Compare commits

...

215 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
132 changed files with 4479 additions and 6468 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

View File

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

View File

@ -9,8 +9,5 @@
<module name="CommandPanels" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="CommandPanels" target="8" />
</bytecodeTargetLevel>
</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>

View File

@ -6,15 +6,110 @@
<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="ChestSort">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/ChestSort.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

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

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

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="MMOItems-6.6.1">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/MMOItems-6.6.1.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="MythicLib-1.1.3">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/MythicLib-1.1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="PlaceholderAPI-2.10.9">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/PlaceholderAPI-2.10.9.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">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot/v1_17_R1/spigot.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot/v1_17_R1/spigot.jar!/" />
</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/v1_13_R2/spigot-1.13.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/spigot/v1_13_R2/spigot-1.13.2.jar!/" />
</SOURCES>
</library>
</component>

View File

@ -1,9 +0,0 @@
<component name="libraryTable">
<library name="spigot-api-1.18.1-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.18.1/bundler/libraries/spigot-api-1.18.1-R0.1-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>

View File

@ -1,27 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</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="CustomItemsAPI_PLACEHOLDER" level="project" />
<orderEntry type="library" name="ChestSort" level="project" />
<orderEntry type="library" name="PlaceholderAPI-2.10.9" level="project" />
<orderEntry type="library" name="MMOItems-6.6.1" level="project" />
<orderEntry type="library" name="MythicLib-1.1.3" level="project" />
<orderEntry type="library" name="spigot-api-1.18.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="spigot" level="project" />
<orderEntry type="library" name="spigot-1.13.2" level="project" />
<orderEntry type="library" name="spigot" level="project" />
<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>

View File

@ -1,25 +1,36 @@
![TitleLogo](https://i.imgur.com/YQMXkoi.png)
### About
Minecraft Servers use GUIs for many tasks from lobbies to shops. Command Panels takes a simple approach to YAML scripting to create a powerful yet simple design.
If you don't feel like scripting, Command Panels is one of the few free plugins you will find that provides a powerful in-game editor. Almost every feature that is available when scripting is included in-game.
<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>
- Lightweight
- PlaceholderAPI support
- Comes with a built in editor
- Unlimited GUIs
- Create complex panel systems
<img align="center" src="https://i.imgur.com/w8UaAP2.png" alt="Screenshot">
### Discord Support
You can join the discord server for support [here](https://discord.gg/eUWBWh7).
This is the main and fastest way to receive support for the plugin.
## 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.
### Wiki Page
You can find the CommandPanels Wiki page [here](https://rockyhawk99.gitbook.io/rockyhawk-wiki/commandpanels/wiki).
The wiki page contains all the features and how to use them.
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**
### Bug Reports
Please report bugs, issues or request features [here](https://github.com/rockyhawk64/CommandPanels/issues).
## 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

197
pom.xml
View File

@ -4,27 +4,214 @@
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>groupId</groupId>
<groupId>me.rockyhawk.commandpanels</groupId>
<artifactId>CommandPanels</artifactId>
<version>1.0-SNAPSHOT</version>
<version>DEV</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<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.11.0</version>
<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,15 +1,13 @@
# |------------------------------------------------------------------------
# | CommandPanels Config File
# | By RockyHawk v5.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# | https://www.spigotmc.org/resources/67788/
# |
# | auto-update and minor-updates-only is HEAVILY RECOMMENDED
# |------------------------------------------------------------------------
config:
refresh-panels: true
refresh-delay: 20
panel-blocks: true
ingame-editor: true
hotbar-items: true
custom-commands: true
auto-register-commands: false
@ -17,10 +15,10 @@ config:
server-ping-timeout: 10
stop-sound: true
disabled-world-message: true
update-notifications: true
panel-snooper: false
enable-import-command: false
format:
tag: '&6[&bCommandPanels&6]'
tag: '&6[&bCommandPanels&6] '
perms: '&cNo permission.'
reload: '&aReloaded.'
nopanel: '&cPanel not found.'
@ -30,15 +28,16 @@ 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:
- '%cp-tag%&aEnter Input for Command'
- '&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'
hexcodes:
start_tag: '#'
start_tag: '&#'
end_tag: ''
placeholders:
primary:
@ -48,25 +47,34 @@ placeholders:
start: '{'
end: '}'
updater:
auto-update: true
minor-updates-only: true
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.17.5.0
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, MMOItems, CustomItems, ChestSort, CoinsAPINB]
softdepend: [Essentials, PlaceholderAPI, Vault, HeadDatabase, TokenManager, VotingPlugin, MMOItems, ChestSort, floodgate]
commands:
commandpanel:
description: Open a command panel.
@ -18,6 +18,10 @@ commands:
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
@ -36,7 +40,7 @@ commands:
aliases: [cpv, cpanelv]
commandpaneledit:
description: Edit panels ingame.
usage: /commandpaneledit [panel]
usage: /commandpaneledit <panel>
aliases: [cpe, cpanele]
commandpanellist:
description: Lists the currently loaded panels.
@ -73,6 +77,8 @@ permissions:
default: op
commandpanel.data:
default: op
commandpanel.refresh:
default: op
commandpanel.edit:
default: op
commandpanel.list:

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Legacy Example File
# | By RockyHawk v2.3
# | Official Panel v2.4
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -107,7 +107,8 @@ panels:
'32':
material: COMPASS
stack: 12
enchanted: true
enchanted:
- true
name: '&cClick Me'
lore:
- '&fI will teleport you home!'

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v3.1
# | Official Panel v3.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v3.1
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -20,102 +20,102 @@ panels:
name: ''
animate0:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'1':
material: AIR
stack: 1
name: ''
animate1:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'2':
material: AIR
stack: 1
name: ''
animate2:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'3':
material: AIR
stack: 1
name: ''
animate3:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'5':
material: AIR
stack: 1
name: ''
animate9:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'6':
material: AIR
stack: 1
name: ''
animate10:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'7':
material: AIR
stack: 1
name: ''
animate11:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'12':
material: AIR
stack: 1
name: ''
animate4:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'14':
material: AIR
stack: 1
name: ''
animate8:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'16':
material: AIR
stack: 1
name: ''
animate12:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'21':
material: AIR
stack: 1
name: ''
animate5:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'22':
material: AIR
stack: 1
name: ''
animate6:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'23':
material: AIR
stack: 1
name: ''
animate7:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'25':
material: AIR
stack: 1
name: ''
animate13:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'
'26':
material: AIR
stack: 1
name: ''
animate14:
material: PUFFERFISH
name: '&eRhys the Pufferfish'
name: '&ePopper the Pufferfish'

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v3.1
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -23,127 +23,127 @@ panels:
- add-data= nextpage 1
item:
'10':
material: 'cps= $cp-player-online-%math_1+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_1+14*{cp-data-onlinepage}%$'
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_1+14*{cp-data-onlinepage}%$'
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_2+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_2+14*{cp-data-onlinepage}%$'
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_2+14*{cp-data-onlinepage}%$'
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_3+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_3+14*{cp-data-onlinepage}%$'
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_3+14*{cp-data-onlinepage}%$'
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_4+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_4+14*{cp-data-onlinepage}%$'
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_4+14*{cp-data-onlinepage}%$'
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_5+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_5+14*{cp-data-onlinepage}%$'
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_5+14*{cp-data-onlinepage}%$'
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_6+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_6+14*{cp-data-onlinepage}%$'
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_6+14*{cp-data-onlinepage}%$'
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_7+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_7+14*{cp-data-onlinepage}%$'
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_7+14*{cp-data-onlinepage}%$'
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_8+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_8+14*{cp-data-onlinepage}%$'
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_8+14*{cp-data-onlinepage}%$'
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_9+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_9+14*{cp-data-onlinepage}%$'
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_9+14*{cp-data-onlinepage}%$'
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_10+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_10+14*{cp-data-onlinepage}%$'
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_10+14*{cp-data-onlinepage}%$'
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_11+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_11+14*{cp-data-onlinepage}%$'
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_11+14*{cp-data-onlinepage}%$'
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_12+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_12+14*{cp-data-onlinepage}%$'
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_12+14*{cp-data-onlinepage}%$'
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_13+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_13+14*{cp-data-onlinepage}%$'
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_13+14*{cp-data-onlinepage}%$'
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_14+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_14+14*{cp-data-onlinepage}%$'
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_14+14*{cp-data-onlinepage}%$'
compare0: '&e$cp-player-online-%math_0:_14+14*{cp-data-onlinepage}%$'
value0: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
@ -160,7 +160,7 @@ panels:
commands:
- math-data= onlinepage -1
- math-data= nextpage -1
- refresh
- open= example_middle_two
'6':
material: ARROW
stack: 1
@ -168,7 +168,7 @@ panels:
commands:
- 'math-data= onlinepage +1'
- 'math-data= nextpage +1'
- 'refresh'
- open= example_middle_two
'4':
material: OAK_SIGN
name: '&e&lOnline Players'

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v3.1
# | Official Panel v3.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -73,18 +73,18 @@ panels:
- placeholder= [item:APPLE]
- refresh
'21':
material: POTION
material: GOLDEN_APPLE
name: '&fClick to heal the player'
potion: INSTANT_HEAL
lore:
- '&7Uses the /heal command so that'
- '&7the player needs permission'
- '&7Uses the /heal command if'
- '&7the player has permission'
commands:
- heal
'24':
material: BOW
name: '&fThis bow is enchanted'
enchanted: true
enchanted:
- true
'26':
material: LEATHER_CHESTPLATE
name: '&eYellow &fArmor'

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Template File
# | By RockyHawk v1.1
# | Official Panel v1.1
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:

View File

@ -1,42 +1,44 @@
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.GetCustomHeads;
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.ingameeditor.OpenEditorGuis;
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.CommandTags;
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.ingameeditor.CpIngameEditCommand;
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
import me.rockyhawk.commandpanels.ingameeditor.EditorUserInput;
import me.rockyhawk.commandpanels.ingameeditor.EditorUtils;
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.Sequence_1_13;
import me.rockyhawk.commandpanels.ioclasses.Sequence_1_14;
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;
@ -47,8 +49,14 @@ 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;
@ -67,7 +75,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.*;
import java.util.concurrent.Callable;
public class CommandPanels extends JavaPlugin{
public YamlConfiguration config;
@ -78,24 +85,30 @@ public class CommandPanels extends JavaPlugin{
public String tag = "[CommandPanels]";
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
public List<String[]> editorInputStrings = new ArrayList<>();
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
//get alternate classes
public CommandTags commandTags = new CommandTags(this);
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 OpenEditorGuis editorGuis = new OpenEditorGuis(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);
@ -114,6 +127,9 @@ public class CommandPanels extends JavaPlugin{
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"));
@ -145,13 +161,14 @@ public class CommandPanels extends JavaPlugin{
//set version to latest version
if (Objects.requireNonNull(this.config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
updater.githubNewUpdate(false);
updater.githubNewUpdate(true);
}
//setup class files
new Metrics(this, 5097);
this.setupEconomy();
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
new Metrics(this);
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));
@ -161,20 +178,49 @@ public class CommandPanels extends JavaPlugin{
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")) {
@ -187,7 +233,7 @@ public class CommandPanels extends JavaPlugin{
}
//load in all built in command tags
commandTags.registerBuiltInTags();
commandRunner.registerBuiltInTags();
//if refresh-panels set to false, don't load this
if(Objects.requireNonNull(config.getString("config.refresh-panels")).equalsIgnoreCase("true")){
@ -204,14 +250,6 @@ public class CommandPanels extends JavaPlugin{
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);
}
//if ingame-editor set to false, don't load this
if(Objects.requireNonNull(config.getString("config.ingame-editor")).equalsIgnoreCase("true")){
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new CpTabCompleteIngame(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CpIngameEditCommand(this));
this.getServer().getPluginManager().registerEvents(new EditorUtils(this), this);
this.getServer().getPluginManager().registerEvents(new EditorUserInput(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));
@ -223,7 +261,6 @@ public class CommandPanels extends JavaPlugin{
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);
@ -232,7 +269,7 @@ public class CommandPanels extends JavaPlugin{
//save the example_top.yml file and the template.yml file
if (!this.panelsf.exists()) {
try {
if(legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
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 {
@ -256,28 +293,24 @@ public class CommandPanels extends JavaPlugin{
}
}
if (Objects.requireNonNull(this.config.getString("config.update-notifications")).equalsIgnoreCase("true")) {
updater.githubNewUpdate(true);
}
//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);
metrics.addCustomChart(new Metrics.SingleLineChart("panels_amount", new Callable<Integer>() {
@Override
public Integer call() throws Exception {
//this is the total panels loaded
return panelList.size();
}
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") + " ");
tag = tex.colour(config.getString("config.format.tag"));
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!");
}
@ -316,13 +349,30 @@ public class CommandPanels extends JavaPlugin{
assert renamedMeta != null;
//hiding attributes will add an NBT tag
if(hideAttributes) {
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
renamedMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
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.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
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);
@ -373,13 +423,13 @@ public class CommandPanels extends JavaPlugin{
}
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<String>(apanels);
Set<String> oset = new HashSet<>(apanels);
if (oset.size() < apanels.size()) {
//there are duplicate panel names
ArrayList<String> opanelsTemp = new ArrayList<String>();
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);
sender.sendMessage(tex.colour(tag) + ChatColor.RED + "Error duplicate panel name: " + tempName);
return false;
}
opanelsTemp.add(tempName);
@ -454,12 +504,18 @@ public class CommandPanels extends JavaPlugin{
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.");
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.");
@ -479,9 +535,6 @@ public class CommandPanels extends JavaPlugin{
if (p.hasPermission("commandpanel.block.list")) {
p.sendMessage(ChatColor.GOLD + "/cpb list " + ChatColor.WHITE + "List blocks that will open panels.");
}
if (p.hasPermission("commandpanel.edit")) {
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
}
}
public final Map<String, Color> colourCodes = new HashMap<String, Color>() {{
@ -506,11 +559,8 @@ public class CommandPanels extends JavaPlugin{
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
if(legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_13) || legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)){
return new Sequence_1_13(this).getReaderFromStream(initialStream);
}else{
return new Sequence_1_14(this).getReaderFromStream(initialStream);
}
byte[] buffer = IOUtils.toByteArray(initialStream);
return new CharSequenceReader(new String(buffer));
}
//split lists using \n escape character

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

@ -45,7 +45,7 @@ public class Utils implements Listener {
//if the panel is clicked on the outside area of the GUI
if (panel.getConfig().contains("outside-commands")) {
try {
plugin.commandTags.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"),e.getClick());
plugin.commandRunner.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"),e.getClick());
}catch(Exception s){
plugin.debug(s,p);
}
@ -87,23 +87,24 @@ public class Utils implements Listener {
panel = plugin.openPanels.getOpenPanel(p.getName(),position);
//this loops through all the items in the panel
boolean foundSlot = false;
for(String slot : Objects.requireNonNull(panel.getConfig().getConfigurationSection("item")).getKeys(false)){
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 = true;
foundSlot = item;
break;
}
}
if(!foundSlot){
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." + clickedSlot), p);
String section = plugin.has.hasSection(panel,position,panel.getConfig().getConfigurationSection("item." + foundSlot), p);
if(panel.getConfig().contains("item." + clickedSlot + section + ".itemType")){
if(panel.getConfig().getStringList("item." + clickedSlot + section + ".itemType").contains("placeable")){
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;
@ -115,26 +116,14 @@ public class Utils implements Listener {
p.updateInventory();
//if an item has an area for input instead of commands
if(panel.getConfig().contains("item." + clickedSlot + section + ".player-input")) {
plugin.inputUtils.playerInput.put(p,new PlayerInput(panel,panel.getConfig().getStringList("item." + clickedSlot + section + ".player-input"),e.getClick()));
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." + clickedSlot + section + ".commands")) {
List<String> commands = panel.getConfig().getStringList("item." + clickedSlot + 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 = panel.getConfig().getStringList(locationOfSequence);
commandsAfterSequence.remove(i);
commandsAfterSequence.addAll(i,commandsSequence);
}
}
commands = commandsAfterSequence;
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()));
@ -142,8 +131,13 @@ public class Utils implements Listener {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "AIR"));
}
}
plugin.commandTags.runCommands(panel,position,p,commands,e.getClick());
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());
}
}
}
}

View File

@ -4,6 +4,7 @@ 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;
@ -19,7 +20,7 @@ public class Panel{
private ConfigurationSection panelConfig;
private String panelName;
private File panelFile;
private File panelFile = null;
public PanelPlaceholders placeholders = new PanelPlaceholders();
public boolean isOpen = false;
@ -86,17 +87,23 @@ public class Panel{
public ItemStack getHotbarItem(Player p){
if (this.getConfig().contains("open-with-item.pre-load-commands")) {
try {
plugin.commandTags.runCommands(this,PanelPosition.Top,p, this.getConfig().getStringList("open-with-item.pre-load-commands"));
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);
int slot = -1;
String slot = "-1";
if(getHotbarSection(p).isSet("stationary")){
slot = getHotbarSection(p).getInt("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);
}
return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName + ":" + slot);
}
public ConfigurationSection getHotbarSection(Player p){
String section = plugin.has.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("open-with-item"), p);

View File

@ -31,18 +31,17 @@ public class ExecuteOpenVoids {
//avoid plugin glitches when sleeping
return;
}
if(plugin.debug.isEnabled(sender) || plugin.config.getBoolean("config.auto-update-panels")){
//reload the panel is debug is enabled
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")));
return;
}else {
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
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) {
@ -50,11 +49,10 @@ public class ExecuteOpenVoids {
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")));
return;
}else {
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
return;
}
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
@ -84,7 +82,7 @@ public class ExecuteOpenVoids {
//execute commands once the panel opens
if (panel.getConfig().contains("commands-on-open")) {
try {
plugin.commandTags.runCommands(panel,position,p, panel.getConfig().getStringList("commands-on-open"));
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")));
}
@ -113,11 +111,9 @@ public class ExecuteOpenVoids {
}else{
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
return;
}else {
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return;
}
}
}
}
@ -159,7 +155,7 @@ public class ExecuteOpenVoids {
public void beforeLoadCommands(Panel panel,PanelPosition pos, Player p){
if (panel.getConfig().contains("pre-load-commands")) {
try {
plugin.commandTags.runCommands(panel,pos,p, panel.getConfig().getStringList("pre-load-commands"));
plugin.commandRunner.runCommands(panel,pos,p, panel.getConfig().getStringList("pre-load-commands"), null);
}catch(Exception s){
plugin.debug(s,p);
}

View File

@ -1,103 +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 me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
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.util.Iterator;
import java.util.UUID;
public class GetCustomHeads {
CommandPanels plugin;
public GetCustomHeads(CommandPanels pl) {
this.plugin = pl;
}
public String getHeadBase64(ItemStack head) {
if (plugin.getHeads.ifSkullOrHead(head.getType().toString()) && head.hasItemMeta()) {
try {
SkullMeta meta = (SkullMeta) head.getItemMeta();
assert meta != null;
if (!meta.hasOwner()) {
Field fld = meta.getClass().getDeclaredField("profile");
fld.setAccessible(true);
GameProfile prof = (GameProfile) fld.get(meta);
Iterator itr = prof.getProperties().get("textures").iterator();
if (itr.hasNext()) {
Property var5 = (Property) itr.next();
return var5.getValue();
}
}
}catch(Exception exc){/*skip return null*/}
}
return null;
}
//getting the head from a Player
@SuppressWarnings("deprecation")
public ItemStack getPlayerHead(String name) {
byte id = 0;
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
id = 3;
}
ItemStack itemStack = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1,id);
SkullMeta meta = (SkullMeta) itemStack.getItemMeta();
meta.setOwner(name);
itemStack.setItemMeta(meta);
return itemStack;
}
@SuppressWarnings("deprecation")
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));
byte id = 0;
if(plugin.legacy.LOCAL_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 {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e1) {
try {
setProfileMethod = headMeta.getClass().getDeclaredMethod("setProfile", GameProfile.class);
} catch (NoSuchMethodException ignore) {}
} catch (SecurityException ignored) {}
try {
if (setProfileMethod == null) {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} else {
setProfileMethod.setAccessible(true);
setProfileMethod.invoke(headMeta, profile);
}
} catch (Exception e1) {
plugin.debug(e1,null);
}
head.setItemMeta(headMeta);
return head;
}
}
}

View File

@ -9,9 +9,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.*;
public class HasSections {
CommandPanels plugin;
@ -19,72 +17,85 @@ public class HasSections {
plugin = pl;
}
public String hasSection(Panel panel, PanelPosition position, ConfigurationSection cf, Player p){
for (int count = 0; cf.getKeys(false).size() > count; count++) {
String setName;
if(cf.isSet("has" + count)) {
setName = "has" + count;
}else if(cf.isSet("hasperm" + count)) {
setName = "hasperm" + count;
}else if(cf.isSet("hasvalue" + count)) {
setName = "hasvalue" + count;
}else if(cf.isSet("hasgreater" + count)) {
setName = "hasgreater" + count;
}else{
continue;
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.
}
}
}
boolean endProcess = true;
//loop through possible values and compares for hypothetical and operators
for (int a = 0; cf.getConfigurationSection(setName).getKeys(false).size() > a; a++) {
if(cf.isSet(setName + ".value" + a) && cf.isSet(setName + ".compare" + a)){
//ensure the endProcess variable has been reset for another operation
endProcess = true;
//get the values of this statement
String value = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, cf.getString(setName + ".value" + a)));
String compare = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, cf.getString(setName + ".compare" + a)));
for (String hasSection : sortedSections.values()) {
if (!cf.isConfigurationSection(hasSection)) continue;
String operator = "AND";
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);
}
ConfigurationSection currentSection = cf.getConfigurationSection(hasSection);
int numberOfConditions = currentSection.getKeys(false).size();
//list of values with the or operator
HashSet<String> values = doOperators(new HashSet<>(Collections.singletonList(value)));
//go through all values with the or operator
for(String val : values){
if (hasProcess(setName, val, compare, p)) {
endProcess = false;
//if it is true and it is OR, there is no need to check the next value in the line
if(operator.equals("OR")){
a++;
}
}
}
if(endProcess){
//check if the operator link between the next value/compare is OR
if(operator.equals("OR")){
//I can just continue because the algorithm already assumes the last sequence was true
endProcess = false;
continue;
}
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 the has section is false move to the next has section
if(endProcess){
continue;
if (currentBlockResult != null && currentBlockResult) {
// If the result of this section is true, check nested sections.
return "." + hasSection + hasSection(panel, position, currentSection, p);
}
//proceed if none of the values were false
return "." + setName + hasSection(panel, position, cf.getConfigurationSection(setName), 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 ")){
@ -96,7 +107,7 @@ public class HasSections {
return value;
}
private boolean hasProcess(String setName, String value, String compare,Player p){
private boolean hasProcess(String value, String compare){
//check to see if the value should be reversed
boolean outputValue = true;
if(value.startsWith("NOT ")){
@ -104,25 +115,17 @@ public class HasSections {
outputValue = false;
}
//the original has sections as TinyTank800 wanted to keep them
if(setName.startsWith("hasvalue")) {
return compare.equals(value) == outputValue;
}
if(setName.startsWith("hasperm")) {
return p.hasPermission(value) == outputValue;
}
if(setName.startsWith("hasgreater")) {
return (Long.parseLong(compare) >= Long.parseLong(value)) == outputValue;
}
//the current has section with all of the functions implemented inside it
if(setName.startsWith("has")) {
if(value.endsWith(" HASPERM")) {
return Bukkit.getPlayer(value.substring(0, value.length()-8)).hasPermission(compare) == outputValue;
}else if(value.endsWith(" ISGREATER")) {
return (new BigDecimal(compare).compareTo(new BigDecimal(value.substring(0, value.length()-10))) <= 0 == outputValue);
}else{
return compare.equals(value) == outputValue;
//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

@ -1,9 +1,10 @@
package me.rockyhawk.commandpanels.classresources;
import com.jojodmo.customitems.api.CustomItemsAPI;
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;
@ -15,23 +16,20 @@ 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.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.potion.PotionData;
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 javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
public class ItemCreation {
@ -53,7 +51,7 @@ public class ItemCreation {
return null;
}
ItemStack s = null;
boolean hideAttributes = true;
boolean hideAttributes = false;
String mat;
String matraw;
String skullname;
@ -86,7 +84,7 @@ public class ItemCreation {
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.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
id = 3;
}
}
@ -94,11 +92,55 @@ public class ItemCreation {
if (matraw.split("\\s")[0].equalsIgnoreCase("hdb=")) {
skullname = "hdb";
mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
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];
@ -109,12 +151,6 @@ public class ItemCreation {
normalCreation = false;
}
//creates Custom Items items
if(matraw.split("\\s")[0].equalsIgnoreCase("cui=") && plugin.getServer().getPluginManager().isPluginEnabled("CustomItems")){
s = CustomItemsAPI.getCustomItem("cui:" + matraw.split("\\s")[1]);
normalCreation = false;
}
//creates a written book item
if(matraw.split("\\s")[0].equalsIgnoreCase("book=")){
s = new ItemStack(Material.WRITTEN_BOOK);
@ -130,7 +166,7 @@ public class ItemCreation {
//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, true);
s = makeCustomItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, false);
normalCreation = false;
}
@ -144,7 +180,7 @@ public class ItemCreation {
if (matraw.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self
meta = (SkullMeta) s.getItemMeta();
if(!plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
if(!plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
@ -194,79 +230,38 @@ public class ItemCreation {
if(itemSection.contains("itemType")){
//if hidden, reverse
if(itemSection.getStringList("itemType").contains("noAttributes")){
hideAttributes = false;
}
if(itemSection.getStringList("itemType").contains("noNBT")){
addNBT = false;
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){
s = plugin.nbt.setNBT(s);
plugin.nbt.setNBT(s, "CommandPanelsItem","boolean_" + "true");
}
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_top.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.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found."));
}
}catch(Exception map){
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map,p);
}
}
if (itemSection.contains("enchanted")) {
try {
ItemMeta EnchantMeta;
if(itemSection.isList("enchanted")){
//if there is a list of enchantments to add
//if list contains true, hide enchanted and add KNOCKBACK
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
for(String enchantment : itemSection.getStringList("enchanted")){
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(enchantment.split("\\s")[0].toLowerCase()))), Integer.parseInt(enchantment.split("\\s")[1]), true);
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);
}else if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) {
//if used if enchanted is set to 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")) {
//if used to ensure enchanted does not equal false but equals something else
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.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
@ -284,11 +279,11 @@ public class ItemCreation {
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
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED,STRIPE_TOP
}
bannerMeta.setPatterns(patterns);
bannerMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
s.setItemMeta(bannerMeta);
}
}catch(Exception ignore){
@ -297,9 +292,13 @@ public class ItemCreation {
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) {
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 = itemSection.getString("leatherarmor");
String colourCode = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("leatherarmor"));
assert colourCode != null;
if (!colourCode.contains(",")) {
//use a color name
@ -327,38 +326,46 @@ public class ItemCreation {
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").split("\\s");
assert potionMeta != null;
boolean extended = false;
boolean upgraded = false;
//create data
if(effectType.length >= 2){
if(effectType[1].equalsIgnoreCase("true")){
extended = true;
}
if(effectType.length == 3){
if(effectType[2].equalsIgnoreCase("true")){
upgraded = true;
}
}
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")));
}
PotionData newData = new PotionData(PotionType.valueOf(effectType[0].toUpperCase()),extended,upgraded);
//set meta
potionMeta.setBasePotionData(newData);
potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
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.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
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) {
@ -371,33 +378,60 @@ public class ItemCreation {
ItemMeta unbreak = s.getItemMeta();
unbreak.setUnbreakable(true);
s.setItemMeta(unbreak);
}
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")));
}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")));
}
}
}
}
if (itemSection.contains("nbt")) {
for(String key : itemSection.getConfigurationSection("nbt").getKeys(false)){
s = plugin.nbt.setNBT(s,key,itemSection.getString("nbt." + key));
// 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;
}
plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
s = plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
return s;
}
@ -428,7 +462,7 @@ public class ItemCreation {
}
}
}
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
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());
}
@ -446,14 +480,7 @@ public class ItemCreation {
}
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("=")) {
SkullMeta meta = (SkullMeta) cont.getItemMeta();
if (plugin.customHeads.getHeadBase64(cont) != null && !plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
//inject base64 here, disable for legacy as is not working
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + plugin.customHeads.getHeadBase64(cont));
} else if (meta.hasOwner()) {
//check for skull owner
file.set("panels." + panelName + ".item." + i + ".material", "cps= " + meta.getOwner());
}
file.set("panels." + panelName + ".item." + i + ".material", plugin.getHeads.playerHeadString());
}
}
try {
@ -467,12 +494,37 @@ public class ItemCreation {
//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()){
file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
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
}
@ -486,11 +538,14 @@ public class ItemCreation {
Material, Name, Lore, Enchanted, Potion
*/
@SuppressWarnings("deprecation")
public boolean isIdentical(ItemStack one, ItemStack two){
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())) {
@ -499,6 +554,13 @@ public class ItemCreation {
}
}
}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())) {
@ -507,9 +569,27 @@ public class ItemCreation {
}
}
}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.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(one.getDurability() != two.getDurability()) {
return false;
}
@ -523,19 +603,21 @@ public class ItemCreation {
} catch (Exception ignore) {}
//check for potions
try {
PotionMeta meta1 = (PotionMeta) one.getItemMeta();
PotionMeta meta2 = (PotionMeta) two.getItemMeta();
//different duration
if(meta1.getBasePotionData().isExtended() != meta2.getBasePotionData().isExtended()){
return false;
}
//different upgrade
if(meta1.getBasePotionData().isUpgraded() != meta2.getBasePotionData().isUpgraded()){
return false;
}
//different potion type
if (meta1.getBasePotionData().getType().compareTo(meta2.getBasePotionData().getType()) != 0){
return false;
//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
@ -546,4 +628,20 @@ public class ItemCreation {
}
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

@ -1,12 +0,0 @@
package me.rockyhawk.commandpanels.classresources;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
public class SerializerUtils {
public static Component serializeText(String msg){
Component parsedText = MiniMessage.miniMessage().deserialize(msg);
return parsedText;
}
}

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

@ -37,6 +37,7 @@ public class ItemFallManager implements Listener {
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;

View File

@ -74,7 +74,9 @@ public class CreateText {
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt, plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
setpapi.set(tempInt,
plugin.hex.translateHexColorCodes(
ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){}
tempInt += 1;
}
@ -84,7 +86,11 @@ public class CreateText {
//regular string papi, but only colours so Player doesn't need to be there
public String colour(String setpapi) {
try {
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', 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;
@ -105,7 +111,11 @@ public class CreateText {
public String placeholders(Panel panel, PanelPosition position, Player p, String setpapi) {
try {
setpapi = attachPlaceholders(panel,position, p,setpapi);
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', 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;

View File

@ -35,7 +35,7 @@ public class HexColours {
}
//automatically format regex to escape special characters
public String formatRegex(String path){
private String formatRegex(String path){
String inputString = plugin.config.getString(path);
final String[] metaCharacters = {"\\","^","$","{","}","[","]","(",")",".","*","+","?","|","<",">","-","&","%"};

View File

@ -1,8 +1,6 @@
package me.rockyhawk.commandpanels.classresources.placeholders;
import com.bencodez.votingplugin.user.UserManager;
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
import me.realized.tokenmanager.api.TokenManager;
import com.earth2me.essentials.Essentials;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
@ -11,13 +9,12 @@ 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.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
public class Placeholders {
CommandPanels plugin;
@ -96,6 +93,16 @@ public class Placeholders {
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();
}
@ -131,19 +138,53 @@ public class Placeholders {
}
}
//placeholder to check if an item has NBT %cp-nbt-slot:key%
if(identifier.startsWith("nbt-")) {
//placeholder to check if an item has NBT %cp-nbt-slot:type:key%
if (identifier.startsWith("nbt-")) {
try {
String slot_key = identifier.replace("nbt-", "");
String value;
value = plugin.nbt.getNBT(p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(slot_key.split(":")[0])),slot_key.split(":")[1]);
if(value == null){
value = "empty";
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
}
return value;
}catch (Exception ex){
plugin.debug(ex,p);
return "";
} catch (Exception ex) {
plugin.debug(ex, p);
return ""; // Handle exceptions as needed
}
}
@ -155,9 +196,9 @@ public class Placeholders {
String material;
try {
material = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getType().toString();
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
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)).getType().getId();
material = material + ":" + p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber)).getData().getData();
}
} catch (NullPointerException er) {
material = "AIR";
@ -168,6 +209,52 @@ public class Placeholders {
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 {
@ -207,7 +294,7 @@ public class Placeholders {
boolean damaged = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem((int)Double.parseDouble(matNumber));
try {
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)){
if(itm.getType().getMaxDurability() != 0) {
damaged = (itm.getType().getMaxDurability() - itm.getDurability()) < itm.getType().getMaxDurability();
}
@ -241,7 +328,7 @@ public class Placeholders {
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)){
if(plugin.itemCreate.isIdentical(confItm,itm, Objects.requireNonNull(panel.getConfig().getConfigurationSection("custom-item." + matLoc)).contains("nbt"))){
isIdentical = true;
}
@ -286,7 +373,7 @@ public class Placeholders {
if(dataPoint.contains(",")){
String dataName = dataPoint.split(",")[0];
String playerName = dataPoint.split(",")[1];
return plugin.panelData.getUserData(Bukkit.getOfflinePlayer(playerName).getUniqueId(),dataName);
return plugin.panelData.getUserData(plugin.panelDataPlayers.getOffline(playerName),dataName);
}else{
return plugin.panelData.getUserData(p.getUniqueId(),dataPoint);
}
@ -295,12 +382,26 @@ public class Placeholders {
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("cp-setdata-", "");
String point_value = identifier.replace("setdata-", "");
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.runCommand(panel,position,p, command);
plugin.commandRunner.runCommand(panel,position,p, command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);
@ -312,7 +413,7 @@ public class Placeholders {
try {
String point_value = identifier.replace("mathdata-", "");
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.runCommand(panel,position,p,command);
plugin.commandRunner.runCommand(panel,position,p,command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);
@ -324,12 +425,27 @@ public class Placeholders {
if(identifier.startsWith("player-online-")) {
try {
String playerLocation = identifier.replace("player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Double.parseDouble(playerLocation) > playerFind.length) {
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
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 {
return playerFind[(int)(Double.parseDouble(playerLocation) - 1)].getName();
//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 "";
@ -345,24 +461,17 @@ public class Placeholders {
} catch (Exception place) {
//skip
}
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
if(identifier.equals("tokenmanager-balance")) {
return Long.toString(api.getTokens(p).orElse(0));
}
}
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
if(identifier.equals("coins-balance")) {
return String.valueOf(CoinsAPI.getCoins(p.getUniqueId().toString()));
}
}
if (plugin.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
if(identifier.equals("votingplugin-points")) {
return String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints());
}
}
//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

@ -8,73 +8,37 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
public class CommandPanelImport implements CommandExecutor {
CommandPanels plugin;
public CommandPanelImport(CommandPanels pl) { this.plugin = pl; }
@EventHandler
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() {
downloadPanel(sender,args[1],args[0]);
plugin.downloader.downloadPanel(sender, args[1], args[0]);
plugin.reloadPanelFiles();
plugin.hotbar.reloadHotbarSlots();
}
}.run();
return true;
}
}else{
} 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;
}
private void downloadPanel(CommandSender sender, String url, String fileName) {
BufferedInputStream in = null;
FileOutputStream fout = null;
try {
URL fileUrl = new URL(url);
in = new BufferedInputStream(fileUrl.openStream());
fout = new FileOutputStream(new File(plugin.panelsf, fileName + ".yml"));
byte[] data = new byte[1024];
int count;
while((count = in.read(data, 0, 1024)) != -1) {
fout.write(data, 0, count);
}
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading.");
} catch (Exception var22) {
sender.sendMessage(plugin.tag + ChatColor.RED + "Could not download panel.");
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException var21) {
this.plugin.getLogger().log(Level.SEVERE, null, var21);
}
try {
if (fout != null) {
fout.close();
}
} catch (IOException var20) {
this.plugin.getLogger().log(Level.SEVERE, null, var20);
}
}
}
}

View File

@ -3,6 +3,7 @@ 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;
@ -17,79 +18,97 @@ public class Commandpanel implements CommandExecutor {
this.plugin = pl;
}
@EventHandler
@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])) {
for (Panel tempPanel : plugin.panelList) {
if (tempPanel.getName().equals(args[0])) {
panel = tempPanel;
break;
}
}
}else{
} else {
plugin.helpMessage(sender);
return true;
}
if(panel == null){
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().contains("panelType")) {
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
//do not allow command with noCommand, console is an exception
disableCommand = true;
disableCommand = 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")) {
if(!(sender instanceof Player)) {
//do console command command
if(args.length == 2){
if(!args[1].equals("item")){
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]"));
}
return true;
}else if(args.length == 3){
if (args[1].equals("item")) {
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]"));
}
return true;
} else {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command directed to a Player!"));
return true;
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player|all]"));
}
}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) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(),PanelPosition.Top, true);
}
}
return true;
}else if(args.length == 3){
plugin.openVoids.giveHotbarItem(sender, plugin.getServer().getPlayer(args[2]), panel.copy(),true);
return true;
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:item] [player]"));
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [player|all:item] [player|all]"));
return true;
}
}

View File

@ -1,84 +1,126 @@
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 org.bukkit.event.EventHandler;
import java.util.Arrays;
public class Commandpanelsdata implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsdata(CommandPanels pl) { this.plugin = pl; }
@EventHandler
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[0].equalsIgnoreCase("-s")){
args = Arrays.copyOfRange(args, 1, args.length);
sendPlayerMessage = false;
if(args.length != 0) {
if (args[0].equalsIgnoreCase("-s")) {
args = Arrays.copyOfRange(args, 1, args.length);
sendPlayerMessage = false;
}
}
if(args.length == 2){
int count = 0;
if (args.length == 2) {
//for the clear command
if(args[0].equals("clear")){
plugin.panelData.clearData(plugin.panelData.getOffline(args[1]));
if(sendPlayerMessage) {
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 + args[1]));
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
return true;
return true;
}
}else if (args.length == 3){
} else if (args.length == 3) {
//for the remove command
if(args[0].equals("remove")) {
plugin.panelData.delUserData(plugin.panelData.getOffline(args[1]), args[2]);
if(sendPlayerMessage) {
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 + args[1]));
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
return true;
}else if(args[0].equals("get")){
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.panelData.getOffline(args[1]), args[2])));
return true;
+ ChatColor.WHITE + plugin.panelData.getUserData(plugin.panelDataPlayers.getOffline(args[1]), args[2])));
return true;
}
}else if (args.length == 4){
if(args[0].equals("set")){
} else if (args.length == 4) {
if (args[0].equals("set")) {
//for set command
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],true);
if(sendPlayerMessage) {
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.WHITE + args[3]
+ ChatColor.GREEN + " for "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")));
}
}else{
} else {
//for add command
plugin.panelData.setUserData(plugin.panelData.getOffline(args[1]), args[2],args[3],false);
if(sendPlayerMessage) {
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 + " if it did not exist already");
+ ChatColor.GREEN + " for "
+ ChatColor.WHITE + (count == 0 ? args[1] : count + "" + ChatColor.GREEN + " players")
+ " if it did not exist already");
}
}
return true;
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpdata <set:add:get:remove:clear> <player> <data> [value]"));
}else{
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

@ -6,13 +6,12 @@ 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 Commandpanelsdebug implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
@EventHandler
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.debug")) {
if (args.length == 0) {

View File

@ -33,24 +33,27 @@ public class Commandpanelsreload implements CommandExecutor {
}
plugin.reloadPanelFiles();
if(new File(plugin.getDataFolder() + File.separator + "temp.yml").delete()){
//empty
}
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();
}
plugin.tag = plugin.tex.colour(plugin.config.getString("config.format.tag") + " ");
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")));
@ -107,4 +110,5 @@ public class Commandpanelsreload implements CommandExecutor {
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

@ -11,7 +11,7 @@ public class Commandpanelversion implements CommandExecutor {
CommandPanels plugin;
public Commandpanelversion(CommandPanels pl) { this.plugin = pl; }
@EventHandler
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpv") || label.equalsIgnoreCase("commandpanelversion") || label.equalsIgnoreCase("cpanelv")) {

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
}
}
}

View File

@ -3,7 +3,6 @@ package me.rockyhawk.commandpanels.commandtags;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -23,7 +22,7 @@ public class CommandTagEvent extends Event {
this.panel = panel1;
this.pos = position;
//do nopapi= tag (donation feature) which will stop PlaceholderAPI placeholders from executing
//do nopapi= tag which will stop PlaceholderAPI placeholders from executing
boolean doApiPlaceholders = true;
if(rawCommand1.startsWith("nopapi= ")){
rawCommand1 = rawCommand1.replace("nopapi= ","");
@ -40,8 +39,8 @@ public class CommandTagEvent extends Event {
if(doApiPlaceholders) {
this.args = plugin.tex.attachPlaceholders(panel1,pos, player, split[1].trim()).split("\\s");
}else{
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),false)).split("\\s");
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),true)).split("\\s");
this.args = plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),false).split("\\s");
this.args = plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),true).split("\\s");
}
}

View File

@ -1,421 +0,0 @@
package me.rockyhawk.commandpanels.commandtags;
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.commandtags.tags.economy.BuyCommandTags;
import me.rockyhawk.commandpanels.commandtags.tags.economy.BuyItemTags;
import me.rockyhawk.commandpanels.commandtags.tags.economy.SellItemTags;
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.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class CommandTags {
CommandPanels plugin;
public CommandTags(CommandPanels pl) {
this.plugin = pl;
}
//with the click type included
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands, ClickType click){
for (String command : commands) {
command = plugin.commandTags.hasCorrectClick(command,click);
if(command.equals("")){
//click type is wrong
continue;
}
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
if(val == PaywallOutput.Blocked){
break;
}
if(val == PaywallOutput.NotApplicable){
plugin.commandTags.runCommand(panel,position,p, command);
}
}
}
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands){
for (String command : commands) {
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
if(val == PaywallOutput.Blocked){
break;
}
if(val == PaywallOutput.NotApplicable){
plugin.commandTags.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.placeholders(panel,position,p,commandRAW.trim()));
}
}
//do this on startup to load listeners
public void registerBuiltInTags(){
plugin.getServer().getPluginManager().registerEvents(new BuyCommandTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new BuyItemTags(plugin), plugin);
plugin.getServer().getPluginManager().registerEvents(new SellItemTags(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=":{
//if commands is for right clicking, remove the 'right=' and continue
command = command.replace("rightshift= ", "");
if (click != ClickType.SHIFT_RIGHT) {
return "";
}
break;
}
case "left=":{
//if commands is for right clicking, remove the 'right=' and continue
command = command.replace("left= ", "");
if (click != ClickType.LEFT) {
return "";
}
break;
}
case "leftshift=":{
//if commands is for right clicking, remove the 'right=' and continue
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
}
}
@SuppressWarnings("deprecation")
public PaywallOutput commandPayWall(Panel panel, Player p, String rawCommand) { //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") + " ";
//create new instance of command but with placeholders parsed
String command = plugin.tex.placeholders(panel,PanelPosition.Top,p,rawCommand);
switch(command.split("\\s")[0]){
case "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]));
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p,plugin.config.getString("purchase.currency.failure"));
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!");
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
case "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
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p,plugin.config.getString("purchase.tokens.failure"));
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs TokenManager to work!");
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
case "coinpaywall=": {
//if player uses coinpaywall= [price]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
int balance = CoinsAPI.getCoins(p.getUniqueId().toString());
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
CoinsAPI.removeCoins(p.getUniqueId().toString(), (int) Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p,plugin.config.getString("purchase.coins.failure"));
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs CoinAPI to work!");
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
case "item-paywall=": {
//if player uses item-paywall= [Material] [Amount] [Id]
//player can use item-paywall= [custom-item]
List<ItemStack> cont = new ArrayList<>(Arrays.asList(plugin.inventorySaver.getNormalInventory(p)));
try {
short id = 0;
if(command.split("\\s").length == 4){
id = Short.parseShort(command.split("\\s")[3]);
}
//create the item to be removed
ItemStack sellItem;
if(command.split("\\s").length == 2) {
sellItem = plugin.itemCreate.makeCustomItemFromConfig(panel,PanelPosition.Top,panel.getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
}else{
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id);
}
//this is not a boolean because it needs to return an int
PaywallOutput removedItem = PaywallOutput.Blocked;
//loop through items in the inventory
for(int f = 0; f < 36; f++){
if(cont.get(f) == null){
//skip slot if empty
continue;
}
if(command.split("\\s").length == 2){
//if item paywall is custom item
if(plugin.itemCreate.isIdentical(sellItem,cont.get(f))){
if (sellItem.getAmount() <= cont.get(f).getAmount()) {
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
} else {
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
//if custom item is an mmo item (1.14+ for the API)
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && panel.getConfig().getString("custom-item." + command.split("\\s")[1] + ".material").startsWith("mmo=")) {
String customItemMaterial = panel.getConfig().getString("custom-item." + command.split("\\s")[1] + ".material");
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (plugin.isMMOItem(cont.get(f),mmoType,mmoID) && sellItem.getAmount() <= cont.get(f).getAmount()) {
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
}else{
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
}catch (Exception ex){
plugin.debug(ex,p);
}
}else {
//if the item is a standard material
if (cont.get(f).getType() == sellItem.getType()) {
if (sellItem.getAmount() <= cont.get(f).getAmount()) {
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
}else{
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
}
}
//send message and return
if(removedItem == PaywallOutput.Blocked){
plugin.tex.sendString(p, tag + plugin.config.getString("purchase.item.failure"));
}else{
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString()));
}
return removedItem;
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
case "xp-paywall=": {
//if player uses xp-paywall= <price> <levels:points>
try {
int balance;
if(command.split("\\s")[2].startsWith("level")){
balance = p.getLevel();
}else{
balance = getPlayerExp(p);
}
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
if(command.split("\\s")[2].startsWith("level")){
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
}else{
removePlayerExp(p,Integer.parseInt(command.split("\\s")[1]));
}
//if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p, plugin.config.getString("purchase.xp.failure"));
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
case "data-paywall=": {
//if player uses data-paywall= <data> <amount>
try {
if (Double.parseDouble(plugin.panelData.getUserData(p.getUniqueId(),command.split("\\s")[1])) >= Double.parseDouble(command.split("\\s")[2])) {
plugin.panelData.doDataMath(p.getUniqueId(),command.split("\\s")[1],"-" + plugin.tex.placeholdersNoColour(panel,PanelPosition.Top,p,command.split("\\s")[2]));
//if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[2]));
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p, plugin.config.getString("purchase.data.failure"));
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return PaywallOutput.Blocked;
}
}
}
return PaywallOutput.NotApplicable;
}
//Experience math is a bit doggy doo doo so these will help to calculate values
// Calculate total experience up to a level
// @author thelonelywolf@https://github.com/TheLonelyWolf1
// @date 06 August 2021
private int getExpAtLevel(int level){
if(level <= 16){
return (int) (Math.pow(level,2) + 6*level);
} else if(level <= 31){
return (int) (2.5*Math.pow(level,2) - 40.5*level + 360.0);
} else {
return (int) (4.5*Math.pow(level,2) - 162.5*level + 2220.0);
}
}
// Calculate amount of EXP needed to level up
private int getExpToLevelUp(int level){
if(level <= 15){
return 2*level+7;
} else if(level <= 30){
return 5*level-38;
} else {
return 9*level-158;
}
}
// Calculate player's current EXP amount
private int getPlayerExp(Player player){
int exp = 0;
int level = player.getLevel();
// Get the amount of XP in past levels
exp += getExpAtLevel(level);
// Get amount of XP towards next level
exp += Math.round(getExpToLevelUp(level) * player.getExp());
return exp;
}
// Take EXP
private int removePlayerExp(Player player, int exp){
// Get player's current exp
int currentExp = getPlayerExp(player);
// Reset player's current exp to 0
player.setExp(0);
player.setLevel(0);
// Give the player their exp back, with the difference
int newExp = currentExp - exp;
player.giveExp(newExp);
// Return the player's new exp amount
return newExp;
}
}

View File

@ -0,0 +1,57 @@
package me.rockyhawk.commandpanels.commandtags;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class PaywallEvent extends Event {
public final Player p;
public final Panel panel;
public String[] raw;
public String[] args;
public String name;
public PanelPosition pos;
public boolean doDelete = true; //if payment should be removed or not
public PaywallOutput PAYWALL_OUTPUT = PaywallOutput.NotApplicable; //the final output
public PaywallEvent(CommandPanels plugin, Panel panel1, PanelPosition position, Player player, String rawCommand1) {
this.p = player;
this.panel = panel1;
this.pos = position;
//do nopapi= tag which will stop PlaceholderAPI placeholders from executing
boolean doApiPlaceholders = true;
if(rawCommand1.startsWith("nopapi= ")){
rawCommand1 = rawCommand1.replace("nopapi= ","");
doApiPlaceholders = false;
}
String[] split = rawCommand1.split(" ", 2);
if(split.length == 1){
split = new String[]{split[0],""};
}
this.name = split[0].trim();
this.raw = split[1].trim().split("\\s");
if(doApiPlaceholders) {
this.args = plugin.tex.attachPlaceholders(panel1,pos, player, split[1].trim()).split("\\s");
}else{
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),false)).split("\\s");
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),true)).split("\\s");
}
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -0,0 +1,44 @@
package me.rockyhawk.commandpanels.commandtags.paywalls;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Objects;
public class DataPaywall implements Listener {
CommandPanels plugin;
public DataPaywall(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e){
if(e.name.equalsIgnoreCase("data-paywall=")){
//if player uses data-paywall= <data> <amount>
try {
if (Double.parseDouble(plugin.panelData.getUserData(e.p.getUniqueId(), e.args[0])) >= Double.parseDouble(e.args[1])) {
if (e.doDelete)
plugin.panelData.doDataMath(e.p.getUniqueId(), e.args[0], "-" + plugin.tex.placeholdersNoColour(e.panel, PanelPosition.Top, e.p, e.args[1]));
//if the message is empty don't send
if (plugin.config.getBoolean("purchase.data.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.data.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.data.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc, e.p);
plugin.tex.sendString(e.p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
}

View File

@ -0,0 +1,50 @@
package me.rockyhawk.commandpanels.commandtags.paywalls;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Objects;
public class Hasperm implements Listener {
CommandPanels plugin;
public Hasperm(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e){
if(e.name.equalsIgnoreCase("hasperm=")){
//if player uses hasperm= [perm]
if (e.p.hasPermission(e.args[0])) {
if (plugin.config.getBoolean("purchase.permission.enable") && e.doDelete) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.permission.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.currency.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.permission.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
if(e.name.equalsIgnoreCase("hasnoperm=")){
//if player uses hasnoperm= [perm]
if (!e.p.hasPermission(e.args[0])) {
if (plugin.config.getBoolean("purchase.permission.enable") && e.doDelete) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.permission.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.currency.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.permission.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
}

View File

@ -0,0 +1,49 @@
package me.rockyhawk.commandpanels.commandtags.paywalls;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Objects;
public class Paywall implements Listener {
CommandPanels plugin;
public Paywall(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e){
if(e.name.equalsIgnoreCase("paywall=")){
//if player uses paywall= [price]
try {
if (plugin.econ != null) {
double paywallAmount = Double.parseDouble(e.args[0]);
if (plugin.econ.getBalance(e.p) >= paywallAmount) {
if (e.doDelete) plugin.econ.withdrawPlayer(e.p, paywallAmount);
if (plugin.config.getBoolean("purchase.currency.enable") && e.doDelete) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.currency.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!");
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc, e.p);
plugin.tex.sendString(e.p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
}

View File

@ -0,0 +1,77 @@
package me.rockyhawk.commandpanels.commandtags.paywalls;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.lang.reflect.Method;
import java.util.Objects;
import java.util.OptionalLong;
public class TokenPaywall implements Listener {
private final CommandPanels plugin;
public TokenPaywall(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e) {
if (e.name.equalsIgnoreCase("tokenpaywall=")) {
// if player uses tokenpaywall= [price]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
// Using reflection in this method as TokenManager has issues with Maven due to the Jitpack dependency
Object api = Bukkit.getPluginManager().getPlugin("TokenManager");
if (api != null) {
// Use reflection to access the getTokens and removeTokens methods
Method getTokensMethod = api.getClass().getMethod("getTokens", org.bukkit.entity.Player.class);
Method removeTokensMethod = api.getClass().getMethod("removeTokens", org.bukkit.entity.Player.class, long.class);
// Call getTokens
Object result = getTokensMethod.invoke(api, e.p);
long balance;
if (result instanceof OptionalLong) {
balance = ((OptionalLong) result).orElse(0L);
} else {
balance = 0L;
}
if (balance >= Double.parseDouble(e.args[0])) {
if (e.doDelete) {
// Call removeTokens
removeTokensMethod.invoke(api, e.p, Long.parseLong(e.args[0]));
}
// if the message is empty don't send
if (plugin.config.getBoolean("purchase.tokens.enable") && e.doDelete) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.tokens.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "Needs TokenManager to work!");
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "Needs TokenManager to work!");
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} catch (Exception ex) {
plugin.debug(ex, e.p);
plugin.tex.sendString(e.p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
}

View File

@ -0,0 +1,111 @@
package me.rockyhawk.commandpanels.commandtags.paywalls;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Objects;
public class XpPaywall implements Listener {
CommandPanels plugin;
public XpPaywall(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e){
if(e.name.equalsIgnoreCase("xp-paywall=")){
//if player uses xp-paywall= <price> <level:points>
try {
int balance;
if (e.args[1].startsWith("level")) {
balance = e.p.getLevel();
} else {
balance = getPlayerExp(e.p);
}
if (balance >= Integer.parseInt(e.args[0])) {
if (e.args[1].startsWith("level")) {
if (e.doDelete) e.p.setLevel(e.p.getLevel() - Integer.parseInt(e.args[0]));
} else {
if (e.doDelete) removePlayerExp(e.p, Integer.parseInt(e.args[0]));
}
//if the message is empty don't send
if (plugin.config.getBoolean("purchase.xp.enable") && e.doDelete) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", e.args[0]));
}
e.PAYWALL_OUTPUT = PaywallOutput.Passed;
} else {
if (plugin.config.getBoolean("purchase.xp.enable")) {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.xp.failure")));
}
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc, e.p);
plugin.tex.sendString(e.p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
//Experience math is a bit doggy doo doo so these will help to calculate values
// Calculate total experience up to a level
// @author thelonelywolf@https://github.com/TheLonelyWolf1
// @date 06 August 2021
private int getExpAtLevel(int level) {
if (level <= 16) {
return (int) (Math.pow(level, 2) + 6 * level);
} else if (level <= 31) {
return (int) (2.5 * Math.pow(level, 2) - 40.5 * level + 360.0);
} else {
return (int) (4.5 * Math.pow(level, 2) - 162.5 * level + 2220.0);
}
}
// Calculate amount of EXP needed to level up
private int getExpToLevelUp(int level) {
if (level <= 15) {
return 2 * level + 7;
} else if (level <= 30) {
return 5 * level - 38;
} else {
return 9 * level - 158;
}
}
// Calculate player's current EXP amount
private int getPlayerExp(Player player) {
int exp = 0;
int level = player.getLevel();
// Get the amount of XP in past levels
exp += getExpAtLevel(level);
// Get amount of XP towards next level
exp += Math.round(getExpToLevelUp(level) * player.getExp());
return exp;
}
// Take EXP
private int removePlayerExp(Player player, int exp) {
// Get player's current exp
int currentExp = getPlayerExp(player);
// Reset player's current exp to 0
player.setExp(0);
player.setLevel(0);
// Give the player their exp back, with the difference
int newExp = currentExp - exp;
player.giveExp(newExp);
// Return the player's new exp amount
return newExp;
}
}

View File

@ -0,0 +1,21 @@
package me.rockyhawk.commandpanels.commandtags.paywalls.itempaywall;
import org.bukkit.inventory.ItemStack;
public class InventoryOperationResult {
private final boolean success;
private final ItemStack[] inventory;
public InventoryOperationResult(boolean success, ItemStack[] inventory) {
this.success = success;
this.inventory = inventory;
}
public boolean isSuccess() {
return success;
}
public ItemStack[] getInventory() {
return inventory;
}
}

View File

@ -0,0 +1,128 @@
package me.rockyhawk.commandpanels.commandtags.paywalls.itempaywall;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.PaywallEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.*;
public class ItemPaywall implements Listener {
CommandPanels plugin;
public ItemPaywall(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(PaywallEvent e){
if(e.name.equalsIgnoreCase("item-paywall=")){
//if player uses item-paywall= [Material] [Amount] <IGNORENBT> WILL NOT TAKE CUSTOM ITEMS. IGNORENBT lets nbt items through. Useful for spawner edge cases.
//player can use item-paywall= [custom-item] [Amount]
try {
boolean ignoreNBT = false;
for (String val : e.args) {
//This is here for when people want to take nbt items like spawners with types in a check for spawners.
if (val.equals("IGNORENBT")) {
ignoreNBT = true;
break;
}
}
//create the item to be removed
ItemStack sellItem;
if (Material.matchMaterial(e.args[0]) == null) {
//If custom item set to custom item data.
sellItem = plugin.itemCreate.makeCustomItemFromConfig(e.panel, PanelPosition.Top, e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
sellItem.setAmount(Integer.parseInt(e.args[1]));
} else {
//If normal just set material.
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(e.args[0])), Integer.parseInt(e.args[1]));
}
//try to remove the item and determine outcome
PaywallOutput removedItem = PaywallOutput.Blocked;
if(removeItem(e.p, sellItem, ignoreNBT, e.doDelete)){
removedItem = PaywallOutput.Passed;
}
//send message and return
if (removedItem == PaywallOutput.Blocked) {
if (plugin.config.getBoolean("purchase.item.enable")) {
//no item found to remove
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")));
}
} else {
if (plugin.config.getBoolean("purchase.item.enable") && e.doDelete) {
//item was removed
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[0]));
}
}
e.PAYWALL_OUTPUT = removedItem;
} catch (Exception buyc) {
plugin.debug(buyc, e.p);
plugin.tex.sendString(e.p, plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
e.PAYWALL_OUTPUT = PaywallOutput.Blocked;
}
}
}
public boolean removeItem(Player p, ItemStack itemToRemove, boolean ignoreNBT, boolean doDelete) {
InventoryOperationResult result;
if (plugin.inventorySaver.hasNormalInventory(p)) {
result = removeItemFromInventory(p.getInventory().getContents(), itemToRemove, ignoreNBT, doDelete);
p.getInventory().setContents(result.getInventory());
} else {
ItemStack[] savedInventory = plugin.inventorySaver.getNormalInventory(p);
result = removeItemFromInventory(savedInventory, itemToRemove, ignoreNBT, doDelete);
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(result.getInventory()));
}
return result.isSuccess(); // Return the success status of the inventory operation
}
private InventoryOperationResult removeItemFromInventory(ItemStack[] inventory, ItemStack itemToRemove, boolean ignoreNBT, boolean doDelete) {
int amountToRemove = itemToRemove.getAmount();
int count = 0;
for (ItemStack item : inventory) {
if (item != null && plugin.itemCreate.isIdentical(item, itemToRemove, !ignoreNBT)) {
count += item.getAmount();
}
}
//return false if the player doesn't have enough items
if (count < amountToRemove) {
return new InventoryOperationResult(false, inventory); // Not enough items, return with original inventory unchanged
}
//return true because there are enough items, but don't run the code to remove them
if(!doDelete){
return new InventoryOperationResult(true, inventory);
}
for (int i = 0; i < inventory.length; i++) {
ItemStack currentItem = inventory[i];
if (currentItem != null && plugin.itemCreate.isIdentical(currentItem, itemToRemove, !ignoreNBT)) {
int removeAmount = Math.min(currentItem.getAmount(), amountToRemove);
currentItem.setAmount(currentItem.getAmount() - removeAmount);
amountToRemove -= removeAmount;
if (currentItem.getAmount() == 0) {
inventory[i] = null;
}
if (amountToRemove == 0) {
break;
}
}
}
return new InventoryOperationResult(true, inventory); // Return true and the modified inventory
}
}

View File

@ -1,98 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.economy;
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.Arrays;
import java.util.Objects;
public class BuyCommandTags implements Listener {
CommandPanels plugin;
public BuyCommandTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("buycommand=")){
e.commandTagUsed();
//if player uses buycommand [price] [command]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(e.p) >= Double.parseDouble(e.args[0])) {
plugin.econ.withdrawPlayer(e.p, Double.parseDouble(e.args[0]));
//execute command under here
String price = e.args[0];
String command = String.join(" ",Arrays.copyOfRange(e.raw, 1, e.raw.length));
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
plugin.tex.sendMessage(e.p,plugin.config.getString("purchase.currency.success").replaceAll("%cp-args%", price));
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.currency.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
}
} catch (Exception buyc) {
plugin.debug(buyc,e.p);
plugin.tex.sendMessage(e.p,plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
return;
}
if(e.name.equalsIgnoreCase("tokenbuycommand=")){
e.commandTagUsed();
//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(e.p).orElse(0)));
if (balance >= Double.parseDouble(e.args[0])) {
api.removeTokens(e.p, Long.parseLong(e.args[0]));
//execute command under here
String price = e.args[0];
String command = String.join(" ",Arrays.copyOfRange(e.raw, 1, e.raw.length));
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", price));
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.tokens.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
}
} catch (Exception buyc) {
plugin.debug(buyc,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
if(e.name.equalsIgnoreCase("coinbuycommand=")){
e.commandTagUsed();
//if player uses coinbuycommand [price] [command]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
int balance = CoinsAPI.getCoins(e.p.getUniqueId().toString());
if (balance >= Double.parseDouble(e.args[0])) {
CoinsAPI.removeCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
//execute command under here
String price = e.args[0];
String command = String.join(" ",Arrays.copyOfRange(e.raw, 1, e.raw.length));
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", price));
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.coins.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
}
} catch (Exception buyc) {
plugin.debug(buyc,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
}
}

View File

@ -1,107 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.economy;
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class BuyItemTags implements Listener {
CommandPanels plugin;
public BuyItemTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("buy=")){
e.commandTagUsed();
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> <ID>
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(e.p) >= Double.parseDouble(e.args[0])) {
plugin.econ.withdrawPlayer(e.p, Double.parseDouble(e.args[0]));
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p, e.args);
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.currency.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
}
} catch (Exception buy) {
plugin.debug(buy,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
return;
}
if(e.name.equalsIgnoreCase("tokenbuy=")) {
e.commandTagUsed();
//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(e.p).orElse(0)));
if (balance >= Double.parseDouble(e.args[0])) {
api.removeTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p,e.args);
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.tokens.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires TokenManager to work!");
}
} catch (Exception buy) {
plugin.debug(buy, e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
if(e.name.equalsIgnoreCase("coinbuy=")) {
e.commandTagUsed();
//if player uses coinbuy= it will be eg. coinbuy= <price> <item> <amount of item> <ID>
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
int balance = CoinsAPI.getCoins(e.p.getUniqueId().toString());
if (balance >= Double.parseDouble(e.args[0])) {
CoinsAPI.removeCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p,e.args);
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.coins.failure"));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires CoinsAPINB to work!");
}
} catch (Exception buy) {
plugin.debug(buy, e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
}
@SuppressWarnings("deprecation")
private void giveItem(Player p, String[] args){
//legacy ID
byte id = 0;
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
for (String argsTemp : args) {
if (argsTemp.startsWith("id:")) {
id = Byte.parseByte(argsTemp.replace("id:", ""));
break;
}
}
}
plugin.inventorySaver.addItem(p,new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]),id));
}
}

View File

@ -1,154 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.economy;
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class SellItemTags implements Listener {
CommandPanels plugin;
public SellItemTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("sell=")){
e.commandTagUsed();
//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 = removeItem(e.p, e.args);
if (!sold) {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
} else {
plugin.econ.depositPlayer(e.p, Double.parseDouble(e.args[0]));
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", e.args[1]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires Vault and an Economy to work!");
}
} catch (Exception sell) {
plugin.debug(sell,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
return;
}
if(e.name.equalsIgnoreCase("tokensell=")) {
e.commandTagUsed();
//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 = removeItem(e.p, e.args);
if (!sold) {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
} else {
assert api != null;
api.addTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.success").replaceAll("%cp-args%", e.args[1]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires TokenManager to work!");
}
} catch (Exception sell) {
plugin.debug(sell,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
if(e.name.equalsIgnoreCase("coinsell=")) {
e.commandTagUsed();
//if player uses coinsell= it will be eg. coinsell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
boolean sold = removeItem(e.p, e.args);
if (!sold) {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
} else {
CoinsAPI.addCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.success").replaceAll("%cp-args%", e.args[1]));
}
} else {
plugin.tex.sendMessage(e.p, ChatColor.RED + "Selling Requires CoinsAPINB to work!");
}
} catch (Exception sell) {
plugin.debug(sell,e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
}
}
}
//returns false if player does not have item
private boolean removeItem(Player p, String[] args){
List<ItemStack> cont = new ArrayList<>(Arrays.asList(plugin.inventorySaver.getNormalInventory(p)));
for (int f = 0; f < 36; f++) {
ItemStack itm = cont.get(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(args[1]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : args){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//legacy ID
byte id = -1;
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
for (String argsTemp : args) {
if (argsTemp.startsWith("id:")) {
id = Byte.parseByte(argsTemp.replace("id:", ""));
break;
}
}
}
//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.tex.colour( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
return false;
}
}
if (id != -1) {
if (itm.getDurability() != id) {
continue;
}
}
}catch(Exception exc){
//skip if it cannot do unless plugin.debug is enabled
plugin.debug(exc,p);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])).getAmount();
itm.setAmount(amt);
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().setItem(f, amt > 0 ? itm : null);
p.updateInventory();
}else{
cont.set(f,amt > 0 ? itm : null);
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
return true;
}
}
}
return false;
}
}

View File

@ -16,47 +16,60 @@ public class DataTags implements Listener {
if(e.name.equalsIgnoreCase("set-data=")){
e.commandTagUsed();
if(e.args.length == 3){
plugin.panelData.setUserData(plugin.panelData.getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),true);
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[2])),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),true);
return;
}
//this will overwrite data. set-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),true);
plugin.panelData.setUserData(e.p.getUniqueId(),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),true);
return;
}
if(e.name.equalsIgnoreCase("add-data=")){
e.commandTagUsed();
if(e.args.length == 3){
plugin.panelData.setUserData(plugin.panelData.getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),false);
plugin.panelData.setUserData(plugin.panelDataPlayers.getOffline(plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[2])),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),false);
return;
}
//this will not overwrite existing data. add-data= [data point] [data value] [optional player]
plugin.panelData.setUserData(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),false);
plugin.panelData.setUserData(e.p.getUniqueId(),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]),false);
return;
}
if(e.name.equalsIgnoreCase("math-data=")){
e.commandTagUsed();
if(e.args.length == 3){
plugin.panelData.doDataMath(plugin.panelData.getOffline(e.args[2]),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]));
plugin.panelData.doDataMath(plugin.panelDataPlayers.getOffline(plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[2])),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]));
return;
}
//only works if data is number, goes math-data= [data point] [operator:number] [optional player] eg, math-data= -1 OR /3
plugin.panelData.doDataMath(e.p.getUniqueId(),e.args[0],plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]));
plugin.panelData.doDataMath(e.p.getUniqueId(),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1]));
return;
}
if(e.name.equalsIgnoreCase("clear-data=")){
e.commandTagUsed();
//will clear all data for player clear-data= [playerName]
plugin.panelData.clearData(e.p.getUniqueId());
plugin.panelData.clearData(plugin.panelDataPlayers.getOffline(plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0])));
return;
}
if(e.name.equalsIgnoreCase("del-data=")){
e.commandTagUsed();
if(e.args.length == 3){
plugin.panelData.delUserData(plugin.panelData.getOffline(e.args[1]),e.args[0]);
if(e.args.length == 2){
plugin.panelData.delUserData(plugin.panelDataPlayers.getOffline(plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[1])),
plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]));
return;
}
//this will remove data. del-data= [data point] [optional player]
plugin.panelData.delUserData(e.p.getUniqueId(),e.args[0]);
plugin.panelData.delUserData(e.p.getUniqueId(),plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]));
}
}
}

View File

@ -2,7 +2,6 @@ package me.rockyhawk.commandpanels.commandtags.tags.other;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -24,7 +23,7 @@ public class PlaceholderTags implements Listener {
return;
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
Character[] cm = convertToCharacterArray(cmd.toCharArray());
for(int i = 0; i < cm.length; i++){
if(cm[i].equals('[')){
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf(']'));
@ -48,7 +47,7 @@ public class PlaceholderTags implements Listener {
return;
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
Character[] cm = convertToCharacterArray(cmd.toCharArray());
for (int i = 0; i < cm.length; i++) {
if (cm[i].equals('[')) {
String contents = cmd.substring(i + 1, i + cmd.substring(i).indexOf(']'));
@ -65,4 +64,12 @@ public class PlaceholderTags implements Listener {
}
}
}
}
private Character[] convertToCharacterArray(char[] charArray) {
Character[] characterArray = new Character[charArray.length];
for (int i = 0; i < charArray.length; i++) {
characterArray[i] = charArray[i];
}
return characterArray;
}
}

View File

@ -4,9 +4,9 @@ import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -37,7 +37,7 @@ public class SpecialTags implements Listener {
return;
}
Character[] cm = ArrayUtils.toObject(cmd.toCharArray());
Character[] cm = convertToCharacterArray(cmd.toCharArray());
for(int i = 0; i < cm.length; i++){
if(cm[i].equals('[')){
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf(']'));
@ -66,7 +66,7 @@ public class SpecialTags implements Listener {
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Bottom);
}else if(position == PanelPosition.Top && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
//closing top closes all
e.p.closeInventory();
plugin.commandRunner.runCommand(e.panel,e.pos,e.p,"cpc");
}
return;
}
@ -99,32 +99,34 @@ public class SpecialTags implements Listener {
}
if(e.name.equalsIgnoreCase("teleport=")) {
e.commandTagUsed();
if (e.args.length == 5) {
float x, y, z, yaw, pitch; //pitch is the heads Y axis and yaw is the X axis
float x, y, z, yaw = 0, pitch = 0;
Player teleportedPlayer = e.p;
World teleportedWorld = e.p.getWorld();
try {
x = Float.parseFloat(e.args[0]);
y = Float.parseFloat(e.args[1]);
z = Float.parseFloat(e.args[2]);
yaw = Float.parseFloat(e.args[3]);
pitch = Float.parseFloat(e.args[4]);
e.p.teleport(new Location(e.p.getWorld(), x, y, z, yaw, pitch));
} else if (e.args.length <= 3) {
float x, y, z;
x = Float.parseFloat(e.args[0]);
y = Float.parseFloat(e.args[1]);
z = Float.parseFloat(e.args[2]);
e.p.teleport(new Location(e.p.getWorld(), x, y, z));
} else {
try {
Player otherplayer = Bukkit.getPlayer(e.args[3]);
float x, y, z;
x = Float.parseFloat(e.args[0]);
y = Float.parseFloat(e.args[1]);
z = Float.parseFloat(e.args[2]);
assert otherplayer != null;
otherplayer.teleport(new Location(otherplayer.getWorld(), x, y, z));
} catch (Exception tpe) {
plugin.tex.sendMessage(e.p,plugin.config.getString("config.format.notitem"));
for(String val : e.args) {
if(val.startsWith("world:")) {
teleportedWorld = Bukkit.getWorld(val.substring(6));
continue;
}
if(val.startsWith("yaw:")) {
yaw = Float.parseFloat(val.substring(4));
continue;
}
if(val.startsWith("pitch:")) {
pitch = Float.parseFloat(val.substring(6));
continue;
}
if(val.startsWith("player:")) {
teleportedPlayer = Bukkit.getPlayer(val.substring(7));
}
}
teleportedPlayer.teleport(new Location(teleportedWorld, x, y, z, yaw, pitch));
} catch (Exception tpe) {
plugin.debug(tpe,e.p);
}
return;
}
@ -137,7 +139,7 @@ public class SpecialTags implements Listener {
@Override
public void run() {
try {
plugin.commandTags.runCommand(e.panel,e.pos, e.p, finalCommand);
plugin.commandRunner.runCommand(e.panel,e.pos, e.p, finalCommand);
} catch (Exception ex) {
//if there are any errors, cancel so that it doesn't loop errors
plugin.debug(ex, e.p);
@ -148,4 +150,12 @@ public class SpecialTags implements Listener {
}.runTaskTimer(plugin, delayTicks, 1); //20 ticks == 1 second
}
}
private Character[] convertToCharacterArray(char[] charArray) {
Character[] characterArray = new Character[charArray.length];
for (int i = 0; i < charArray.length; i++) {
characterArray[i] = charArray[i];
}
return characterArray;
}
}

View File

@ -1,12 +1,14 @@
package me.rockyhawk.commandpanels.commandtags.tags.standard;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
import me.rockyhawk.commandpanels.classresources.SerializerUtils;
import me.rockyhawk.commandpanels.classresources.MiniMessageUtils;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
@ -23,10 +25,25 @@ public class BasicTags implements Listener {
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("cpc")){
if(e.name.equalsIgnoreCase("cpc") || e.name.equalsIgnoreCase("commandpanelclose")){
e.commandTagUsed();
//return if no panel open
if(!plugin.openPanels.hasPanelOpen(e.p.getName(),PanelPosition.Top)){
return;
}
//unclosable panels are at the Top only
if(plugin.openPanels.getOpenPanel(e.p.getName(),PanelPosition.Top).getConfig().contains("panelType")){
if(plugin.openPanels.getOpenPanel(e.p.getName(),PanelPosition.Top).getConfig().getStringList("panelType").contains("unclosable")){
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Top);
plugin.openPanels.skipPanelClose.add(e.p.getName());
}
}
//this will close the current inventory
e.p.closeInventory();
plugin.openPanels.skipPanelClose.remove(e.p.getName());
return;
}
if(e.name.equalsIgnoreCase("refresh")) {
@ -54,11 +71,38 @@ public class BasicTags implements Listener {
e.p.chat("/" + String.join(" ",e.args));
return;
}
if (e.name.equalsIgnoreCase("bungee=")) {
e.commandTagUsed();
ByteArrayDataOutput out = ByteStreams.newDataOutput();
try {
out.writeUTF(e.p.getName());
out.writeUTF(String.join(" ",e.args));
} catch(Exception ex) {
e.p.sendMessage(plugin.tag + ChatColor.translateAlternateColorCodes('&', "&cSomething wrong happened..."));
}
e.p.sendPluginMessage(plugin, "my:psb", out.toByteArray());
return;
}
if(e.name.equalsIgnoreCase("msg=")) {
e.commandTagUsed();
plugin.tex.sendString(e.panel,e.pos,e.p,String.join(" ",e.args));
return;
}
if(e.name.equalsIgnoreCase("broadcast=")) {
e.commandTagUsed();
Bukkit.broadcastMessage(plugin.tex.placeholders(e.panel, e.pos, e.p,String.join(" ",e.args).trim()));
return;
}
if(e.name.equalsIgnoreCase("broadcast-perm=")) {
e.commandTagUsed();
StringBuilder message = new StringBuilder();
for(int i = 1; i < e.args.length; i++){
message.append(e.args[i]).append(" ");
}
// <perm> <message>
Bukkit.broadcast(plugin.tex.placeholders(e.panel, e.pos, e.p,String.join(" ",message).trim()),String.valueOf(e.args[0]));
return;
}
if(e.name.equalsIgnoreCase("op=")) {
e.commandTagUsed();
//if player uses op= it will perform command as op
@ -101,24 +145,20 @@ public class BasicTags implements Listener {
}
if(e.name.equalsIgnoreCase("event=")) {
e.commandTagUsed();
PanelCommandEvent commandEvent = new PanelCommandEvent(e.p, e.args[0], e.panel);
PanelCommandEvent commandEvent = new PanelCommandEvent(e.p, String.join(" ",e.args), e.panel);
Bukkit.getPluginManager().callEvent(commandEvent);
return;
}
if(e.name.equalsIgnoreCase("minimessage=")){
e.commandTagUsed();
String tag = plugin.config.getString("config.format.tag") + " ";
if(Bukkit.getServer().getVersion().contains("Paper")){
LegacyVersion legacy = new LegacyVersion(plugin);
if(legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)){
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
Component parsedText = SerializerUtils.serializeText(String.join(" ",e.args));
player.sendMessage(parsedText);
}else{
plugin.tex.sendString(e.p, tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
}
}else{
plugin.tex.sendString(e.p, tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
//do mini message if conditions are met
if (plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)) {
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
Component parsedText = plugin.miniMessage.doMiniMessage(String.join(" ", e.args));
player.sendMessage(parsedText);
} else {
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
}
}
}
}
}

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class BungeeTags implements Listener {
public class BungeeTags implements Listener {
CommandPanels plugin;
public BungeeTags(CommandPanels pl) {
this.plugin = pl;
@ -17,15 +17,28 @@ public class BungeeTags implements Listener {
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("server=")){
if(e.name.equalsIgnoreCase("force-server=")){
e.commandTagUsed();
//this contacts bungee and tells it to send the server change command
//this contacts bungee and tells it to send the server change command without checking permissions
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(e.args[0]);
Player player = Bukkit.getPlayerExact(e.p.getName());
assert player != null;
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
} else if(e.name.equalsIgnoreCase("server=")){
e.commandTagUsed();
Player player = Bukkit.getPlayerExact(e.p.getName());
assert player != null;
if (player.hasPermission("bungeecord.command.server." + e.args[0].toLowerCase())) {
//this contacts bungee and tells it to send the server change command whilst checking for permissions
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(e.args[0]);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
}else{
player.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
}
}
}

View File

@ -3,9 +3,14 @@ package me.rockyhawk.commandpanels.commandtags.tags.standard;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Set;
public class ItemTags implements Listener {
CommandPanels plugin;
@ -18,6 +23,13 @@ public class ItemTags implements Listener {
if(e.name.equalsIgnoreCase("give-item=")){
e.commandTagUsed();
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
if(e.args.length == 2){
try{
itm.setAmount(Integer.parseInt(e.args[1]));
} catch (Exception err){
plugin.debug(err,e.p);
}
}
plugin.inventorySaver.addItem(e.p,itm);
return;
}
@ -25,7 +37,7 @@ public class ItemTags implements Listener {
e.commandTagUsed();
//if player uses setitem= [custom item] [slot] [position] it will change the item slot to something, used for placeable items
//make a section in the panel called "custom-item" then whatever the title of the item is, put that here
ItemStack s = plugin.itemCreate.makeItemFromConfig(null, e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(null, e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
PanelPosition position = PanelPosition.valueOf(e.args[2]);
if(position == PanelPosition.Top) {
e.p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(e.args[1]), s);
@ -34,6 +46,80 @@ public class ItemTags implements Listener {
}else{
e.p.getInventory().setItem(Integer.parseInt(e.args[1]), s);
}
return;
}
if(e.name.equalsIgnoreCase("enchant=")){
e.commandTagUsed();
//if player uses enchant= [slot] [position] [ADD/REMOVE/CLEAR] [enchant] <level> it will add/remove/clear the enchants of the selected slot
PanelPosition position = PanelPosition.valueOf(e.args[1]);
ItemStack EditItem;
if(position == PanelPosition.Top) {
EditItem = e.p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(e.args[0]));
}else if(position == PanelPosition.Middle) {
EditItem = e.p.getInventory().getItem(Integer.parseInt(e.args[0])+9);
}else{
EditItem = e.p.getInventory().getItem(Integer.parseInt(e.args[0]));
}
assert EditItem != null;
if(e.args[2].equalsIgnoreCase("add")){
try{
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(e.args[3].toLowerCase()));
assert enchant != null;
EditItem.addEnchantment(enchant, Integer.parseInt(e.args[4]));
return;
} catch (Exception err){
plugin.debug(err,e.p);
}
}
if(e.args[2].equalsIgnoreCase("remove")){
try{
Enchantment enchant = Enchantment.getByKey(NamespacedKey.minecraft(e.args[3].toLowerCase()));
assert enchant != null;
EditItem.removeEnchantment(enchant);
return;
} catch (Exception err){
plugin.debug(err,e.p);
}
}
if(e.args[2].equalsIgnoreCase("clear")){
try{
Set<Enchantment> Enchants = EditItem.getEnchantments().keySet();
for(Enchantment enchant : Enchants){
EditItem.removeEnchantment(enchant);
}
} catch (Exception err){
plugin.debug(err,e.p);
}
}
return;
}
if(e.name.equalsIgnoreCase("setcustomdata=")){
e.commandTagUsed();
//if player uses setcustomdata= [slot] [position] [data] it will change the custom model data of the item
PanelPosition position = PanelPosition.valueOf(e.args[1]);
ItemStack editItem;
if(position == PanelPosition.Top) {
editItem = e.p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(e.args[0]));
}else if(position == PanelPosition.Middle) {
editItem = e.p.getInventory().getItem(Integer.parseInt(e.args[0])+9);
}else{
editItem = e.p.getInventory().getItem(Integer.parseInt(e.args[0]));
}
try{
ItemMeta itemMeta = editItem.getItemMeta();
itemMeta.setCustomModelData(Integer.valueOf(e.args[2]));
editItem.setItemMeta(itemMeta);
} catch (Exception err){
plugin.debug(err,e.p);
}
return;
}
}
}

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.completetabs;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@ -13,37 +14,63 @@ import java.util.List;
public class CpTabComplete implements TabCompleter {
CommandPanels plugin;
public CpTabComplete(CommandPanels pl) { this.plugin = pl; }
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
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
try {
if (!panel.getName().startsWith(args[0])) {
//this will narrow down the panels to what the user types
continue;
}
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if(panel.getConfig().contains("panelType")) {
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
//do not allow command with nocommand
continue;
if (sender instanceof Player && args.length >= 1)
if (label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")) {
Player p = ((Player) sender).getPlayer();
if (args.length == 1) {
ArrayList<String> apanels = new ArrayList<String>(); //all panels
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
try {
if (!panel.getName().startsWith(args[0])) {
//this will narrow down the panels to what the user types
continue;
}
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if (panel.getConfig().contains("panelType")) {
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
//do not allow command with nocommand
continue;
}
}
if (plugin.panelPerms.isPanelWorldEnabled(p, panel.getConfig())) {
apanels.add(panel.getName());
}
}
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
apanels.add(panel.getName());
}
} catch (Exception skip) {
//ignore panel
}
}catch(Exception skip){
//ignore panel
}
return apanels;
}
return apanels;
if (args.length == 2 || args.length == 3) {
List<String> aplayers = new ArrayList<>();
if ("all".startsWith(args[(args.length == 2 ? 1 : 2)].toLowerCase())) aplayers.add("all");
if (args.length == 2 && "item".startsWith(args[1].toLowerCase())) aplayers.add("item");
for (Player player : Bukkit.getOnlinePlayers()) {
String name = player.getName();
if (name.toLowerCase().startsWith(args[(args.length == 2 ? 1 : 2)])) {
//this will narrow down the panels to what the user types
aplayers.add(name);
}
}
return aplayers;
}
}
}
return null;
}
}

View File

@ -2,13 +2,12 @@ package me.rockyhawk.commandpanels.completetabs;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class DataTabComplete implements TabCompleter {
@ -18,25 +17,50 @@ public class DataTabComplete implements TabCompleter {
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender.hasPermission("commandpanel.data")) {
ArrayList<String> output = new ArrayList<>();
if (args.length>=1 && args[0].equalsIgnoreCase("-s")) {
args = Arrays.copyOfRange(args, 1, args.length);
}
if(args.length == 1){
output.add("set");
output.add("add");
output.add("get");
output.add("remove");
output.add("clear");
String arg1 = args[0].toLowerCase();
if ("set".startsWith(arg1))output.add("set");
if ("add".startsWith(arg1))output.add("add");
if ("get".startsWith(arg1))output.add("get");
if ("remove".startsWith(arg1))output.add("remove");
if ("clear".startsWith(arg1))output.add("clear");
}else if(args.length == 2){
for (Player p : Bukkit.getOnlinePlayers()) {
if (!p.getName().startsWith(args[1])) {
continue;
if ("all".startsWith(args[1].toLowerCase()) && !args[0].equalsIgnoreCase("get")) output.add("all");
if ("online".startsWith(args[1].toLowerCase()) && !args[0].equalsIgnoreCase("get")) output.add("online");
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
String name = player.getName();
// don't worry about it saying it may throw a NPE
if (name.toLowerCase().startsWith(args[1].toLowerCase())) {
//this will narrow down the panels to what the user types
output.add(name);
}
output.add(p.getName());
}
}else if(args.length == 3){
if (!args[0].equalsIgnoreCase("remove")) return new ArrayList<>();
//the clear function is here as it is the only subcommand with 3 args
try {
return new ArrayList<>(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelData.getOffline(args[1])).getKeys(false));
if (!args[1].equalsIgnoreCase("all") && !args[1].equalsIgnoreCase("online"))
return new ArrayList<>(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelDataPlayers.getOffline(args[1])).getKeys(false));
else {
Set<String> set = new HashSet<>();
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
if (!player.isOnline()&&args[1].equalsIgnoreCase("online")) continue;
set.addAll(plugin.panelData.dataConfig.getConfigurationSection("playerData." + plugin.panelDataPlayers.getOffline(player.getName())).getKeys(false));
}
String[] finalArgs = args;
set.removeIf(s -> !s.toLowerCase().startsWith(finalArgs[2]));
return new ArrayList<>(set);
}
} catch (Exception ex) {
return null;
return new ArrayList<>();
}
}
return output;

View File

@ -0,0 +1,35 @@
package me.rockyhawk.commandpanels.completetabs;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.*;
public class UpdateTabComplete implements TabCompleter {
CommandPanels plugin;
public UpdateTabComplete(CommandPanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender.hasPermission("commandpanel.refresh")) {
ArrayList<String> output = new ArrayList<>();
if(args.length == 1){
for(Player player : Bukkit.getOnlinePlayers()){
output.add(player.getName());
}
}else if(args.length == 2){
output.add("ALL");
for(PanelPosition pp : PanelPosition.values()){
output.add(pp.toString());
}
}
return output;
}
return null;
}
}

View File

@ -1,14 +1,12 @@
package me.rockyhawk.commandpanels.datamanager;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.UUID;
import java.util.regex.Pattern;
public class PanelDataLoader {
CommandPanels plugin;
@ -26,14 +24,6 @@ public class PanelDataLoader {
if(!overwrite && dataConfig.isSet("playerData." + playerUUID + "." + dataPoint)){
return;
}
//check if string is numeric
Pattern pattern = Pattern.compile("-?\\d+(\\.\\d+)?");
if(pattern.matcher(dataValue).matches()){
doDataMath(playerUUID, dataPoint, dataValue);
return;
}
dataConfig.set("playerData." + playerUUID + "." + dataPoint, dataValue);
}
@ -105,10 +95,4 @@ public class PanelDataLoader {
dataConfig.set("playerData." + playerUUID + "." + dataPoint, output.toPlainString());
}
@SuppressWarnings("deprecation")
public UUID getOffline(String playerName){
//making this a separate function as it is long and deprecated
return Bukkit.getOfflinePlayer(playerName).getUniqueId();
}
}

View File

@ -0,0 +1,40 @@
package me.rockyhawk.commandpanels.datamanager;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashMap;
import java.util.UUID;
public class PanelDataPlayerManager implements Listener {
private CommandPanels plugin;
public PanelDataPlayerManager(CommandPanels pl) {
this.plugin = pl;
}
//will return UUID if found or null
public UUID getOffline(String playerName){
return knownPlayers.getOrDefault(playerName, null);
}
//Bukkit.getOfflinePlayer uses MojangAPI and can be very slow if a player has never joined the server before
//Will get all players who have ever joined the server before and use them
private HashMap<String, UUID> knownPlayers = new HashMap<>();
public void reloadAllPlayers(){
knownPlayers.clear();
for(OfflinePlayer p : Bukkit.getOfflinePlayers()){
knownPlayers.put(p.getName(), p.getUniqueId());
}
}
//Add players who have joined the server to known players
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
knownPlayers.put(e.getPlayer().getName(), e.getPlayer().getUniqueId());
}
}

View File

@ -0,0 +1,125 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import net.md_5.bungee.api.chat.*;
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 java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.CompletableFuture;
public class CommandPanelsEditor implements CommandExecutor {
CommandPanels plugin;
public CommandPanelsEditor(CommandPanels pl) {
this.plugin = pl;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.edit")) {
if (!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cannot execute command in Console!"));
return true;
}
//editor website link
if (args.length == 0) {
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Access the web editor at the link below"));
sender.sendMessage(plugin.tex.colour(ChatColor.YELLOW + "https://CommandPanels.net/editor"));
return true;
}
//export the requested panel
if (args.length == 1) {
for (Panel panel : plugin.panelList) {
if (panel.getFile().getName().equals(args[0])) {
String filePath = panel.getFile().getAbsolutePath(); //remove file name extensions
String fileContents = readFileAsString(filePath);
// Get the relative file path from the root panels folder
Path panelsFolderPath = plugin.panelsf.toPath();
Path panelFilePath = panel.getFile().toPath();
Path relativePanelPath = panelsFolderPath.relativize(panelFilePath);
String relativePath = relativePanelPath.toString();
// Prepend "fileName: {name}" and "filePath: {relativePath}" to the YAML content
String yamlWithFileNameAndPath = "fileName: " + (relativePath.replaceFirst("[.][^.]+$", "")) + "\n" + fileContents;
byte[] contentBytes = yamlWithFileNameAndPath.getBytes(StandardCharsets.UTF_8);
//65535 is maximum value that can be represented by an unsigned 16-bit binary number
if (contentBytes.length > 65535) {
// If the content is too large, notify the player to use a different method
sender.sendMessage(plugin.tag + ChatColor.RED +
"Content too long to paste in chat. Please copy and paste the panel file into the editor manually.");
} else {
// Safe to send
BaseComponent[] components = new ComponentBuilder(plugin.tag +
net.md_5.bungee.api.ChatColor.GREEN + "Click here to copy " +
net.md_5.bungee.api.ChatColor.WHITE + panel.getFile().getName() +
net.md_5.bungee.api.ChatColor.GREEN + " to the clipboard!")
.event(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yamlWithFileNameAndPath))
.create();
Player player = (Player) sender;
player.spigot().sendMessage(components);
}
return true;
}
}
// Pass the panel name to the YamlFileHandler
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not find panel!"));
return true;
}
//download the requested panel using an import
if (args.length == 3) {
downloadPanel(sender,args[1],args[0], args[2]).thenAccept((ignored) -> {
plugin.reloadPanelFiles();
plugin.hotbar.reloadHotbarSlots();
});
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: /cpe <parameters>"));
return true;
}
private CompletableFuture<Void> downloadPanel(CommandSender sender, String userID, String fileName, String token) {
CompletableFuture<Void> future = new CompletableFuture<>();
//get custom editor URL
String url = "https://firebasestorage.googleapis.com/v0/b/commandpanels-website.appspot.com/o/pastes%2F" + userID + "%2F" + fileName + "?alt=media&token=" + token;
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin.downloader.downloadPanel(sender, url, fileName);
future.complete(null);
});
return future;
}
private String readFileAsString(String filePath) {
try {
Path path = Paths.get(filePath);
byte[] bytes = Files.readAllBytes(path);
return new String(bytes, StandardCharsets.UTF_8);
} catch (IOException e) {
// Handle the exception if the file cannot be read
e.printStackTrace();
return "";
}
}
}

View File

@ -0,0 +1,29 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.ArrayList;
import java.util.List;
public class EditorTabComplete implements TabCompleter {
CommandPanels plugin;
public EditorTabComplete(CommandPanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender.hasPermission("commandpanel.edit")) {
ArrayList<String> output = new ArrayList<>();
if(args.length == 1){
for(Panel panel : plugin.panelList){
output.add(panel.getFile().getName());
}
}
return output;
}
return null;
}
}

View File

@ -0,0 +1,133 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.*;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.logging.Level;
public class PanelDownloader {
CommandPanels plugin;
public PanelDownloader(CommandPanels pl) {
this.plugin = pl;
}
public void downloadPanel(CommandSender sender, String url, String fileName) {
BufferedInputStream in = null;
FileOutputStream fout = null;
//add extension if not already added
if (!fileName.endsWith(".yml") && !fileName.endsWith(".yaml")) {
fileName = fileName + ".yml";
}
//Check if fileName contains file://
try {
if (URLDecoder.decode(url, StandardCharsets.UTF_8.toString()).contains("file://")) {
sender.sendMessage(plugin.tag + ChatColor.RED + "Invalid URL. Using file:// is not supported.");
return;
}
} catch (UnsupportedEncodingException e) {
sender.sendMessage(plugin.tag + ChatColor.RED + "UTF-8 support not found.");
return;
}
// Create the file object and get its canonical path
File file = new File(plugin.panelsf, fileName);
try {
String canonicalPath = file.getCanonicalPath();
if (!canonicalPath.startsWith(plugin.panelsf.getCanonicalPath())) {
sender.sendMessage(plugin.tag + ChatColor.RED + "Invalid file name or URL.");
return;
}
} catch (IOException e) {
sender.sendMessage(plugin.tag + ChatColor.RED + "Invalid file name or URL.");
return;
}
//download panel from page contents and add to plugin
try {
URL fileUrl = new URL(url);
in = new BufferedInputStream(fileUrl.openStream());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] data = new byte[1024];
int count;
while ((count = in.read(data, 0, 1024)) != -1) {
baos.write(data, 0, count);
}
String yamlData = baos.toString(StandardCharsets.UTF_8.name());
YamlConfiguration yamlConfig = new YamlConfiguration();
try {
yamlConfig.loadFromString(yamlData);
} catch (InvalidConfigurationException e) {
// Handle invalid YAML data
sender.sendMessage(plugin.tag + ChatColor.RED + "Downloaded data is not a valid YAML file.");
return;
}
// If parsing is successful, save the YAML data to the file
File outputFile = new File(plugin.panelsf, fileName);
try (FileOutputStream outputFileOut = new FileOutputStream(outputFile)) {
outputFileOut.write(yamlData.getBytes(StandardCharsets.UTF_8));
}
if (sender instanceof Player) {
YamlConfiguration panels = YamlConfiguration.loadConfiguration(file);
if (panels.getConfigurationSection("panels").getKeys(false).size()>1) {
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading panel "
+ ChatColor.YELLOW + "'" + fileName + "'");
} else {
BaseComponent[] components = new ComponentBuilder(plugin.tag +
net.md_5.bungee.api.ChatColor.GREEN + "Finished downloading " +
ChatColor.UNDERLINE + "'" + fileName + "'.\n" +
ChatColor.YELLOW + ChatColor.UNDERLINE + " Click Here to open the panel.")
.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/cp " +
panels.getConfigurationSection("panels").getKeys(false).toArray()[0]))
.create();
Player player =(Player) sender;
player.spigot().sendMessage(components);
}
} else {
sender.sendMessage(plugin.tag + ChatColor.GREEN + "Finished downloading panel " +
ChatColor.YELLOW+ "'" + fileName + "'");
}
} catch (Exception var22) {
sender.sendMessage(plugin.tag + ChatColor.RED + "Could not download panel.");
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException var21) {
this.plugin.getLogger().log(Level.SEVERE, null, var21);
}
try {
if (fout != null) {
fout.close();
}
} catch (IOException var20) {
this.plugin.getLogger().log(Level.SEVERE, null, var20);
}
}
}
}

View File

@ -0,0 +1,173 @@
package me.rockyhawk.commandpanels.floodgatecp;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.geysermc.cumulus.form.CustomForm;
import org.geysermc.cumulus.form.SimpleForm;
import org.geysermc.cumulus.response.CustomFormResponse;
import org.geysermc.cumulus.response.SimpleFormResponse;
import org.geysermc.cumulus.util.FormImage;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class OpenFloodgateGUI implements Listener {
private CommandPanels plugin;
public OpenFloodgateGUI(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void onPanelOpen(PanelOpenedEvent e) {
if (!FloodgateApi.getInstance().isFloodgatePlayer(e.getPlayer().getUniqueId()) ||
!e.getPanel().getConfig().contains("floodgate")) return;
FloodgatePlayer fgPlayer = FloodgateApi.getInstance().getPlayer(e.getPlayer().getUniqueId());
ConfigurationSection fgPanel = e.getPanel().getConfig().getConfigurationSection("floodgate");
if (fgPanel.contains("simple")) {
createAndSendSimpleForm(e, fgPlayer, fgPanel);
} else {
createAndSendCustomForm(e, fgPlayer, fgPanel);
}
e.setCancelled(true);
}
private void createAndSendSimpleForm(PanelOpenedEvent e, FloodgatePlayer fgPlayer, ConfigurationSection fgPanel) {
//replace for multi-line support in simpleform content title
SimpleForm.Builder form = SimpleForm.builder()
.title(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), e.getPanel().getConfig().getString("title"))))
.content(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fgPanel.getString("simple")).replaceAll("\\\\n", "\n")));
List<String> buttonCommands;
try {
buttonCommands = processButtons(fgPanel, form, e.getPanel(), e.getPlayer());
}catch (Exception err){
e.getPlayer().sendMessage(plugin.tag + ChatColor.RED + "FloodGate panel button config error");
plugin.debug(err, e.getPlayer());
return;
}
form.validResultHandler((SimpleFormResponse response) -> {
int clickedButtonId = response.clickedButtonId();
String configKey = buttonCommands.get(clickedButtonId);
String section = plugin.has.hasSection(e.getPanel(), PanelPosition.Top, fgPanel.getConfigurationSection(configKey), e.getPlayer());
ConfigurationSection buttonConfig = fgPanel.getConfigurationSection(configKey + section);
if(buttonConfig.contains("commands")) {
plugin.commandRunner.runCommands(e.getPanel(), PanelPosition.Top, e.getPlayer(), buttonConfig.getStringList("commands"), null);
}
});
fgPlayer.sendForm(form.build());
}
private List<String> processButtons(ConfigurationSection fgPanel, SimpleForm.Builder form, Panel panel, Player p) {
return fgPanel.getKeys(false).stream()
.filter(key -> key.matches("\\d+"))
.sorted(Comparator.comparingInt(Integer::parseInt)) // Ensure numeric sorting
.map(key -> {
String section = plugin.has.hasSection(panel, PanelPosition.Top, fgPanel.getConfigurationSection(key), p);
ConfigurationSection buttonConfig = fgPanel.getConfigurationSection(key + section);
if (buttonConfig == null) return null;
String buttonContent = plugin.tex.placeholders(panel, null, p, buttonConfig.getString("text").replaceAll("\\\\n", "\n"));
if (!buttonConfig.contains("icon")) {
form.button(buttonContent);
} else {
FormImage.Type type = FormImage.Type.valueOf(plugin.tex.placeholders(panel, null, p, buttonConfig.getString("icon.type")).toUpperCase());
String texture = plugin.tex.placeholders(panel, null, p, buttonConfig.getString("icon.texture"));
form.button(buttonContent, type, texture);
}
return key;
})
.filter(key -> key != null)
.collect(Collectors.toList());
}
private void createAndSendCustomForm(PanelOpenedEvent e, FloodgatePlayer fgPlayer, ConfigurationSection fgPanel) {
CustomForm.Builder form = CustomForm.builder()
.title(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), e.getPanel().getConfig().getString("title")));
List<String> commandsOrder = new ArrayList<>();
fgPanel.getKeys(false).forEach(key -> {
if (key.matches("\\d+")) {
String section = plugin.has.hasSection(e.getPanel(), e.getPosition(), fgPanel.getConfigurationSection(key), e.getPlayer());
ConfigurationSection fieldConfig = fgPanel.getConfigurationSection(key + section);
try {
String type = "toggle";
if(fieldConfig.contains("type")) {
type = fieldConfig.getString("type").toLowerCase();
}
switch (type) {
case "toggle":
form.toggle(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("text").replaceAll("\\\\n", "\n")),
Boolean.parseBoolean(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("default"))));
commandsOrder.add(key);
break;
case "slider":
form.slider(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("text").replaceAll("\\\\n", "\n")),
Long.parseLong(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("min"))),
Long.parseLong(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("max"))),
Long.parseLong(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("step"))),
Long.parseLong(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("default"))));
commandsOrder.add(key);
break;
case "input":
form.input(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("text").replaceAll("\\\\n", "\n")),
plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("placeholder")),
plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("default")));
commandsOrder.add(key);
break;
case "dropdown":
form.dropdown(plugin.tex.placeholders(e.getPanel(), null, e.getPlayer(), fieldConfig.getString("text").replaceAll("\\\\n", "\n")),
plugin.tex.placeholdersList(e.getPanel(), null, e.getPlayer(), fieldConfig.getStringList("options"), true));
commandsOrder.add(key);
break;
}
}catch (Exception err){
e.getPlayer().sendMessage(plugin.tag + ChatColor.RED + "FloodGate panel button config error");
plugin.debug(err, e.getPlayer());
}
}
});
form.validResultHandler((CustomFormResponse response) -> {
for (String configKey : commandsOrder) { // Iterate over each command configuration key
if (!response.hasNext()) {
break; // Safety check to prevent NoSuchElementException
}
String section = plugin.has.hasSection(e.getPanel(), e.getPosition(), fgPanel.getConfigurationSection(configKey), e.getPlayer());
ConfigurationSection fieldConfig = fgPanel.getConfigurationSection(configKey + section);
if(fieldConfig.contains("commands")) {
Object fieldValue = response.next(); // Retrieve the next response value
String value = String.valueOf(fieldValue); // Convert the field value to String
List<String> commands = fieldConfig.getStringList("commands"); // Retrieve commands for this field
List<String> processedCommands = new ArrayList<>();
for (String command : commands) {
processedCommands.add(command.replaceAll("%cp-input%", value)); // Replace the placeholder in each command
}
plugin.commandRunner.runCommands(e.getPanel(), PanelPosition.Top, e.getPlayer(), processedCommands, null); // Execute the processed commands
}
}
});
fgPlayer.sendForm(form.build());
}
}

View File

@ -32,6 +32,9 @@ public class GenUtils implements Listener {
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
Player p = (Player)e.getPlayer();
if(!p.hasPermission("commandpanel.generate")){
return;
}
if(!ChatColor.stripColor(e.getView().getTitle()).equals("Generate New Panel")){
return;
}
@ -56,7 +59,6 @@ public class GenUtils implements Listener {
}
}
@SuppressWarnings("deprecation")
void generatePanel(Player p, Inventory inv){
ArrayList<String> apanels = new ArrayList();
for(Panel panel : plugin.panelList){
@ -94,7 +96,7 @@ public class GenUtils implements Listener {
file.set("panels." + date + ".title", "&8Generated " + date);
file.addDefault("panels." + date + ".command", date);
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
file.set("panels." + date + ".empty", "STAINED_GLASS_PANE");
file.set("panels." + date + ".emptyID", "15");
}else{
@ -111,4 +113,4 @@ public class GenUtils implements Listener {
}
plugin.reloadPanelFiles();
}
}
}

View File

@ -1,56 +0,0 @@
package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
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;
import java.util.Objects;
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) {
if(!sender.hasPermission("commandpanel.edit")){
sender.sendMessage(plugin.tex.colour(plugin.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.tex.colour(plugin.tag + ChatColor.RED + "Editor disabled!"));
return true;
}
if(!(sender instanceof Player)) {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
return true;
}
Player p = (Player)sender;
//below is going to go through the files and find the right one
if (args.length == 1) { //check to make sure the person hasn't just left it empty
for(Panel panel : plugin.panelList){
if(panel.getName().equals(args[0])) {
//below will start the command, once it got the right file and panel
plugin.createGUI.openGui(panel.copy(), p, PanelPosition.Top, PanelOpenType.Editor,0);
return true;
}
}
}
if (args.length == 0) {
plugin.editorGuis.openEditorGui(p,0);
return true;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>"));
return true;
}
}

View File

@ -1,44 +0,0 @@
package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
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
try {
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if(!panel.getName().startsWith(args[0])){
//this will narrow down the panels to what the user types
continue;
}
if(sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
apanels.add(panel.getName());
}
}
//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,702 +0,0 @@
package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
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.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 cfile = null;
ConfigurationSection cf = null;
try {
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
if (panel.getName().equals(panelName)) {
cf = panel.getConfig();
cfile = YamlConfiguration.loadConfiguration(panel.getFile());
panelFile = panel.getFile();
panelTitle = plugin.tex.colour(cf.getString("title"));
break;
}
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
plugin.editorInputStrings.remove(temp);
return;
}
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
plugin.editorInputStrings.remove(temp);
plugin.reloadPanelFiles();
e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
return;
}
plugin.editorInputStrings.remove(temp);
if(section.startsWith("panel.")) {
panelSectionCheck(p, section, panelName, panelTitle, cf, cfile, panelFile, e);
}else if(section.startsWith("item:")){
itemSectionCheck(p, section, panelName, cf, cfile, panelFile, e);
}else if(section.startsWith("section.")){
itemSectionSectionCheck(p, section, panelName, cf, cfile, panelFile, e);
}
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 ConfigurationSection finalCF = cf;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.createGUI.openGui(new Panel(finalCF, panelName), p, PanelPosition.Top, PanelOpenType.Editor,0); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}else if(section.startsWith("section.")){
String itemSection = ChatColor.stripColor(section.replace("section." + section.split("\\.")[1] + ".", ""));
final ConfigurationSection finalCF = cf.getConfigurationSection("item." + itemSection);
if(section.contains("change")){
final String changeItemSection = itemSection.substring(0, itemSection.lastIndexOf("."));
final ConfigurationSection changeFinalCF = cf.getConfigurationSection("item." + changeItemSection);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.editorGuis.openItemSections(p,panelName,changeFinalCF,changeItemSection);
}
});
}else{
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.editorGuis.openItemSections(p,panelName,finalCF,itemSection);
}
});
}
}
return;
}
}
boolean savePanelFile(ConfigurationSection cf, YamlConfiguration cfile, String panelName, File panelFile){
try {
cfile.set("panels." + panelName, cf);
cfile.save(panelFile);
return true;
} catch (Exception io) {
plugin.debug(io,null);
return false;
}
}
void panelSectionCheck(Player p, String section, String panelName, String panelTitle, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
switch (section) {
case "panel.delete":
if (e.getMessage().contains("y")) {
if(Objects.requireNonNull(cfile.getConfigurationSection("panels")).getKeys(false).size() != 1){
//if the file has more than one panel in it
if(savePanelFile(null, cfile, panelName, panelFile)){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}else {
//if the file only has one panel in it
if (panelFile.delete()) {
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
}
}
}
break;
case "panel.perm":
if(e.getMessage().contains(" ")){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!"));
break;
}
cf.set("perm", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.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.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
return;
}
cf.set("rows", rows);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
} catch (Exception io) {
plugin.debug(io,p);
}
break;
case "panel.title":
if(panelTitle.equals(plugin.tex.colour(e.getMessage()))){
p.sendMessage(plugin.tex.colour(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
break;
}
cf.set("title", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
break;
case "panel.name":
if(e.getMessage().contains(" ")){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!"));
break;
}
if(panelName.equals(e.getMessage())){
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
break;
}
cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName));
//I have put null there instead of cf because that will replicate cp = null to delete it
savePanelFile(null, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
break;
case "panel.empty":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("empty", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.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.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
}
cf.set("empty", materialTemp);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
break;
case "panel.sound-on-open":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("sound-on-open", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sounds have been removed."));
break;
}
String tempSound;
try {
tempSound = Sound.valueOf(e.getMessage()).toString();
}catch(Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
return;
}
cf.set("sound-on-open", tempSound);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
break;
case "panel.panelType.add":
List<String> typeAdd = new ArrayList<>();
if(cf.contains("panelType")){
typeAdd = cf.getStringList("panelType");
}
typeAdd.add(e.getMessage().toLowerCase());
cf.set("panelType", typeAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase()));
break;
case "panel.panelType.remove":
List<String> typeRemove;
if(cf.contains("panelType")){
typeRemove = cf.getStringList("panelType");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No types found to remove!"));
break;
}
try {
typeRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find type!"));
break;
}
if(typeRemove.size() == 0){
cf.set("panelType", null);
}else{
cf.set("panelType", typeRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage()));
break;
case "panel.commands.add":
List<String> commandsAdd = new ArrayList<>();
if(cf.contains("commands")){
commandsAdd = cf.getStringList("commands");
}
commandsAdd.add(e.getMessage());
cf.set("commands", commandsAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.commands.remove":
List<String> commandsRemove;
if(cf.contains("commands")){
commandsRemove = cf.getStringList("commands");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsRemove.size() == 0){
cf.set("commands", null);
}else{
cf.set("commands", commandsRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "panel.commands-on-open.add":
List<String> commandsOnOpenAdd = new ArrayList<>();
if(cf.contains("commands-on-open")){
commandsOnOpenAdd = cf.getStringList("commands-on-open");
}
commandsOnOpenAdd.add(e.getMessage());
cf.set("commands-on-open", commandsOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.commands-on-open.remove":
List<String> commandsOnOpenRemove;
if(cf.contains("commands-on-open")){
commandsOnOpenRemove = cf.getStringList("commands-on-open");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandsOnOpenRemove.size() == 0){
cf.set("commands-on-open", null);
}else{
cf.set("commands-on-open", commandsOnOpenRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "panel.disabled-worlds.add":
List<String> disabledWorldsAdd = new ArrayList<>();
if(cf.contains("disabled-worlds")){
disabledWorldsAdd = cf.getStringList("disabled-worlds");
}
disabledWorldsAdd.add(e.getMessage());
cf.set("disabled-worlds", disabledWorldsAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage()));
break;
case "panel.disabled-worlds.remove":
List<String> disabledWorldsRemove;
if(cf.contains("disabled-worlds")){
disabledWorldsRemove = cf.getStringList("disabled-worlds");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No Worlds found to remove!"));
break;
}
try {
disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find World!"));
break;
}
if(disabledWorldsRemove.size() == 0){
cf.set("disabled-worlds", null);
}else{
cf.set("disabled-worlds", disabledWorldsRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage()));
break;
case "panel.hotbar.material":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("open-with-item", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed."));
//after an open-with-item has been altered, reload after changes
plugin.reloadPanelFiles();
break;
}
cf.set("open-with-item.material", e.getMessage());
if(!cf.contains("open-with-item.name")){
cf.set("open-with-item.name", panelName + " Item");
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.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("open-with-item.stationary", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved."));
break;
}
try {
int loc = Integer.parseInt(e.getMessage());
if (loc >= 36 || loc <= -1) {
//if the number isn't between the numbers
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 35!"));
return;
}
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
cf.set("open-with-item.stationary", loc);
savePanelFile(cf, cfile, panelName, panelFile);
} catch (Exception io) {
plugin.debug(io,p);
}
plugin.hotbar.reloadHotbarSlots();
break;
case "panel.hotbar.name":
cf.set("open-with-item.name",e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.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("open-with-item.lore")){
loreAdd = cf.getStringList("open-with-item.lore");
}
loreAdd.add(e.getMessage());
cf.set("open-with-item.lore", loreAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "panel.hotbar.lore.remove":
List<String> loreRemove;
if(cf.contains("open-with-item.lore")){
loreRemove = cf.getStringList("open-with-item.lore");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
break;
}
if(loreRemove.size() == 0){
cf.set("open-with-item.lore", null);
}else{
cf.set("open-with-item.lore", loreRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
case "panel.hotbar.commands.add":
List<String> commandAdd = new ArrayList<>();
if(cf.contains("open-with-item.commands")){
commandAdd = cf.getStringList("open-with-item.commands");
}
commandAdd.add(e.getMessage());
cf.set("open-with-item.commands", commandAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "panel.hotbar.commands.remove":
List<String> commandRemove;
if(cf.contains("open-with-item.commands")){
commandRemove = cf.getStringList("open-with-item.commands");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
break;
}
if(commandRemove.size() == 0){
cf.set("open-with-item.commands", null);
}else{
cf.set("open-with-item.commands", commandRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
}
}
void itemSectionCheck(Player p, String section, String panelName, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
/*
I am using : instead of . because the
item sections could contain 18.hasperm <- the periods
so using a different symbol will help to separate the section from
everything else
*/
String itemSlot = section.split(":")[1];
String sectionChange = section.replace("item:" + itemSlot + ":","");
switch (sectionChange) {
case "name":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".name", "");
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Name is now default."));
break;
}
cf.set("item." + itemSlot + ".name", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
break;
case "head":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".material", plugin.getHeads.playerHeadString());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Material is now default."));
break;
}
cf.set("item." + itemSlot + ".material", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
break;
case "stack":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".stack", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.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.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
return;
}
cf.set("item." + itemSlot + ".stack", rows);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
} catch (Exception io) {
plugin.debug(io,p);
}
break;
case "enchanted":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".enchanted", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Enchantments have been removed."));
break;
}
cf.set("item." + itemSlot + ".enchanted", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
break;
case "potion":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".potion", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Potion effects have been removed."));
break;
}
cf.set("item." + itemSlot + ".potion", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
break;
case "customdata":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".customdata", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed."));
break;
}
cf.set("item." + itemSlot + ".customdata", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
break;
case "leatherarmor":
if(e.getMessage().trim().equalsIgnoreCase("remove")){
cf.set("item." + itemSlot + ".leatherarmor", null);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed."));
break;
}
cf.set("item." + itemSlot + ".leatherarmor", e.getMessage());
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
break;
case "commands:add":
List<String> commandsOnOpenAdd = new ArrayList<>();
if(cf.contains("item." + itemSlot + ".commands")){
commandsOnOpenAdd = cf.getStringList("item." + itemSlot + ".commands");
}
commandsOnOpenAdd.add(e.getMessage());
cf.set("item." + itemSlot + ".commands", commandsOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
break;
case "commands:remove":
List<String> commandsOnOpenRemove;
if(cf.contains("item." + itemSlot + ".commands")){
commandsOnOpenRemove = cf.getStringList("item." + itemSlot + ".commands");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
break;
}
try {
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
plugin.debug(ex,p);
break;
}
if(commandsOnOpenRemove.size() == 0){
cf.set("item." + itemSlot + ".commands", null);
}else{
cf.set("item." + itemSlot + ".commands", commandsOnOpenRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
break;
case "lore:add":
List<String> loreOnOpenAdd = new ArrayList<>();
if(cf.contains("item." + itemSlot + ".lore")){
loreOnOpenAdd = cf.getStringList("item." + itemSlot + ".lore");
}
loreOnOpenAdd.add(e.getMessage());
cf.set("item." + itemSlot + ".lore", loreOnOpenAdd);
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
break;
case "lore:remove":
List<String> loreOnOpenRemove;
if(cf.contains("item." + itemSlot + ".lore")){
loreOnOpenRemove = cf.getStringList("item." + itemSlot + ".lore");
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
break;
}
try {
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
}catch (Exception ex){
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
plugin.debug(ex,p);
break;
}
if(loreOnOpenRemove.size() == 0){
cf.set("item." + itemSlot + ".lore", null);
}else{
cf.set("item." + itemSlot + ".lore", loreOnOpenRemove);
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
break;
case "duplicate:add":
if(cf.contains("item." + itemSlot + ".duplicate")){
cf.set("item." + itemSlot + ".duplicate", cf.getString("item." + itemSlot + ".duplicate") + "," + e.getMessage());
}else{
cf.set("item." + itemSlot + ".duplicate", e.getMessage());
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage()));
break;
case "duplicate:remove":
if(cf.contains("item." + itemSlot + ".duplicate")){
if(cf.getString("item." + itemSlot + ".duplicate").contains(",")) {
try {
String[] duplicateItems = cf.getString("item." + itemSlot + ".duplicate").split(",");
StringBuilder items = new StringBuilder();
for(int s = 0; s < duplicateItems.length; s++){
if(Integer.parseInt(e.getMessage()) != s+1) {
items.append(duplicateItems[s]);
items.append(",");
}
}
cf.set("item." + itemSlot + ".duplicate", items.toString());
} catch (Exception ex) {
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not delete or find item!"));
plugin.debug(ex,p);
break;
}
if(cf.getString("item." + itemSlot + ".duplicate").equals("")){
cf.set("item." + itemSlot + ".duplicate", null);
}
}else{
cf.set("item." + itemSlot + ".duplicate", null);
}
}else{
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No items found to remove!"));
break;
}
savePanelFile(cf, cfile, panelName, panelFile);
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage()));
break;
}
}
void itemSectionSectionCheck(Player p, String section, String panelName, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
String secondValue = section.split("\\.")[1];
//section includes slot at front eg, 1.hasvalue
String itemSection = ChatColor.stripColor(section.replace("section." + secondValue + ".", ""));
String playerMessage = ChatColor.stripColor(e.getMessage()).toLowerCase();
switch (secondValue) {
case "add":
cf.set("item." + itemSection + "." + playerMessage + ".output", "true");
if(playerMessage.equals("hasperm")) {
cf.set("item." + itemSection + "." + playerMessage + ".perm", "admin");
}else{
cf.set("item." + itemSection + "." + playerMessage + ".value", "10");
cf.set("item." + itemSection + "." + playerMessage + ".compare", "%cp-player-balance%");
}
cf.set("item." + itemSection + "." + playerMessage + ".material", "DIRT");
cf.set("item." + itemSection + "." + playerMessage + ".name", "");
savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles();
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage));
break;
case "remove":
cf.set("item." + itemSection + "." + playerMessage, null);
savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles();
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage));
break;
case "change":
cf.set("item." + itemSection + "." + playerMessage.split(":")[0], playerMessage.split(":")[1]);
savePanelFile(cf, cfile, panelName, panelFile);
plugin.reloadPanelFiles();
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1]));
break;
}
}
}

View File

@ -1,753 +0,0 @@
package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.Material;
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.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
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.tex.colour("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName(), PanelPosition.Top)){
return;
}
if(e.getClickedInventory() != e.getView().getTopInventory()){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
e.setCancelled(true);
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<ConfigurationSection> panelYaml = new ArrayList<ConfigurationSection>(); //all panels from ALL files (panel yaml files)
try {
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
panelNames.add(plugin.tex.colour(panel.getName()));
panelTitles.add(plugin.tex.colour( Objects.requireNonNull(panel.getConfig().getString("title"))));
panelYaml.add(panel.getConfig());
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
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.SLIME_BALL){
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.createGUI.openGui(new Panel(panelYaml.get(count), panelName), p,PanelPosition.Top,PanelOpenType.Editor,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(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
String panelName = ""; //all panels from ALL files (panel names)
File file = null; //all panels from ALL files (panel names)
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
boolean found = false;
try {
//neew to loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
panelName = panel.getName();
file = panel.getFile();
config = YamlConfiguration.loadConfiguration(panel.getFile());
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
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()) {
config.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(config.contains("panels." + panelName + ".item." + slot + ".stack")){
config.set("panels." + panelName + ".item." + slot + ".stack",null);
}
saveFile(file, config);
saveFile(file, config);
}
}catch(NullPointerException nu){
plugin.debug(nu,p);
}
}
}
@EventHandler
public void onInventoryEdit(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
String panelName = "";
File file = null;
YamlConfiguration config = new YamlConfiguration();
boolean found = false;
try {
//neew to loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
panelName = panel.getName();
file = panel.getFile();
config = YamlConfiguration.loadConfiguration(panel.getFile());
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
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.getInventory().getItem(e.getSlot()) == null) {
return;
}
onEditPanelClose(p,e.getInventory(),e.getView());
inventoryItemSettingsOpening.add(p.getName());
//refresh the yaml config
config = YamlConfiguration.loadConfiguration(file);
plugin.editorGuis.openItemSettings(p,panelName,config.getConfigurationSection("panels." + panelName + ".item." + e.getSlot()), String.valueOf(e.getSlot()));
p.updateInventory();
return;
}
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
if(!plugin.getHeads.ifSkullOrHead(Objects.requireNonNull(e.getCursor()).getType().toString())) {
//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.getSlot() == -999){
if(e.getCurrentItem() == null) {
clearTemp(p, panelName);
}
return;
}
if(e.getAction() == InventoryAction.CLONE_STACK){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.PLACE_ALL){
loadTempItem(e, p, config, file, panelName);
clearTemp(p, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
removeOldItem(e, p, config, 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, config, file, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){
e.setCancelled(true);
}else if(e.getAction() == InventoryAction.PICKUP_ALL){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
removeOldItem(e, p, config, file, panelName);
}else if(e.getAction() == InventoryAction.PICKUP_HALF){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.PICKUP_ONE){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.PICKUP_SOME){
saveTempItem(e, p, config, panelName);
saveFile(file,config);
}else if(e.getAction() == InventoryAction.PLACE_ONE){
loadTempItem(e, p, config, file, panelName);
saveFile(file,config);
}
}
@EventHandler
public void onPlayerClosePanel(InventoryCloseEvent e){
//this is put here to avoid conflicts, close panel if it is open
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName(),PanelPosition.Top)){
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
return;
}
//do editor settings if it is not a regular panel
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();
if(!p.getOpenInventory().getTitle().contains("Panel Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
e.setCancelled(true);
String panelName = ""; //all panels from ALL files (panel names)
boolean found = false;
boolean hotbarItems = false;
try {
//need to loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if(e.getView().getTitle().equals("Panel Settings: " + panel.getName())){
panelName = panel.getName();
if(panel.getConfig().contains("open-with-item")){
hotbarItems = true;
}
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
return;
}
if(!found){
return;
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Permission"));
p.closeInventory();
}
if(e.getSlot() == 3){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Title"));
p.closeInventory();
}
if(e.getSlot() == 5){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Sound ID"));
p.closeInventory();
}
if(e.getSlot() == 7){
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 21){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)"));
p.closeInventory();
}
if(e.getSlot() == 23){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 17){
//adds abilities to add and remove types
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Panel type"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)"));
}
p.closeInventory();
}
if(e.getSlot() == 25){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New World Name"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter World 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.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material"));
p.closeInventory();
}
if(e.getSlot() == 38 && hotbarItems){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (0 to 35)"));
p.closeInventory();
}
if(e.getSlot() == 44 && hotbarItems){
//adds abilities to add and remove lines
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
}
p.closeInventory();
}
}
@EventHandler
public void onItemSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Item Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
e.setCancelled(true);
String panelName = ""; //all panels from ALL files (panel names)
ConfigurationSection panelYaml = null; //all panels from ALL files (panel names)
boolean found = false;
try {
//loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if(e.getView().getTitle().equals("Item Settings: " + panel.getName())){
panelName = panel.getName();
panelYaml = panel.getConfig();
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
return;
}
if(!found){
return;
}
String itemSlot;
try {
itemSlot = ChatColor.stripColor(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,p);
return;
}
if(e.getSlot() == 1){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment"));
p.closeInventory();
}
if(e.getSlot() == 7){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
p.closeInventory();
}
if(e.getSlot() == 13){
//adds abilities to add and remove items
if(e.getClick().isLeftClick()) {
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)"));
}
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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
}else{
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "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.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour"));
p.closeInventory();
}
if(e.getSlot() == 31){
//section includes the slot number at the front
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + itemSlot), itemSlot);
p.updateInventory();
}
if(e.getSlot() == 35){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)"));
p.closeInventory();
}
if(e.getSlot() == 27){
if(itemSlot.contains(".")){
String newSection = itemSlot.substring(0, itemSlot.lastIndexOf("."));
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + newSection), newSection);
}else {
plugin.createGUI.openGui(new Panel(panelYaml, panelName), p,PanelPosition.Top, PanelOpenType.Editor, 0);
}
p.updateInventory();
}
}
//item section viewer click event
@EventHandler
public void onItemSection(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Item Sections:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
e.setCancelled(true);
String panelName = ""; //all panels from ALL files (panel names)
ConfigurationSection panelYaml = null;
ConfigurationSection itemConfSection; //all panels from ALL files (panel names)
boolean found = false;
try {
//loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if(e.getView().getTitle().equals("Item Sections: " + panel.getName())){
panelName = panel.getName();
panelYaml = panel.getConfig();
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
return;
}
if(!found){
return;
}
//this section includes slot at front
String section;
try {
section = ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(44)).getItemMeta()).getDisplayName().split("\\s")[2]);
}catch(Exception ex){
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
plugin.debug(ex,p);
return;
}
itemConfSection = panelYaml.getConfigurationSection("item." + section);
if(e.getSlot() <= 35){
if(e.getInventory().getItem(e.getSlot()) != null){
if(e.getClick().isLeftClick()) {
String newSection = section + "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
plugin.editorGuis.openItemSettings(p, panelName, itemConfSection.getConfigurationSection(ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName())), newSection);
p.updateInventory();
}else{
String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500"));
p.closeInventory();
}
}
}
if(e.getSlot() == 38){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0"));
p.closeInventory();
}
if(e.getSlot() == 42){
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section});
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0"));
p.closeInventory();
}
if(e.getSlot() == 36){
plugin.editorGuis.openItemSettings(p,panelName,itemConfSection, section);
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);
}
public void loadTempItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
//loads temp item to the current item
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
config.set("panels." + panelName + ".item." + e.getSlot(),tempEdit.get("panels." + panelName + ".temp." + p.getName()));
saveFile(file, config);
}
}
public void removeOldItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
//removes the old item from config, if it has been picked up (use this only after saving)
config.set("panels." + panelName + ".item." + e.getSlot(),null);
saveFile(file, config);
}
public void clearTemp(Player p, String panelName){
//empty temp item
tempEdit.set("panels." + panelName + ".temp." + p.getName(),null);
saveFile("temp.yml", tempEdit);
}
public void saveFile(String fileName, YamlConfiguration file){
try {
file.save(new File(plugin.getDataFolder() + File.separator + fileName));
} catch (IOException s) {
plugin.debug(s,null);
}
}
public void saveFile(File file, YamlConfiguration config){
try {
config.save(file);
} catch (IOException s) {
plugin.debug(s,null);
}
}
@SuppressWarnings("deprecation")
public void onEditPanelClose(Player p, Inventory inv, InventoryView invView) {
if(!p.getOpenInventory().getTitle().contains("Editing Panel:")){
return;
}
if(!p.hasPermission("commandpanel.edit")){
return;
}
String panelName = ""; //all panels from ALL files (panel names)
File file = null; //all panels from ALL files (panel names)
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
boolean found = false;
try {
//neew to loop through files to get file names
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
if (invView.getTitle().equals("Editing Panel: " + panel.getName())) {
panelName = panel.getName();
file = panel.getFile();
config = YamlConfiguration.loadConfiguration(panel.getFile());
found = true;
break;
}
}
}catch(Exception fail){
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
return;
}
if(!found){
return;
}
//save items as they appear
config = plugin.itemCreate.generatePanelFile(panelName,inv,config);
try {
config.save(file);
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Saved Changes!"));
} catch (IOException s) {
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could Not Save Changes!"));
plugin.debug(s,p);
}
plugin.reloadPanelFiles();
}
}

View File

@ -1,570 +0,0 @@
package me.rockyhawk.commandpanels.ingameeditor;
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.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
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<>(); //all panels from ALL files (panel names)
ArrayList<String> panelTitles = new ArrayList<>(); //all panels from ALL files (panel titles)
ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials)
try {
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
panelNames.add(plugin.tex.colour(panel.getName()));
panelTitles.add(plugin.tex.colour(panel.getConfig().getString("title")));
if (panel.getConfig().contains("open-with-item.material")) {
panelItems.add(panel.getHotbarItem(p));
} else {
panelItems.add(new ItemStack(Material.PAPER));
}
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail,p);
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.SLIME_BALL, 1);
plugin.setName(null,temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true, true);
i.setItem(49, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(null,temp, ChatColor.RED + "Exit Menu", null, p, true, 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(null,temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, 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(null,temp, ChatColor.WHITE + "Previous Page", null, p, true, true, true);
i.setItem(48, temp);
}
if (pageNumber < pagesAmount) {
//if page number is under pages amount
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(null,temp, ChatColor.WHITE + "Next Page", null, p, true, 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(null,temp, ChatColor.WHITE + panelName, lore, p, false, true, true);
i.setItem(slot, temp);
slot += 1;
}
count += 1;
}
p.openInventory(i);
}
@SuppressWarnings("deprecation")
public void openPanelSettings(Player p, String panelName, ConfigurationSection cf) {
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("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.IRON_INGOT, 1);
lore.add(ChatColor.GRAY + "Permission required to open panel");
lore.add(ChatColor.GRAY + "commandpanel.panel.[insert]");
if (cf.contains("perm")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("perm"));
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Permission", lore, p, true, 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("title")) {
lore.add(ChatColor.WHITE + "------------------");
lore.add(ChatColor.WHITE + cf.getString("title"));
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Title", lore, p, true, 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("sound-on-open")) {
lore.add(ChatColor.WHITE + "------------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase());
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Sound", lore, p, true, true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.IRON_DOOR, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Custom commands to open panel");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Command", lore, p, true, 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(null,temp, ChatColor.RED + "Delete Panel", lore, p, true, true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.LADDER, 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(null,temp, ChatColor.WHITE + "Panel Rows", lore, p, true, true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.STONE, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Worlds that cannot access the panel");
lore.add(ChatColor.GRAY + "- Left click to add world");
lore.add(ChatColor.GRAY + "- Right click to remove world");
if (cf.contains("disabled-worlds")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("disabled-worlds")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Disabled Worlds", lore, p, true, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.GLASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
if (cf.contains("empty")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("empty")).toUpperCase());
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Empty Item", lore, p, true, true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.ANVIL, 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("commands-on-open")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands-on-open")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Commands", lore, p, true, true, true);
i.setItem(15, temp);
temp = new ItemStack(Material.STRING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Special panel types");
lore.add(ChatColor.GRAY + "- Left click to add panel type");
lore.add(ChatColor.GRAY + "- Right click to remove panel type");
if (cf.contains("panelType")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panelType")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Types", lore, p, true, true, true);
i.setItem(17, 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(null,temp, ChatColor.WHITE + "Panel Name", lore, p, true, true, true);
i.setItem(11, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(18, temp);
//This will create a wall of glass panes, separating panel settings with hotbar settings
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
temp = new ItemStack(Material.matchMaterial("STAINED_GLASS_PANE"), 1,(short)15);
}else{
temp = new ItemStack(Material.matchMaterial("BLACK_STAINED_GLASS_PANE"), 1);
}
plugin.setName(null,temp, ChatColor.WHITE + "", null, p,false, true, 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("open-with-item.material")){
hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(null, PanelPosition.Top,cf.getConfigurationSection("open-with-item"), p, false, true, false);
}else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
}
lore.clear();
lore.add(ChatColor.GRAY + "Current Item");
if (cf.contains("open-with-item.material")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.material")).toUpperCase());
}else{
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.RED + "DISABLED");
}
plugin.setName(null,temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p, true, 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("open-with-item.name")) {
lore.add(ChatColor.WHITE + "----------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.name")));
}
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.FEATHER, 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("open-with-item.lore")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("open-with-item.lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Lore", lore, p, true, 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 0 to 35");
if (cf.contains("open-with-item.stationary")) {
lore.add(ChatColor.WHITE + "-------------------------");
int location = cf.getInt("open-with-item.stationary");
lore.add(ChatColor.WHITE + String.valueOf(location));
}
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands from Hotbar Item");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
lore.add(ChatColor.GRAY + "If commands are added, the item will");
lore.add(ChatColor.GRAY + "no longer automatically open the panel");
if (cf.contains("open-with-item.commands")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("open-with-item.commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true,true);
i.setItem(44, temp);
}
p.openInventory(i);
}
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
public void openItemSettings(Player p, String panelName, ConfigurationSection cf, String section) {
Inventory i = Bukkit.createInventory(null, 36, ChatColor.stripColor("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("name")) {
if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("name"));
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Name", lore, p, true, true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.ANVIL, 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("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Commands", lore, p, true, true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.ENCHANTED_BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
if (cf.contains("enchanted")) {
if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("enchanted"));
}
} else {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "false");
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Enchantment", lore, p, true, 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("potion")) {
if (!Objects.equals(cf.getString("potion"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("potion"));
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Potion Effect", lore, p, true, true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.PAPER, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Duplicate item visuals in other slots");
lore.add(ChatColor.GRAY + "- Left click to add duplicate item/s");
lore.add(ChatColor.GRAY + "- Right click to remove duplicate item/s");
if (cf.contains("duplicate")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getString("duplicate").split(",")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.FEATHER, 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("lore")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Lores", lore, p, true, 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("stack")) {
if (!Objects.equals(cf.getString("stack"), "")) {
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("stack"))));
} catch (Exception ignored) {
}
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("stack"));
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true, true);
i.setItem(21, temp);
if(!plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
temp = new ItemStack(Material.PAINTING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
if (cf.contains("customdata")) {
if (!Objects.equals(cf.getString("customdata"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("customdata"));
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true, true);
i.setItem(23, temp);
}
/*show the compass that opens the viewer for the sections..
it will only show the sections immidiatly under the other, so
if there is a hasperm inside another hasperm, it will not appear
until the other hasperm is opened.
*/
temp = new ItemStack(Material.COMPASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "View the items different");
lore.add(ChatColor.GRAY + "Sections and add complex values.");
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + section);
plugin.setName(null,temp, ChatColor.WHITE + "Item Sections", lore, p, true, true, true);
i.setItem(31, 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("leatherarmor")) {
if (!Objects.equals(cf.getString("leatherarmor"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("leatherarmor"));
}
}
plugin.setName(null,temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(27, temp);
temp = plugin.itemCreate.makeItemFromConfig(null,PanelPosition.Top,cf,p,false,false, false);
lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads");
plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true, true);
i.setItem(35, temp);
p.openInventory(i);
}
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
public void openItemSections(Player p, String panelName, ConfigurationSection cf, String itemSection) {
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Item Sections: " + panelName));
ItemStack temp;
int slot = 0;
for(String section : cf.getKeys(false)){
//get list of item sections
if(slot > 35){
break;
}
if(section.contains("hasperm") || section.contains("hasvalue") || section.contains("hasgreater")){
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Left click to open item");
lore.add(ChatColor.GRAY + "Right click to change below settings");
if(cf.contains(section + ".output")) {
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + cf.getString(section + ".output"));
}else{
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + "true");
}
if(cf.contains(section + ".perm")) {
lore.add(ChatColor.WHITE + "Perm: " + ChatColor.GRAY + cf.getString(section + ".perm"));
}
if(cf.contains(section + ".value")) {
lore.add(ChatColor.WHITE + "Value: " + ChatColor.GRAY + cf.getString(section + ".value"));
}
if(cf.contains(section + ".compare")) {
lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
}
temp = plugin.itemCreate.makeItemFromConfig(null,PanelPosition.Top,cf.getConfigurationSection(section),p,false,false, false);
plugin.setName(null,temp, ChatColor.AQUA + section, lore, p,false, true, true);
i.setItem(slot, temp);
slot++;
}
}
temp = new ItemStack(Material.REDSTONE, 1);
plugin.setName(null,temp, ChatColor.WHITE + "Remove Section", null, p, true, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.SLIME_BALL, 1);
plugin.setName(null,temp, ChatColor.WHITE + "Add Section", null, p, true, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(36, temp);
temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Section Types:");
lore.add(ChatColor.GRAY + "- hasperm");
lore.add(ChatColor.GRAY + "- hasvalue");
lore.add(ChatColor.GRAY + "- hasgreater");
plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true, true);
i.setItem(44, temp);
p.openInventory(i);
}
}

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