Compare commits

...

174 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
132 changed files with 3949 additions and 5321 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

@ -33,6 +33,7 @@ body:
- 1.17
- 1.18
- 1.19
- 1.20
validations:
required: true
- type: dropdown
@ -40,6 +41,21 @@ body:
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
@ -54,16 +70,6 @@ body:
- 3.17.4.1
- 3.17.4.0
- 3.17.3.1
- 3.17.3.0
- 3.17.2.2
- 3.17.2.1
- 3.17.2.0
- 3.17.1.5
- 3.17.1.4
- 3.17.1.3
- 3.17.1.2
- 3.17.1.1
- 3.17.1.0
- Any other version
validations:
required: true

View File

@ -1,6 +1,6 @@
name: Need help
description: Create an issue for a problem you are having.
labels: ["help wanted"]
labels: [ "help wanted" ]
body:
- type: checkboxes
id: searched
@ -31,13 +31,29 @@ body:
- 1.17
- 1.18
- 1.19
- 1.20
validations:
required: true
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
@ -52,19 +68,9 @@ body:
- 3.17.4.1
- 3.17.4.0
- 3.17.3.1
- 3.17.3.0
- 3.17.2.2
- 3.17.2.1
- 3.17.2.0
- 3.17.1.5
- 3.17.1.4
- 3.17.1.3
- 3.17.1.2
- 3.17.1.1
- 3.17.1.0
- Any other version
validations:
required: true
required: true
- type: dropdown
id: server_software
attributes:
@ -82,7 +88,7 @@ body:
- Velocity
- Travertine
validations:
required: true
required: true
- type: textarea
id: what-happened
attributes:

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="1.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,20 +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="CoinsAPI 1.8.9">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/CoinsAPI 1.8.9.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

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

View File

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

View File

@ -1,13 +0,0 @@
<component name="libraryTable">
<library name="Maven: org.jetbrains:annotations:23.0.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.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.19-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.19.2/bundler/libraries/spigot-api-1.19-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="temurin-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,36 +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" />
<sourceFolder url="file://$MODULE_DIR$/resource_editor" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/resource_example" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="jdk" jdkName="temurin-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" level="project" />
<orderEntry type="library" name="spigot-1.13.2" level="project" />
<orderEntry type="library" name="spigot" level="project" />
<orderEntry type="library" name="CoinsAPI 1.8.9" level="project" />
<orderEntry type="library" name="spigot-api-1.19-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-text-minimessage:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-api:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:adventure-key:4.11.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
<orderEntry type="library" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:23.0.0" 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,8 +15,8 @@ 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] '
perms: '&cNo permission.'
@ -30,6 +28,7 @@ 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!'
@ -38,7 +37,7 @@ input:
- '&aEnter Input for Command'
- '&cType &4%cp-args% &cto Cancel the command'
hexcodes:
start_tag: '#'
start_tag: '&#'
end_tag: ''
placeholders:
primary:
@ -49,7 +48,6 @@ placeholders:
end: '}'
updater:
auto-update: false
minor-updates-only: true
update-checks: true
purchase:
currency:
@ -76,3 +74,7 @@ purchase:
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.18.3.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
@ -73,6 +77,8 @@ permissions:
default: op
commandpanel.data:
default: op
commandpanel.refresh:
default: op
commandpanel.edit:
default: op
commandpanel.list:

View File

@ -1,39 +0,0 @@
panels:
BottomSettings:
perm: default
rows: 3
title: '&8Bottom Settings'
panelType:
- static
pre-load-commands:
- event= CommandPanels_EditorOpened
commands-on-close:
- event= CommandPanels_EditorClosed
item:
'0':
material: BARRIER
stack: 1
name: '&cExit'
commands:
- event= CommandPanels_EditorClosed
- cpc
'4':
material: CHEST
stack: 1
name: '&fPanel Settings'
commands:
- "event= CommandPanels_OpenPanelSettings"
'6':
material: COOKIE
stack: 1
name: '&fItem Settings'
commands:
- "event= CommandPanels_OpenItemSettings"
#'8':
# material: COMPASS
# stack: 1
# name: '&fItem Sections'
# lore:
# - "&cIN PROGRESS"
# commands:
# - "event= CommandPanels_OpenItemSections"

View File

@ -1,227 +0,0 @@
panels:
ItemEditMenu:
perm: default
rows: 3
title: '&8Item Settings'
panelType:
- static
custom-messages:
input-message:
- "&e[&bCommand Panels Editor&e]"
- "&fEnter your value in the chat bar below."
item:
'4':
material: FLINT_AND_STEEL
name: '&fPlayer Input'
lore:
- "&7Add a player input to your item."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorItem_player-input
- cpc
player-input:
- "event= CPEditor_iteminput %cp-player-input%"
'5':
material: NAME_TAG
name: '&fItem Name'
lore:
- "&7Choose a name for your item."
commands:
- event= CPEditorItem_name
- cpc
player-input:
- "event= CPEditor_itemname %cp-player-input%"
'6':
material: ITEM_FRAME
name: '&fItem Stack'
lore:
- "&7Choose a number from 1 to 64."
commands:
- event= CPEditorItem_stack
- cpc
player-input:
- "event= CPEditor_itemstack %cp-player-input%"
'7':
material: ENCHANTED_BOOK
name: '&fEnchantments'
lore:
- "&7Add enchantments to your item."
- ""
- "&7Options"
- "&7- add [type] [level]"
- "&7- edit [line number] [type] [level]"
- "&7- insert [line number] [type] [level]"
- "&7- remove [line number]"
- ""
- "&7For example: add KNOCKBACK 3"
commands:
- event= CPEditorItem_enchanted
- cpc
player-input:
- "event= CPEditor_itemenchantment %cp-player-input%"
'8':
material: PAPER
name: '&fItem NBT Data'
lore:
- "&7You can create custom NBT for your item."
- ""
- "&7Options"
- "&7- add [name] [value]"
- "&7- remove [name]"
- ""
- "&7For example: add example_data this is the value"
commands:
- cpc
player-input:
- "event= CPEditor_itemnbt %cp-player-input%"
'18':
material: LAVA_BUCKET
name: '&cDelete Item'
lore:
- "&7Enter 'confirm' to delete the item."
commands:
- cpc
player-input:
- "event= CPEditor_itemdelete %cp-player-input%"
'9':
material: REDSTONE_BLOCK
name: '&fEditing Item: %cp-item-slot%'
lore:
- "&7Click here to change the"
- "&7slot number you are editing."
commands:
- cpc
player-input:
- "event= CPEditor_itemslot %cp-player-input%"
'0':
material: ENDER_CHEST
name: '&fMove Item'
lore:
- "&7Enter a slot to move this item to."
commands:
- cpc
player-input:
- "event= CPEditor_itemmove %cp-player-input%"
'1':
material: STONE
name: '&fItem Material'
lore:
- "&7Choose a material for your item."
commands:
- event= CPEditorItem_material
- cpc
player-input:
- "event= CPEditor_itemmaterial %cp-player-input%"
'13':
material: COBBLESTONE
name: '&fItem ID'
lore:
- "&7Material ID for Minecraft 1.12 and below."
commands:
- event= CPEditorItem_id
- cpc
player-input:
- "event= CPEditor_itemid %cp-player-input%"
'14':
material: PAINTING
name: '&fCustom Model Data'
lore:
- "&7Enter Custom Model Data for your item."
commands:
- event= CPEditorItem_customdata
- cpc
player-input:
- "event= CPEditor_itemmodeldata %cp-player-input%"
'15':
material: ANVIL
name: '&fItem Durability'
lore:
- "&7Enter a number if you want the item to be damaged."
commands:
- event= CPEditorItem_damage
- cpc
player-input:
- "event= CPEditor_itemdurability %cp-player-input%"
'16':
material: LEATHER_HELMET
name: '&fArmour Colour'
lore:
- "&7Enter a value for your armour to be coloured."
commands:
- event= CPEditorItem_leatherarmor
- cpc
player-input:
- "event= CPEditor_itemarmour %cp-player-input%"
'17':
material: POTION
name: '&fPotion Effect'
lore:
- "&7Choose a potion effect to be applied."
commands:
- event= CPEditorItem_potion
- cpc
player-input:
- "event= CPEditor_itempotion %cp-player-input%"
'23':
material: FEATHER
name: '&fItem Lore'
lore:
- "&7Add a lore to your item."
- ""
- "&7Options"
- "&7- add [text]"
- "&7- edit [line number] [text]"
- "&7- insert [line number] [text]"
- "&7- remove [line number]"
commands:
- event= CPEditorItem_lore
- cpc
player-input:
- "event= CPEditor_itemlore %cp-player-input%"
'24':
material: MAGMA_CREAM
name: '&fItem Commands'
lore:
- "&7Add commands to your item."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorItem_commands
- cpc
player-input:
- "event= CPEditor_itemcommands %cp-player-input%"
'25':
material: MELON_SEEDS
name: '&fItem Duplicates'
lore:
- "&7Enter slots to duplicate this item to."
commands:
- event= CPEditorItem_duplicate
- cpc
player-input:
- "event= CPEditor_itemduplicate %cp-player-input%"
'26':
material: SLIME_BALL
name: '&fItem Types'
lore:
- "&7Add item types to your item."
- ""
- "&7Options"
- "&7- add [text]"
- "&7- edit [line number] [text]"
- "&7- insert [line number] [text]"
- "&7- remove [line number]"
commands:
- event= CPEditorItem_itemType
- cpc
player-input:
- "event= CPEditor_itemtypes %cp-player-input%"

View File

@ -1,271 +0,0 @@
panels:
PanelEditMenu:
perm: default
rows: 3
title: '&8Panel Settings'
panelType:
- static
custom-messages:
input-message:
- "&e[&bCommand Panels Editor&e]"
- "&fEnter your value in the chat bar below."
item:
'3':
material: PUMPKIN_SEEDS
name: '&fEmpty Slot Item ID'
lore:
- "&7Material ID for Minecraft 1.12 and below."
commands:
- event= CPEditorPanel_emptyID
- cpc
player-input:
- "event= CPEditor_panelemptyid %cp-player-input%"
'4':
material: MELON_SEEDS
name: '&fEmpty Slot Item'
lore:
- "&7This item will replace all"
- "&7of the empty slots."
commands:
- event= CPEditorPanel_empty
- cpc
player-input:
- "event= CPEditor_panelempty %cp-player-input%"
'5':
material: COBBLESTONE
name: '&fEnabled Worlds'
lore:
- "&7Add Enabled Worlds."
- "&7The panel will only open in them."
- ""
- "&7Options"
- "&7- add [world]"
- "&7- edit [line number] [world]"
- "&7- insert [line number] [world]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_enabled-worlds
- cpc
player-input:
- "event= CPEditor_panelenabledworlds %cp-player-input%"
'6':
material: REDSTONE_BLOCK
name: '&fDisabled Worlds'
lore:
- "&7Add Disabled Worlds."
- "&7The panel will not open in them."
- ""
- "&7Options"
- "&7- add [world]"
- "&7- edit [line number] [world]"
- "&7- insert [line number] [world]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_disabled-worlds
- cpc
player-input:
- "event= CPEditor_paneldisabledworlds %cp-player-input%"
'7':
material: BEACON
name: '&fPanel Permission'
lore:
- "&7Change the permission for your Panel."
- "&7Use 'default' to disable this feature."
- "&7The permission will be commandpanel.panel.[text]"
commands:
- event= CPEditorPanel_perm
- cpc
player-input:
- "event= CPEditor_panelpermission %cp-player-input%"
'8':
material: NOTE_BLOCK
name: '&fPanel Open Sound'
lore:
- "&7Choose a sound when your panel opens."
- "&7Make sure this is all uppercase."
commands:
- event= CPEditorPanel_sound-on-open
- cpc
player-input:
- "event= CPEditor_panelopensound %cp-player-input%"
'0':
material: LAVA_BUCKET
name: '&cDelete Panel'
lore:
- "&7Enter 'confirm' to delete the panel."
commands:
- cpc
player-input:
- "event= CPEditor_paneldelete %cp-player-input%"
'9':
material: NAME_TAG
name: '&fPanel Name: %cp-panel-name%'
lore:
- "&7Choose the name for your panel."
commands:
- cpc
player-input:
- "event= CPEditor_panelname %cp-player-input%"
'21':
material: FEATHER
name: '&fNo Permission Custom Message'
lore:
- "&7Add a No Permission custom message."
commands:
- event= CPEditorPanel_custom-messages.perm
- cpc
player-input:
- "event= CPEditor_panelpermissionmessage %cp-player-input%"
'12':
material: FEATHER
name: '&fMaximum Input Custom Message'
lore:
- "&7Add a Player Input Maximum custom message."
commands:
- event= CPEditorPanel_custom-messages.input
- cpc
player-input:
- "event= CPEditor_panelmaxinputmessage %cp-player-input%"
'13':
material: FEATHER
name: '&fPlayer Input Custom Message'
lore:
- "&7Add a Player Input custom message."
- ""
- "&7Options"
- "&7- add [text]"
- "&7- edit [line number] [text]"
- "&7- insert [line number] [text]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_custom-messages.player-input
- cpc
player-input:
- "event= CPEditor_panelplayerinputmessage %cp-player-input%"
'14':
material: BOOK
name: '&fPanel Title'
lore:
- "&7Change your panel title."
commands:
- event= CPEditorPanel_title
- cpc
player-input:
- "event= CPEditor_paneletitle %cp-player-input%"
'15':
material: LADDER
name: '&fPanel Rows'
lore:
- "&7How many rows the panel should be 1-6."
commands:
- event= CPEditorPanel_rows
- cpc
player-input:
- "event= CPEditor_panelrows %cp-player-input%"
'16':
material: LEVER
name: '&fPanel Refresh Delay'
lore:
- "&7Refresh delay measured in ticks."
commands:
- event= CPEditorPanel_refresh-delay
- cpc
player-input:
- "event= CPEditor_panelrefreshdelay %cp-player-input%"
'17':
material: SLIME_BALL
name: '&fPanel Types'
lore:
- "&7Add Panel Types."
- ""
- "&7Options"
- "&7- add [text]"
- "&7- edit [line number] [text]"
- "&7- insert [line number] [text]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_panelType
- cpc
player-input:
- "event= CPEditor_paneltype %cp-player-input%"
'22':
material: MAGMA_CREAM
name: '&fPanel Commands to Open Panel'
lore:
- "&7Commands that can be used to"
- "&7open this panel."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_commands
- cpc
player-input:
- "event= CPEditor_panelcommands %cp-player-input%"
'23':
material: MAGMA_CREAM
name: '&fCommands Before Panel Open'
lore:
- "&7Commands before the panel has opened."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_pre-load-commands
- cpc
player-input:
- "event= CPEditor_panelprecommands %cp-player-input%"
'24':
material: MAGMA_CREAM
name: '&fCommands On Panel Open'
lore:
- "&7Commands when the panel has opened."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_commands-on-open
- cpc
player-input:
- "event= CPEditor_panelopencommands %cp-player-input%"
'25':
material: MAGMA_CREAM
name: '&fCommands On Panel Close'
lore:
- "&7Commands when the panel is closing."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_commands-on-close
- cpc
player-input:
- "event= CPEditor_panelclosecommands %cp-player-input%"
'26':
material: MAGMA_CREAM
name: '&fOutside Panel Commands'
lore:
- "&7Add commands when clicking outside the panel."
- ""
- "&7Options"
- "&7- add [command]"
- "&7- edit [line number] [command]"
- "&7- insert [line number] [command]"
- "&7- remove [line number]"
commands:
- event= CPEditorPanel_outside-commands
- cpc
player-input:
- "event= CPEditor_paneloutsidecommands %cp-player-input%"

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,10 +1,12 @@
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;
@ -15,27 +17,28 @@ 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.editor.CPEventHandler;
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorCommand;
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorMain;
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorTabComplete;
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;
@ -46,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;
@ -66,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;
@ -77,25 +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 CommandPanelsEditorMain editorMain = new CommandPanelsEditorMain(this);
public PanelDownloader downloader = new PanelDownloader(this);
public CommandTags commandTags = new CommandTags(this);
public CommandRunner commandRunner = new CommandRunner(this);
public PanelDataLoader panelData = new PanelDataLoader(this);
public PanelDataPlayerManager panelDataPlayers = new PanelDataPlayerManager(this);
public Placeholders placeholders = new Placeholders(this);
public DebugManager debug = new DebugManager(this);
public CreateText tex = new CreateText(this);
public HexColours hex = new HexColours(this);
public MiniMessageUtils miniMessage = null;
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
public ItemCreation itemCreate = new ItemCreation(this);
public HasSections has = new HasSections(this);
public GetCustomHeads customHeads = new GetCustomHeads(this);
public Updater updater = new Updater(this);
public PlayerHeads getHeads = new PlayerHeads(this);
public ClassicPotionData classicPotion = new ClassicPotionData(this);
public LegacyPotionData legacyPotion = new LegacyPotionData(this);
public LegacyVersion legacy = new LegacyVersion(this);
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
@ -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,13 +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")){
this.getServer().getPluginManager().registerEvents(new CPEventHandler(this), this);
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new CommandPanelsEditorTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CommandPanelsEditorCommand(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));
@ -222,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);
@ -231,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 {
@ -255,24 +293,20 @@ 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
@ -315,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);
@ -372,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);
@ -453,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.");
@ -478,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>() {{
@ -505,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);
}
@ -86,34 +86,25 @@ public class Utils implements Listener {
//the panels proper position
panel = plugin.openPanels.getOpenPanel(p.getName(),position);
//this will cancel click on editor open and then change the slot clicked
if(plugin.editorMain.settings.containsKey(p.getUniqueId())) {
if (plugin.editorMain.settings.get(p.getUniqueId()).hasEditorOpen && position == PanelPosition.Top) {
plugin.editorMain.settings.get(p.getUniqueId()).slotSelected = String.valueOf(e.getSlot());
plugin.editorMain.openGuiPage(plugin.editorMain.settings.get(p.getUniqueId()).menuOpen, p, PanelPosition.Middle);
e.setCancelled(true);
return;
}
}
//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;
@ -125,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()));
@ -152,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;
@ -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

@ -82,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")));
}
@ -155,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,24 +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 {
@ -54,7 +51,7 @@ public class ItemCreation {
return null;
}
ItemStack s = null;
boolean hideAttributes = true;
boolean hideAttributes = false;
String mat;
String matraw;
String skullname;
@ -87,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;
}
}
@ -95,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];
@ -110,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);
@ -131,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;
}
@ -145,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)));
@ -195,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")){
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")) {
//is 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(EnchantmentWrapper.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")));
@ -285,12 +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.placeholders(panel,position,p,temp);
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){
@ -333,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 = plugin.tex.placeholdersNoColour(panel,position,p,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) {
@ -377,21 +378,39 @@ 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")) {
@ -402,7 +421,7 @@ public class ItemCreation {
//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.commandTags.runCommands(panel,position,p,itemSection.getStringList("refresh-commands"));
plugin.commandRunner.runCommands(panel,position,p,itemSection.getStringList("refresh-commands"), null);
}catch(Exception ex){
plugin.debug(ex,p);
}
@ -412,7 +431,7 @@ public class ItemCreation {
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;
}
@ -443,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());
}
@ -461,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 {
@ -482,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
}
@ -501,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())) {
@ -514,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())) {
@ -522,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;
}
@ -538,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
@ -561,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,11 +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){
return MiniMessage.miniMessage().deserialize(msg);
}
}

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,8 +93,15 @@ public class Placeholders {
case("online-players"): {
return Integer.toString(Bukkit.getServer().getOnlinePlayers().size());
}
case("online-players-true"): {
return Integer.toString(Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList()).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();
@ -134,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
}
}
@ -158,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";
@ -171,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 {
@ -210,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();
}
@ -244,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;
}
@ -289,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);
}
@ -298,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);
@ -315,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);
@ -326,23 +424,28 @@ public class Placeholders {
//checks for players online
if(identifier.startsWith("player-online-")) {
try {
if (identifier.endsWith("-true")){
String playerLocation = identifier.replace("player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList()).size()]);
if (Double.parseDouble(playerLocation) > playerFind.length) {
return plugin.tex.colour(Objects.requireNonNull(plugin.config.getString("config.format.offline")));
} else {
return playerFind[(int)(Double.parseDouble(playerLocation) - 1)].getName();
String playerLocation = identifier.replace("player-online-", "");
if (identifier.endsWith("-visible")){
//for players that are visible only
//remove -visible from the end of playerLocation
playerLocation = playerLocation.replace("-visible", "");
List<Player> playerList = new ArrayList<>();
for(Player temp : Bukkit.getOnlinePlayers()) {
if(!isPlayerVanished(temp)) {
playerList.add(temp);
}
}
if(playerList.size() >= Integer.parseInt(playerLocation)){
return playerList.get(Integer.parseInt(playerLocation)-1).getName();
}
} else {
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")));
} 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 "";
@ -358,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

@ -37,6 +37,9 @@ public class Commandpanelsreload implements CommandExecutor {
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);
@ -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,450 +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
//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]));
if(plugin.config.getBoolean("purchase.currency.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.currency.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.currency.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, plugin.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, plugin.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
if(plugin.config.getBoolean("purchase.tokens.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.tokens.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, plugin.tag + ChatColor.RED + "Needs TokenManager to work!");
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, plugin.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
if(plugin.config.getBoolean("purchase.coins.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.coins.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.coins.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, plugin.tag + ChatColor.RED + "Needs CoinAPI to work!");
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, plugin.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(Material.matchMaterial(command.split("\\s")[1]) == null) {
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(Material.matchMaterial(command.split("\\s")[1]) == null){
//item-paywall is a custom item as it is not a material
if(plugin.itemCreate.isIdentical(sellItem,cont.get(f))){
int sellItemAmount = sellItem.getAmount();
if(command.split("\\s").length == 3){
sellItemAmount = Integer.parseInt(command.split("\\s")[2]);
}
if (sellItemAmount <= cont.get(f).getAmount()) {
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItemAmount);
p.updateInventory();
} else {
cont.get(f).setAmount(cont.get(f).getAmount() - sellItemAmount);
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){
if(plugin.config.getBoolean("purchase.item.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
}else{
if(plugin.config.getBoolean("purchase.item.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
}
return removedItem;
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, plugin.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
if(plugin.config.getBoolean("purchase.xp.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.xp.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.xp.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, plugin.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
if(plugin.config.getBoolean("purchase.data.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.data.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Passed;
} else {
if(plugin.config.getBoolean("purchase.data.enable")){
plugin.tex.sendString(panel, PanelPosition.Top, p, Objects.requireNonNull(plugin.config.getString("purchase.data.failure")).replaceAll("%cp-args%", command.split("\\s")[1]));
}
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, plugin.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,76 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.economy;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
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.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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", price));
} else {
String price = e.args[0];
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.failure")).replaceAll("%cp-args%", price));
}
} 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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", price));
} else {
String price = e.args[0];
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.failure")).replaceAll("%cp-args%", price));
}
} 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,112 +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 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.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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p, e.args);
} else {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.currency.failure")).replaceAll("%cp-args%", e.args[0]));
}
} 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]));
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p,e.args);
} else {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.failure")).replaceAll("%cp-args%", e.args[0]));
}
} 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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", e.args[0]));
giveItem(e.p,e.args);
} else {
plugin.tex.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.failure")).replaceAll("%cp-args%", e.args[0]));
}
} 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,155 +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 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.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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")).replaceAll("%cp-args%", e.args[1]));
} else {
plugin.econ.depositPlayer(e.p, Double.parseDouble(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, 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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")).replaceAll("%cp-args%", e.args[1]));
} else {
assert api != null;
api.addTokens(e.p, Long.parseLong(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, 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 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.sendString(e.panel, PanelPosition.Top, e.p, Objects.requireNonNull(plugin.config.getString("purchase.item.failure")).replaceAll("%cp-args%", e.args[1]));
} else {
CoinsAPI.addCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
plugin.tex.sendString(e.panel, PanelPosition.Top, 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 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
plugin.commandTags.runCommand(e.panel,e.pos,e.p,"cpc");
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,8 +1,10 @@
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.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
@ -69,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
@ -122,11 +151,12 @@ public class BasicTags implements Listener {
}
if(e.name.equalsIgnoreCase("minimessage=")){
e.commandTagUsed();
if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18) && Bukkit.getServer().getVersion().contains("Paper")){
//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 = SerializerUtils.serializeText(String.join(" ",e.args));
Component parsedText = plugin.miniMessage.doMiniMessage(String.join(" ", e.args));
player.sendMessage(parsedText);
}else{
} 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;

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

@ -1,333 +0,0 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
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 java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CPEventHandler implements Listener {
CommandPanels plugin;
public CPEventHandler(CommandPanels pl) { this.plugin = pl; }
@EventHandler
public void onCommandEventOpen(PanelCommandEvent e){
if(!e.getMessage().startsWith("CommandPanels_")) {
return;
}
if (e.getMessage().equals("CommandPanels_OpenPanelSettings")) {
plugin.editorMain.openGuiPage("PanelEditMenu", e.getPlayer(), PanelPosition.Middle);
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).setMenuOpen("PanelEditMenu");
return;
}
if (e.getMessage().equals("CommandPanels_OpenItemSettings")) {
plugin.editorMain.openGuiPage("ItemEditMenu", e.getPlayer(), PanelPosition.Middle);
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).setMenuOpen("ItemEditMenu");
return;
}
if (e.getMessage().equals("CommandPanels_EditorOpened")) {
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).hasEditorOpen = true;
return;
}
if (e.getMessage().equals("CommandPanels_EditorClosed")) {
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).hasEditorOpen = false;
}
}
void savePanelFile(Panel p){
try {
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(p.getFile());
newConfig.set("panels." + p.getName(), p.getConfig());
newConfig.save(p.getFile());
} catch (Exception io) {
plugin.debug(io,null);
}
}
@EventHandler
public void onCommandEventView(PanelCommandEvent e){
if(!e.getMessage().startsWith("CPEditorItem_") && !e.getMessage().startsWith("CPEditorPanel_")){
return;
}
EditorSettings editor = plugin.editorMain.settings.get(e.getPlayer().getUniqueId());
Panel panel = null;
for(Panel pnl : plugin.panelList) {
if (pnl.getName().equals(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).panelName)) {
panel = pnl.copy();
break;
}
}
assert panel != null;
if(e.getMessage().startsWith("CPEditorItem_")){
String input = e.getMessage().replace("CPEditorItem_","");
viewContents(e.getPlayer(), panel, "item." + editor.slotSelected + "." + input);
}
if(e.getMessage().startsWith("CPEditorPanel_")){
String input = e.getMessage().replace("CPEditorPanel_","");
viewContents(e.getPlayer() , panel, input);
}
}
@EventHandler
public void onCommandEventSettings(PanelCommandEvent e){
if(!e.getMessage().startsWith("CPEditor_")) {
return;
}
String editType = e.getMessage().split("\\s")[0].replace("CPEditor_","");
String playerInput = e.getMessage().replace("CPEditor_" + editType + " ","");
EditorSettings editor = plugin.editorMain.settings.get(e.getPlayer().getUniqueId());
Panel panel = null;
for(Panel pnl : plugin.panelList) {
if (pnl.getName().equals(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).panelName)) {
panel = pnl.copy();
break;
}
}
assert panel != null;
if(editType.startsWith("item")) {
switch (editType) {
case "itemslot":
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).slotSelected = playerInput;
break;
case "itemmaterial":
panel.getConfig().set("item." + editor.slotSelected + ".material", playerInput);
break;
case "itemname":
panel.getConfig().set("item." + editor.slotSelected + ".name", playerInput);
break;
case "itemstack":
panel.getConfig().set("item." + editor.slotSelected + ".stack", playerInput);
break;
case "itemdelete":
if (playerInput.toLowerCase().startsWith("c")) {
panel.getConfig().set("item." + editor.slotSelected, null);
}
break;
case "itemmove":
ConfigurationSection oldLocation = panel.getConfig().getConfigurationSection("item." + editor.slotSelected);
if (panel.getConfig().isSet("item." + playerInput)) {
ConfigurationSection newLocation = panel.getConfig().getConfigurationSection("item." + playerInput);
panel.getConfig().set("item." + editor.slotSelected, newLocation);
}
panel.getConfig().set("item." + playerInput, oldLocation);
break;
case "itemmodeldata":
panel.getConfig().set("item." + editor.slotSelected + ".customdata", playerInput);
break;
case "itemdurability":
panel.getConfig().set("item." + editor.slotSelected + ".damage", playerInput);
break;
case "itemarmour":
panel.getConfig().set("item." + editor.slotSelected + ".leatherarmor", playerInput);
break;
case "itemduplicate":
panel.getConfig().set("item." + editor.slotSelected + ".duplicate", playerInput);
break;
case "itempotion":
panel.getConfig().set("item." + editor.slotSelected + ".potion", playerInput);
break;
case "itemid":
panel.getConfig().set("item." + editor.slotSelected + ".ID", playerInput);
break;
case "itemlore":
listChanger(playerInput, panel, "item." + editor.slotSelected + ".lore");
if (!panel.getConfig().isSet("item." + editor.slotSelected + ".name")) {
e.getPlayer().sendMessage(ChatColor.RED + "Your item needs to have a name for your lore to be visible!");
}
break;
case "itemcommands":
listChanger(playerInput, panel, "item." + editor.slotSelected + ".commands");
break;
case "iteminput":
listChanger(playerInput, panel, "item." + editor.slotSelected + ".player-input");
break;
case "itemtypes":
listChanger(playerInput, panel, "item." + editor.slotSelected + ".itemType");
break;
case "itemenchantment":
listChanger(playerInput, panel, "item." + editor.slotSelected + ".enchanted");
break;
case "itemnbt":
if (playerInput.startsWith("add")) {
String[] str = playerInput.split("\\s", 3);
panel.getConfig().set("item." + editor.slotSelected + ".nbt." + str[1], str[2]);
} else if (playerInput.startsWith("remove")) {
String element = playerInput.split("\\s")[1];
panel.getConfig().set("item." + editor.slotSelected + ".nbt." + element, null);
}
break;
}
}else{
switch (editType) {
case "panelpermission":
panel.getConfig().set("perm", playerInput);
break;
case "panelenabledworlds":
listChanger(playerInput, panel, "enabled-worlds");
break;
case "paneldisabledworlds":
listChanger(playerInput, panel, "disabled-worlds");
break;
case "panelopensound":
panel.getConfig().set("sound-on-open", playerInput);
break;
case "panelemptyid":
panel.getConfig().set("emptyID", playerInput);
break;
case "panelempty":
panel.getConfig().set("empty", playerInput);
break;
case "paneltitle":
panel.getConfig().set("title", playerInput);
break;
case "panelrows":
if(isNumeric(playerInput)){
panel.getConfig().set("rows", Integer.parseInt(playerInput));
}else {
panel.getConfig().set("rows", playerInput);
}
break;
case "panelrefreshdelay":
panel.getConfig().set("refresh-delay", playerInput);
break;
case "paneltype":
listChanger(playerInput, panel, "panelType");
break;
case "panelcommands":
listChanger(playerInput, panel, "commands");
break;
case "panelprecommands":
listChanger(playerInput, panel, "pre-load-commands");
break;
case "panelopencommands":
listChanger(playerInput, panel, "commands-on-open");
break;
case "panelclosecommands":
listChanger(playerInput, panel, "commands-on-close");
break;
case "paneloutsidecommands":
listChanger(playerInput, panel, "outside-commands");
break;
case "panelplayerinputmessage":
listChanger(playerInput, panel, "custom-messages.player-input");
break;
case "panelmaxinputmessage":
panel.getConfig().set("custom-messages.input", playerInput);
break;
case "panelpermissionmessage":
panel.getConfig().set("custom-messages.perm", playerInput);
break;
case "paneldelete":
if (!playerInput.toLowerCase().startsWith("c")) {
break;
}
try {
//clear panel from file contents
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(panel.getFile());
newConfig.set("panels." + panel.getName(), null);
e.getPlayer().sendMessage(ChatColor.GREEN + "Panel deleted!");
if(newConfig.getKeys(true).size() == 1){
//file is empty
if(panel.getFile().delete()){
plugin.reloadPanelFiles();
return;
}
}
newConfig.save(panel.getFile());
} catch (Exception io) {
plugin.debug(io,e.getPlayer());
}
plugin.reloadPanelFiles();
return;
case "panelname":
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(panel.getFile());
newConfig.set("panels." + playerInput.split("\\s")[0], panel.getConfig());
newConfig.set("panels." + panel.getName(), null);
try {
newConfig.save(panel.getFile());
} catch (Exception io) {
plugin.debug(io,e.getPlayer());
}
plugin.reloadPanelFiles();
e.getPlayer().sendMessage(ChatColor.GREEN + "Panel name changed!");
return;
}
}
savePanelFile(panel);
//This will open the editor back up
panel.open(e.getPlayer(),PanelPosition.Top);
plugin.editorMain.openGuiPage(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).menuOpen,e.getPlayer(),PanelPosition.Middle);
plugin.editorMain.openGuiPage("BottomSettings",e.getPlayer(),PanelPosition.Bottom);
}
/*
this will allow for add, edit and remove settings
add msg= test
edit 1 msg= changed
insert 1 msg= new line
remove 1
*/
public void listChanger(String playerInput, Panel panel, String location){
List<String> contents = panel.getConfig().getStringList(location);
if(playerInput.startsWith("add")){
String str = playerInput.split("\\s", 2)[1];
contents.add(str);
}else if(playerInput.startsWith("edit")){
List<String> str = new ArrayList<>(Arrays.asList(playerInput.split("\\s")));
str.subList(0,2).clear();
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
contents.set(element,String.join(" ",str));
}else if(playerInput.startsWith("insert")){
List<String> str = new ArrayList<>(Arrays.asList(playerInput.split("\\s")));
str.subList(0,2).clear();
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
contents.add(element,String.join(" ",str));
}else if(playerInput.startsWith("remove")){
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
contents.remove(element);
}
if(contents.isEmpty()){
panel.getConfig().set(location, null);
}else {
panel.getConfig().set(location, contents);
}
}
public void viewContents(Player player, Panel panel, String location){
if(panel.getConfig().isList(location)){
player.sendMessage("Current Value: ");
int n = 1;
for(String value : panel.getConfig().getStringList(location)){
player.sendMessage("(" + n + ") " + value);
n++;
}
}else{
player.sendMessage("Current Value: " + panel.getConfig().getString(location));
}
}
//if a string is a number
public boolean isNumeric(String str) {
try {
Double.parseDouble(str);
return true;
} catch(NumberFormatException e){
return false;
}
}
}

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

@ -1,51 +0,0 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
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;
public class CommandPanelsEditorCommand implements CommandExecutor {
CommandPanels plugin;
public CommandPanelsEditorCommand(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(!(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])) {
if(plugin.editorMain.settings.containsKey(p.getUniqueId())){
plugin.editorMain.settings.get(p.getUniqueId()).setLastPanel(panel.getName());
}else{
plugin.editorMain.settings.put(p.getUniqueId(), new EditorSettings("PanelEditMenu",panel.getName()));
}
//below will start the command, once it got the right file and panel
panel.copy().open(p,PanelPosition.Top);
plugin.editorMain.openGuiPage(plugin.editorMain.settings.get(p.getUniqueId()).menuOpen,p,PanelPosition.Middle);
plugin.editorMain.openGuiPage("BottomSettings",p,PanelPosition.Bottom);
return true;
}
}
}
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>"));
return true;
}
}

View File

@ -1,32 +0,0 @@
package me.rockyhawk.commandpanels.editor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class CommandPanelsEditorMain {
CommandPanels plugin;
public CommandPanelsEditorMain(CommandPanels pl) {
this.plugin = pl;
}
public Map<UUID, EditorSettings> settings = new HashMap<>();
public void openGuiPage(String fileName, Player p, PanelPosition position){
try {
Panel panel = new Panel(YamlConfiguration.loadConfiguration(plugin.getReaderFromStream(plugin.getResource(fileName + ".yml"))), fileName);
panel.placeholders.addPlaceholder("panel-name",settings.get(p.getUniqueId()).panelName);
panel.placeholders.addPlaceholder("item-slot",settings.get(p.getUniqueId()).slotSelected);
panel.open(p, position);
}catch(Exception ex){
ex.printStackTrace();
}
}
}

View File

@ -1,42 +0,0 @@
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 org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class CommandPanelsEditorTabComplete implements TabCompleter {
CommandPanels plugin;
public CommandPanelsEditorTabComplete(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();
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,21 +0,0 @@
package me.rockyhawk.commandpanels.editor;
public class EditorSettings {
public String panelName;
public String menuOpen;
public String slotSelected = "0";
public boolean hasEditorOpen = false;
public EditorSettings(String menu, String panel){
menuOpen = menu;
panelName = panel;
}
public void setMenuOpen(String menu){
menuOpen = menu;
}
public void setLastPanel(String panel){
panelName = panel;
}
}

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;
}
@ -93,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{
@ -110,4 +113,4 @@ public class GenUtils implements Listener {
}
plugin.reloadPanelFiles();
}
}
}

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