Compare commits

..

No commits in common. "latest" and "3.14.4.1" have entirely different histories.

152 changed files with 6236 additions and 8501 deletions

View File

@ -1,30 +0,0 @@
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:/

42
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

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

View File

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

View File

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

View File

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

32
.github/ISSUE_TEMPLATE/need-help.md vendored Normal file
View File

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

View File

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

5
.gitignore vendored
View File

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

View File

@ -1 +0,0 @@
CommandPanels

View File

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

View File

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

View File

@ -1,9 +0,0 @@
<?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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,9 @@
<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

@ -0,0 +1,9 @@
<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

@ -0,0 +1,9 @@
<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

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

View File

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

View File

@ -1,12 +1,6 @@
<?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 name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>

View File

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

76
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at rockyhawk99@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

21
Command Panels.iml Normal file
View File

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

View File

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

View File

@ -1,36 +1,43 @@
![TitleLogo](https://i.imgur.com/YQMXkoi.png)
![TitleLogo](https://www.spigotmc.org/attachments/cpbanner-theonly-png.553479/)
<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>
### 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.
<img align="center" src="https://i.imgur.com/w8UaAP2.png" alt="Screenshot">
- Lightweight
- PlaceholderAPI support
- Comes with a built in editor
- Unlimited GUIs
- Create complex panel systems
### Command Panels Server
This is the official Command Panels Server. Feel free to join in and be a part of the community! The server is survival 1.8-1.16.4. Test the plugin here too!
`play.CommandPanels.org`
## 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.
### Partnered Servers
These servers are running Command Panels. Feel free to join in and be a part of the community!
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**
- CrystalRPG | 1.16 play.crystalrpg.com
## 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.
- GrindMC | 1.15 play.grind-mc.com
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!
- ArcticForestMC | 1.16
arcticforestmc.net
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.
- TVHG Network | 1.16 play.tvhgmc.org
- Zuligen | 1.16 p.zuligen.com
## Main Features
### 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.
**Online Editor** Offers simple GUI creation, the layout and logic has been simplified for easier usage.
### 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.
**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.
### Bug Reports
Please report bugs, issues or request features [here](https://github.com/rockyhawk64/CommandPanels/issues)
### Spigot Page
You can find the spigot page for the plugin [here](https://www.spigotmc.org/resources/67788/).
You can find the spigot page for the plugin [here](https://www.spigotmc.org/resources/67788/)

View File

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

217
pom.xml
View File

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

View File

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

147
resource/example.yml Normal file
View File

@ -0,0 +1,147 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v2.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example:
perm: admin
rows: 4
title: '&6[&bExample Panel&6]&f Welcome!'
commands:
- "example"
sound-on-open: BLOCK_NOTE_BLOCK_CHIME
empty: BLACK_STAINED_GLASS_PANE
disabled-worlds:
- 'world_nether'
open-with-item:
material: CLOCK
name: '&6[&bExample Panel&6]'
lore:
- '&3Click me to open the panel!'
stationary: 4
item:
'0':
material: LEATHER_HELMET
name: '&d&lPURPLE'
leatherarmor: PURPLE
damage: 30
'1':
material: DIAMOND
name: '&fThis is a diamond'
lore: "&7Feel free to take me!"
itemType:
- placeable
'10':
material: RED_WOOL
name: '&fTake the diamond'
hasvalue:
value: DIAMOND
output: false
compare: '%cp-material-1%'
name: '&fNice One!'
material: GREEN_WOOL
'9':
material: LEATHER_CHESTPLATE
name: '&9&lBLUE'
leatherarmor: BLUE
damage: 20
'18':
material: LEATHER_LEGGINGS
name: '&a&lLIME'
leatherarmor: LIME
damage: 40
'2':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGJiMjczN2VjYmY5MTBlZmUzYjI2N2RiN2Q0YjMyN2YzNjBhYmM3MzJjNzdiZDBlNGVmZjFkNTEwY2RlZiJ9fX0=
name: '&e&lE'
'3':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWE2Nzg3YmEzMjU2NGU3YzJmM2EwY2U2NDQ5OGVjYmIyM2I4OTg0NWU1YTY2YjVjZWM3NzM2ZjcyOWVkMzcifX19
name: '&e&lX'
'4':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTY3ZDgxM2FlN2ZmZTViZTk1MWE0ZjQxZjJhYTYxOWE1ZTM4OTRlODVlYTVkNDk4NmY4NDk0OWM2M2Q3NjcyZSJ9fX0=
name: '&e&lA'
'5':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDljNDVhMjRhYWFiZjQ5ZTIxN2MxNTQ4MzIwNDg0OGE3MzU4MmFiYTdmYWUxMGVlMmM1N2JkYjc2NDgyZiJ9fX0=
name: '&e&lM'
'6':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTBhNzk4OWI1ZDZlNjIxYTEyMWVlZGFlNmY0NzZkMzUxOTNjOTdjMWE3Y2I4ZWNkNDM2MjJhNDg1ZGMyZTkxMiJ9fX0=
name: '&e&lP'
'7':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzE5ZjUwYjQzMmQ4NjhhZTM1OGUxNmY2MmVjMjZmMzU0MzdhZWI5NDkyYmNlMTM1NmM5YWE2YmIxOWEzODYifX19
name: '&e&lL'
'8':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGJiMjczN2VjYmY5MTBlZmUzYjI2N2RiN2Q0YjMyN2YzNjBhYmM3MzJjNzdiZDBlNGVmZjFkNTEwY2RlZiJ9fX0=
name: '&e&lE'
'13':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTBhNzk4OWI1ZDZlNjIxYTEyMWVlZGFlNmY0NzZkMzUxOTNjOTdjMWE3Y2I4ZWNkNDM2MjJhNDg1ZGMyZTkxMiJ9fX0=
name: '&e&lP'
'14':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTY3ZDgxM2FlN2ZmZTViZTk1MWE0ZjQxZjJhYTYxOWE1ZTM4OTRlODVlYTVkNDk4NmY4NDk0OWM2M2Q3NjcyZSJ9fX0=
name: '&e&lA'
'15':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzViOGIzZDhjNzdkZmI4ZmJkMjQ5NWM4NDJlYWM5NGZmZmE2ZjU5M2JmMTVhMjU3NGQ4NTRkZmYzOTI4In19fQ==
name: '&e&lN'
'16':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGJiMjczN2VjYmY5MTBlZmUzYjI2N2RiN2Q0YjMyN2YzNjBhYmM3MzJjNzdiZDBlNGVmZjFkNTEwY2RlZiJ9fX0=
name: '&e&lE'
'17':
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzE5ZjUwYjQzMmQ4NjhhZTM1OGUxNmY2MmVjMjZmMzU0MzdhZWI5NDkyYmNlMTM1NmM5YWE2YmIxOWEzODYifX19
name: '&e&lL'
'20':
material: RED_WOOL
name: '&cYour nickname is not ''RockyHawk'''
commands:
- 'msg= &cNot RockyHawk'
hasvalue:
output: true
value: RockyHawk
compare: '%cp-player-name%'
material: LIME_WOOL
name: '&aYour username is ''RockyHawk'''
commands:
- 'msg= &aWelcome my master!'
'27':
material: LEATHER_BOOTS
name: '&e&lYELLOW'
leatherarmor: YELLOW
damage: 50
'32':
material: COMPASS
stack: 12
enchanted: true
name: '&cClick Me'
lore:
- '&fI will teleport you home!'
commands:
- home
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"%cp-player-displayname%","color":"green"}
- console= title %cp-player-name% title {"text":"Welcome Home"}
'30':
material: POTION
name: '&5&lInstant Health II'
potion: INSTANT_HEAL
commands:
- heal
- cpc
'34':
material: REDSTONE_BLOCK
name: '&cNo Permission'
lore:
- '&4You cannot change to'
- '&4creative looking like that!'
hasperm:
perm: essentials.gamemode
output: true
material: EMERALD_BLOCK
name: '&aClick Me'
lore:
- '&2I will change you'
- '&2to creative mode!'
commands:
- gamemode creative
- cpc
- console= title %cp-player-name% times 20 60 20
- console= title %cp-player-name% subtitle {"text":"You are now in creative mode!","color":"green"}
- console= title %cp-player-name% title {"text":"Awesome %cp-player-displayname%"}

View File

@ -1,6 +1,6 @@
# |------------------------------------------------------------------------
# | CommandPanels Legacy Example File
# | Official Panel v2.4
# | By RockyHawk v2.2
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
@ -19,6 +19,7 @@ panels:
name: '&6[&bExample Panel&6]'
lore:
- '&3Click me to open the panel!'
stationary: 4
item:
'0':
material: LEATHER_HELMET
@ -34,9 +35,10 @@ panels:
'10':
material: REDSTONE_BLOCK
name: '&fTake the diamond'
has0:
value0: NOT DIAMOND
compare0: '%cp-material-1%'
hasvalue:
value: DIAMOND
output: false
compare: '%cp-material-1%'
name: '&fNice One!'
material: EMERALD_BLOCK
'9':
@ -91,9 +93,10 @@ panels:
name: '&cYour nickname is not ''RockyHawk'''
commands:
- 'msg= &cNot RockyHawk'
has0:
value0: RockyHawk
compare0: '%cp-player-name%'
hasvalue:
output: true
value: RockyHawk
compare: '%cp-player-name%'
material: WOOL
ID: 5
name: '&aYour username is ''RockyHawk'''
@ -107,8 +110,7 @@ panels:
'32':
material: COMPASS
stack: 12
enchanted:
- true
enchanted: true
name: '&cClick Me'
lore:
- '&fI will teleport you home!'
@ -131,9 +133,9 @@ panels:
lore:
- '&4You cannot change to'
- '&4creative looking like that!'
has0:
value0: '%cp-player-name% HASPERM'
compare0: essentials.gamemode
hasperm:
perm: essentials.gamemode
output: true
material: EMERALD_BLOCK
name: '&aClick Me'
lore:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,139 +1,96 @@
package me.rockyhawk.commandpanels;
import com.google.common.collect.ImmutableMultimap;
import io.lumine.mythic.lib.api.item.NBTItem;
import me.rockyhawk.commandpanels.api.CommandPanelsAPI;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.classresources.ExecuteOpenVoids;
import me.rockyhawk.commandpanels.classresources.MiniMessageUtils;
import me.rockyhawk.commandpanels.classresources.customheads.GetCustomHeads;
import me.rockyhawk.commandpanels.classresources.HasSections;
import me.rockyhawk.commandpanels.classresources.ItemCreation;
import me.rockyhawk.commandpanels.classresources.placeholders.expansion.CpPlaceholderExpansion;
import me.rockyhawk.commandpanels.completetabs.DataTabComplete;
import me.rockyhawk.commandpanels.completetabs.ImportTabComplete;
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
import me.rockyhawk.commandpanels.classresources.placeholders.Placeholders;
import java.io.*;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.bencodez.votingplugin.user.UserManager;
import me.clip.placeholderapi.PlaceholderAPI;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.classresources.*;
import me.rockyhawk.commandpanels.commands.*;
import me.rockyhawk.commandpanels.commandtags.CommandRunner;
import me.rockyhawk.commandpanels.completetabs.CpTabComplete;
import me.rockyhawk.commandpanels.completetabs.UpdateTabComplete;
import me.rockyhawk.commandpanels.customcommands.CommandPlaceholderLoader;
import me.rockyhawk.commandpanels.customcommands.Commandpanelcustom;
import me.rockyhawk.commandpanels.datamanager.DebugManager;
import me.rockyhawk.commandpanels.datamanager.PanelDataLoader;
import me.rockyhawk.commandpanels.datamanager.PanelDataPlayerManager;
import me.rockyhawk.commandpanels.editor.*;
import me.rockyhawk.commandpanels.floodgatecp.OpenFloodgateGUI;
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
import me.rockyhawk.commandpanels.interactives.OutsideClickEvent;
import me.rockyhawk.commandpanels.interactives.input.UserInputUtils;
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
import me.rockyhawk.commandpanels.interactives.OpenOnJoin;
import me.rockyhawk.commandpanels.ioclasses.nbt.NBTManager;
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.ioclasses.legacy.PlayerHeads;
import me.rockyhawk.commandpanels.ioclasses.potions.ClassicPotionData;
import me.rockyhawk.commandpanels.ioclasses.potions.LegacyPotionData;
import me.rockyhawk.commandpanels.openpanelsmanager.*;
import me.rockyhawk.commandpanels.ingameeditor.CpIngameEditCommand;
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
import me.rockyhawk.commandpanels.ingameeditor.EditorUserInput;
import me.rockyhawk.commandpanels.ingameeditor.EditorUtils;
import me.rockyhawk.commandpanels.ioclasses.Sequence_1_13;
import me.rockyhawk.commandpanels.ioclasses.Sequence_1_14;
import me.rockyhawk.commandpanels.legacy.LegacyVersion;
import me.rockyhawk.commandpanels.legacy.PlayerHeads;
import me.rockyhawk.commandpanels.openpanelsmanager.OpenGUI;
import me.rockyhawk.commandpanels.openpanelsmanager.OpenPanelsLoader;
import me.rockyhawk.commandpanels.openpanelsmanager.UtilsPanelsLoader;
import me.rockyhawk.commandpanels.openwithitem.HotbarItemLoader;
import me.rockyhawk.commandpanels.openwithitem.SwapItemEvent;
import me.rockyhawk.commandpanels.openwithitem.UtilsChestSortEvent;
import me.rockyhawk.commandpanels.openwithitem.UtilsOpenWithItem;
import me.rockyhawk.commandpanels.panelblocks.BlocksTabComplete;
import me.rockyhawk.commandpanels.panelblocks.Commandpanelblocks;
import me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick;
import me.rockyhawk.commandpanels.playerinventoryhandler.InventorySaver;
import me.rockyhawk.commandpanels.playerinventoryhandler.ItemStackSerializer;
import me.rockyhawk.commandpanels.playerinventoryhandler.pickupevent.EntityPickupEvent;
import me.rockyhawk.commandpanels.playerinventoryhandler.pickupevent.legacyPlayerEvent;
import me.rockyhawk.commandpanels.interactives.CommandpanelUserInput;
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
import me.rockyhawk.commandpanels.updater.Updater;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.CharSequenceReader;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SingleLineChart;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import net.mmogroup.mmolib.api.item.NBTItem;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.*;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.*;
public class CommandPanels extends JavaPlugin{
public class CommandPanels extends JavaPlugin {
public YamlConfiguration config;
public Economy econ = null;
public boolean debug = false;
public boolean openWithItem = false; //this will be true if there is a panel with open-with-item
//initialise the tag
public String tag = "[CommandPanels]";
public List<Player> generateMode = new ArrayList<>(); //players that are currently in generate mode
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
public List<String[]> userInputStrings = new ArrayList<>();
public List<String[]> editorInputStrings = new ArrayList<>();
public List<String> panelFiles = new ArrayList<>(); //names of all the files in the panels folder including extension
public List<String[]> panelNames = new ArrayList<>(); //this will return something like {"mainMenuPanel","4"} which means the 4 is for panelFiles.get(4). So you know which file it is for
//get alternate classes
public PanelDownloader downloader = new PanelDownloader(this);
public CommandRunner commandRunner = new CommandRunner(this);
public PanelDataLoader panelData = new PanelDataLoader(this);
public PanelDataPlayerManager panelDataPlayers = new PanelDataPlayerManager(this);
public Placeholders placeholders = new Placeholders(this);
public DebugManager debug = new DebugManager(this);
public CreateText tex = new CreateText(this);
public HexColours hex = new HexColours(this);
public MiniMessageUtils miniMessage = null;
public CommandTags commandTags = new CommandTags(this);
public OpenEditorGuis editorGuis = new OpenEditorGuis(this);
public ExecuteOpenVoids openVoids = new ExecuteOpenVoids(this);
public ItemCreation itemCreate = new ItemCreation(this);
public HasSections has = new HasSections(this);
public GetCustomHeads customHeads = new GetCustomHeads(this);
public Updater updater = new Updater(this);
public PlayerHeads getHeads = new PlayerHeads(this);
public ClassicPotionData classicPotion = new ClassicPotionData(this);
public LegacyPotionData legacyPotion = new LegacyPotionData(this);
public LegacyVersion legacy = new LegacyVersion(this);
public OpenPanelsLoader openPanels = new OpenPanelsLoader(this);
public OpenGUI createGUI = new OpenGUI(this);
public PanelPermissions panelPerms = new PanelPermissions(this);
public CommandPlaceholderLoader customCommand = new CommandPlaceholderLoader(this);
public HotbarItemLoader hotbar = new HotbarItemLoader(this);
public NBTManager nbt = new NBTManager(this);
public InventorySaver inventorySaver = new InventorySaver(this);
public ItemStackSerializer itemSerializer = new ItemStackSerializer(this);
public UserInputUtils inputUtils = new UserInputUtils(this);
public File panelsf = new File(this.getDataFolder() + File.separator + "panels");
public File panelsf;
public YamlConfiguration blockConfig; //where panel block locations are stored
public void onEnable() {
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loading...");
//Initialise classes that are not used externally
new OpenFloodgateGUI(this);
//register config files
this.panelsf = new File(this.getDataFolder() + File.separator + "panels");
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
panelData.dataConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "data.yml"));
inventorySaver.inventoryConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "inventories.yml"));
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
//save the config.yml file
@ -159,81 +116,23 @@ public class CommandPanels extends JavaPlugin{
}
}
//set version to latest version
if (Objects.requireNonNull(this.config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
updater.githubNewUpdate(true);
}
//setup class files
new Metrics(this, 5097);
this.setupEconomy();
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "my:psb");
new Metrics(this);
Objects.requireNonNull(this.getCommand("commandpanel")).setExecutor(new Commandpanel(this));
Objects.requireNonNull(this.getCommand("commandpanel")).setTabCompleter(new CpTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setTabCompleter(new TabCompleteGenerate(this));
Objects.requireNonNull(this.getCommand("commandpanelgenerate")).setExecutor(new Commandpanelsgenerate(this));
Objects.requireNonNull(this.getCommand("commandpaneldata")).setTabCompleter(new DataTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpaneldata")).setExecutor(new Commandpanelsdata(this));
Objects.requireNonNull(this.getCommand("commandpanelupdate")).setTabCompleter(new UpdateTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelupdate")).setExecutor(new Commandpanelsupdate(this));
Objects.requireNonNull(this.getCommand("commandpanelimport")).setExecutor(new CommandPanelImport(this));
Objects.requireNonNull(this.getCommand("commandpanelimport")).setTabCompleter(new ImportTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CommandPanelsEditor(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new EditorTabComplete(this));
Objects.requireNonNull(this.getCommand("commandpanelreload")).setExecutor(new Commandpanelsreload(this));
Objects.requireNonNull(this.getCommand("commandpaneldebug")).setExecutor(new Commandpanelsdebug(this));
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new Commandpanelversion(this));
Objects.requireNonNull(this.getCommand("commandpaneladdons")).setExecutor(new Commandpanelresources(this));
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new Commandpanelslist(this));
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
this.getServer().getPluginManager().registerEvents(inventorySaver, this);
if(this.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_12)){
this.getServer().getPluginManager().registerEvents(new EntityPickupEvent(this), this);
}else{
this.getServer().getPluginManager().registerEvents(new legacyPlayerEvent(this), this);
}
try {
// Check all the minimessage classes exist before loading
Class.forName("net.kyori.adventure.text.Component");
Class.forName("net.kyori.adventure.text.format.TextDecoration");
Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
Class.forName("net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer");
miniMessage = new MiniMessageUtils(this);
} catch (ClassNotFoundException ignore) {
//do not initialise miniMessage
}
this.getServer().getPluginManager().registerEvents(inputUtils, this);
this.getServer().getPluginManager().registerEvents(panelDataPlayers, this);
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
this.getServer().getPluginManager().registerEvents(new ItemFallManager(this), this);
this.getServer().getPluginManager().registerEvents(new OpenOnJoin(this), this);
this.getServer().getPluginManager().registerEvents(new OutsideClickEvent(this), this);
if (this.getServer().getPluginManager().isPluginEnabled("floodgate")) {
this.getServer().getPluginManager().registerEvents(new OpenFloodgateGUI(this), this);
}
//load in the updater if requested
if (Objects.requireNonNull(config.getString("updater.update-checks")).equalsIgnoreCase("true")) {
this.getServer().getPluginManager().registerEvents(updater, this);
}
//load in PlaceholderAPI Expansion
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new CpPlaceholderExpansion(this).register();
}
//load in all built in command tags
commandRunner.registerBuiltInTags();
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
//if refresh-panels set to false, don't load this
if(Objects.requireNonNull(config.getString("config.refresh-panels")).equalsIgnoreCase("true")){
@ -250,6 +149,14 @@ public class CommandPanels extends JavaPlugin{
this.getServer().getPluginManager().registerEvents(new UtilsOpenWithItem(this), this);
}
//if ingame-editor set to false, don't load this
if(Objects.requireNonNull(config.getString("config.ingame-editor")).equalsIgnoreCase("true")){
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new CpTabCompleteIngame(this));
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CpIngameEditCommand(this));
this.getServer().getPluginManager().registerEvents(new EditorUtils(this), this);
this.getServer().getPluginManager().registerEvents(new EditorUserInput(this), this);
}
//if panel-blocks set to false, don't load this
if(Objects.requireNonNull(config.getString("config.panel-blocks")).equalsIgnoreCase("true")){
Objects.requireNonNull(this.getCommand("commandpanelblock")).setExecutor(new Commandpanelblocks(this));
@ -261,139 +168,92 @@ 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);
}
//save the example_top.yml file and the template.yml file
if (!this.panelsf.exists()) {
//save the example.yml file
if (!this.panelsf.exists() || Objects.requireNonNull(this.panelsf.list()).length == 0) {
try {
if(legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
FileConfiguration exampleFileConfiguration;
if(legacy.isLegacy()){
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
}else {
//top
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_top.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_top.yml"));
//middle one
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_one.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_one.yml"));
//middle two
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_two.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_two.yml"));
//bottom
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_bottom.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_bottom.yml"));
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example.yml")));
}
FileConfiguration templateFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("template.yml")));
templateFileConfiguration.save(new File(this.panelsf + File.separator + "template.yml"));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the example file!");
}
}
if (Objects.requireNonNull(this.config.getString("config.update-notifications")).equalsIgnoreCase("true")) {
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, 5097);
metrics.addCustomChart(new SingleLineChart("panels_amount", () -> {
//this is the total panels loaded
return panelList.size();
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 panelNames.size();
}
}));
//get tag
tag = tex.colour(config.getString("config.format.tag"));
tag = papi(config.getString("config.format.tag") + " ");
Bukkit.getLogger().info("[CommandPanels] RockyHawk's CommandPanels v" + this.getDescription().getVersion() + " Plugin Loaded!");
}
public void onDisable() {
//close all the panels
for(String name : openPanels.openPanels.keySet()){
openPanels.closePanelForLoader(name, PanelPosition.Top);
try {
Bukkit.getPlayer(name).closeInventory();
}catch (Exception ignore){}
if (Objects.requireNonNull(this.config.getString("config.updater.auto-update")).equalsIgnoreCase("true")) {
updater.autoUpdatePlugin(this.getFile().getName());
}
//save files
panelData.saveDataFile();
inventorySaver.saveInventoryFile();
updater.autoUpdatePlugin(this.getFile().getName());
Bukkit.getLogger().info("RockyHawk's CommandPanels Plugin Disabled, aww man.");
}
public static CommandPanelsAPI getAPI(){
return new CommandPanelsAPI(JavaPlugin.getPlugin(CommandPanels.class));
}
public ItemStack setName(Panel panel, ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) {
public void setName(ItemStack renamed, String customName, List<String> lore, Player p, Boolean usePlaceholders, Boolean useColours, Boolean hideAttributes) {
try {
ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders
if(usePlaceholders){
customName = tex.placeholdersNoColour(panel,PanelPosition.Top,p,customName);
customName = papiNoColour(p,customName);
}
if(useColours){
customName = tex.colour(customName);
customName = papi(customName);
}
assert renamedMeta != null;
//hiding attributes will add an NBT tag
if(hideAttributes) {
renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
//HIDE_ADDITIONAL_TOOLTIP was added into 1.20.5 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_21) ||
(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && legacy.MINOR_VERSION >= 5)){
renamedMeta.addItemFlags(ItemFlag.valueOf("HIDE_ADDITIONAL_TOOLTIP"));
}
//HIDE_POTION_EFFECTS was removed in the 1.20.5 api
if(legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && legacy.MINOR_VERSION <= 4)){
renamedMeta.addItemFlags(ItemFlag.valueOf("HIDE_POTION_EFFECTS"));
}
//HIDE_ARMOR_TRIM was added into 1.20 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20)){
renamedMeta.addItemFlags(ItemFlag.HIDE_ARMOR_TRIM);
}
//HIDE_DYE was added into 1.17 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
}
//setAttributeModifiers was added into 1.14 api
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
renamedMeta.setAttributeModifiers(ImmutableMultimap.of());
}
}
if (customName != null) {
renamedMeta.setDisplayName(customName);
}
List<String> re_lore;
List<String> clore;
if (lore != null) {
if(usePlaceholders && useColours){
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, true);
clore = papi(p, lore, true);
}else if(usePlaceholders){
re_lore = tex.placeholdersNoColour(panel,PanelPosition.Top,p, lore);
clore = papiNoColour(p, lore);
}else if(useColours){
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, false);
clore = papi(p, lore, false);
}else{
re_lore = lore;
clore = lore;
}
renamedMeta.setLore(splitListWithEscape(re_lore));
renamedMeta.setLore(clore);
}
renamed.setItemMeta(renamedMeta);
} catch (Exception ignored) {}
return renamed;
} catch (Exception ignored) {
}
}
private void setupEconomy() {
@ -415,21 +275,305 @@ public class CommandPanels extends JavaPlugin{
}
}
//regular string papi
public String papi(Player p, String setpapi) {
try {
setpapi = setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//string papi with no colours
public String papiNoColour(Player p, String setpapi) {
try {
setpapi = setCpPlaceholders(p,setpapi);
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//regular string papi, but only colours so Player doesn't need to be there
public String papi(String setpapi) {
try {
setpapi = translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
return setpapi;
}
}
//papi except if it is a String List
public List<String> papi(Player p, List<String> setpapi, boolean placeholders) {
try {
if(placeholders) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
int tempInt = 0;
//change colour
for(String temp : setpapi){
try {
setpapi.set(tempInt, translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', temp)));
}catch(NullPointerException ignore){
}
tempInt += 1;
}
return setpapi;
}
//papi except if it is a String List
public List<String> papiNoColour(Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, setCpPlaceholders(p, temp));
tempInt += 1;
}
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = getServer().getOfflinePlayer(p.getUniqueId());
setpapi = PlaceholderAPI.setPlaceholders(offp, setpapi);
}
}catch(Exception ignore){
//this will be ignored as it is probably a null
return null;
}
return setpapi;
}
@SuppressWarnings("deprecation")
public String setCpPlaceholders(Player p, String str) {
//replace nodes with PlaceHolders
str = str.replaceAll("%cp-player-displayname%", p.getDisplayName());
str = str.replaceAll("%cp-player-name%", p.getName());
str = str.replaceAll("%cp-player-world%", p.getWorld().getName());
str = str.replaceAll("%cp-player-x%", String.valueOf(Math.round(p.getLocation().getX())));
str = str.replaceAll("%cp-player-y%", String.valueOf(Math.round(p.getLocation().getY())));
str = str.replaceAll("%cp-player-z%", String.valueOf(Math.round(p.getLocation().getZ())));
str = str.replaceAll("%cp-online-players%", Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
str = str.replaceAll("%cp-tag%", papi(tag));
//placeholder to check for server availability %cp-server-IP:PORT%
while (str.contains("%cp-server-")) {
int start = str.indexOf("%cp-server-");
int end = str.indexOf("%", str.indexOf("%cp-server-")+1);
String ip_port = str.substring(start, end).replace("%cp-server-", "").replace("%","");
Socket s = new Socket();
try {
s.connect(new InetSocketAddress(ip_port.split(":")[0], Integer.parseInt(ip_port.split(":")[1])), config.getInt("config.server-ping-timeout"));
str = str.replace(str.substring(start, end) + "%", "true");
s.close();
}catch (IOException ex){
str = str.replace(str.substring(start, end) + "%", "false");
}
}
//set custom placeholders to their values
for(String[] placeholder : customCommand.getCCP(p.getName())){
while (str.contains(placeholder[0])) {
int start = str.indexOf(placeholder[0]);
int end = start+placeholder[0].length()-1;
str = str.replace(str.substring(start, end) + "%", placeholder[1]);
}
}
//DO placeholders for detection of other items in a panel
//get material value from slot in current open inventory (panel)
while (str.contains("%cp-material-")) {
try {
int start = str.indexOf("%cp-material-");
int end = str.indexOf("%", str.indexOf("%cp-material-") + 1);
String matNumber = str.substring(start, end).replace("%cp-material-", "").replace("%", "");
String material;
try {
material = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().toString();
if(legacy.isLegacy()){
//add the ID to the end if it is legacy (eg, material:id)
material = material + ":" + p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getType().getId();
}
} catch (NullPointerException er) {
material = "AIR";
}
str = str.replace(str.substring(start, end) + "%", material);
}catch(Exception ex){
debug(ex);
break;
}
}
//get stack amount from slot in current open inventory (panel)
while (str.contains("%cp-stack-")) {
try {
int start = str.indexOf("%cp-stack-");
int end = str.indexOf("%", str.indexOf("%cp-stack-") + 1);
String matNumber = str.substring(start, end).replace("%cp-stack-", "").replace("%", "");
int amount;
try {
amount = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber)).getAmount();
} catch (NullPointerException er) {
amount = 0;
}
str = str.replace(str.substring(start, end) + "%", String.valueOf(amount));
}catch(Exception ex){
debug(ex);
break;
}
}
//is an item damaged
while (str.contains("%cp-damaged-")) {
try {
int start = str.indexOf("%cp-damaged-");
int end = str.indexOf("%", str.indexOf("%cp-damaged-") + 1);
String matNumber = str.substring(start, end).replace("%cp-damaged-", "").replace("%", "");
boolean damaged = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(Integer.parseInt(matNumber));
try {
if(legacy.isLegacy()){
if(itm.getType().getMaxDurability() != 0) {
damaged = (itm.getType().getMaxDurability() - itm.getDurability()) < itm.getType().getMaxDurability();
}
}else {
Damageable itemDamage = (Damageable) itm.getItemMeta();
damaged = itemDamage.hasDamage();
}
} catch (NullPointerException er) {
damaged = false;
}
str = str.replace(str.substring(start, end) + "%", String.valueOf(damaged));
}catch(Exception ex){
debug(ex);
break;
}
}
//is an item identical, uses custom-items (custom item, slot)
while (str.contains("%cp-identical-")) {
try {
int start = str.indexOf("%cp-identical-");
int end = str.indexOf("%", str.indexOf("%cp-identical-") + 1);
String matLocSlot = str.substring(start, end).replace("%cp-identical-", "").replace("%", "");
String matLoc = matLocSlot.split(",")[0];
int matSlot = Integer.parseInt(matLocSlot.split(",")[1]);
boolean isIdentical = false;
ItemStack itm = p.getOpenInventory().getTopInventory().getItem(matSlot);
try {
//if it is a regular custom item
ItemStack confItm = itemCreate.makeItemFromConfig(openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + matLoc),p,true,true, true);
if(itm.isSimilar(confItm) && itm.getAmount() == confItm.getAmount()){
isIdentical = true;
}
//if custom item is an mmo item (1.14+ for the API)
String customItemMaterial = openPanels.getOpenPanel(p.getName()).getString("custom-item." + matLoc + ".material");
if (getServer().getPluginManager().isPluginEnabled("MMOItems") && customItemMaterial.startsWith("mmo=")) {
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (isMMOItem(itm,mmoType,mmoID) && itm.getAmount() <= confItm.getAmount()) {
isIdentical = true;
}
}
} catch (NullPointerException er) {
isIdentical = false;
}
str = str.replace(str.substring(start, end) + "%", String.valueOf(isIdentical));
}catch(Exception ex){
debug(ex);
break;
}
}
//does %cp-random-MIN,MAX%
while (str.contains("%cp-random-")) {
int start = str.indexOf("%cp-random-");
int end = str.indexOf("%", str.indexOf("%cp-random-") + 1);
String min_max = str.substring(start, end).replace("%cp-random-", "").replace("%", "");
int min = Integer.parseInt(min_max.split(",")[0]);
int max = Integer.parseInt(min_max.split(",")[1]);
str = str.replace(str.substring(start, end) + "%", String.valueOf(getRandomNumberInRange(min, max)));
}
while (str.contains("%cp-player-online-")) {
int start = str.indexOf("%cp-player-online-");
int end = str.indexOf("-find%",str.indexOf("%cp-player-online-")+1);
String playerLocation = str.substring(start, end).replace("%cp-player-online-", "");
Player[] playerFind = Bukkit.getOnlinePlayers().toArray(new Player[Bukkit.getOnlinePlayers().size()]);
if (Integer.parseInt(playerLocation) > playerFind.length) {
str = str.replace(str.substring(start, end) + "-find%", papi(Objects.requireNonNull(config.getString("config.format.offline"))));
} else {
str = str.replace(str.substring(start, end) + "-find%", playerFind[Integer.parseInt(playerLocation) - 1].getName());
}
}
try {
if (econ != null) {
str = str.replaceAll("%cp-player-balance%", String.valueOf(Math.round(econ.getBalance(p))));
}
} catch (Exception place) {
//skip
}
if (this.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
str = str.replaceAll("%cp-tokenmanager-balance%", Long.toString(api.getTokens(p).orElse(0)));
}
if (this.getServer().getPluginManager().isPluginEnabled("VotingPlugin")) {
str = str.replaceAll("%cp-votingplugin-points%", String.valueOf(UserManager.getInstance().getVotingPluginUser(p).getPoints()));
}
if (str.contains("%cp-player-input%")) {
for (String[] key : userInputStrings) {
if (key[0].equals(p.getName())) {
userInputStrings.add(new String[]{p.getName(), str});
return "cpc";
}
}
userInputStrings.add(new String[]{p.getName(), str});
List<String> inputMessages = new ArrayList<String>(config.getStringList("config.input-message"));
for (String temp : inputMessages) {
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(config.getString("config.input-cancel")));
p.sendMessage(papi(p, temp));
}
str = "cpc";
}
//end nodes with PlaceHolders
return str;
}
//check for duplicate panel names
public boolean checkDuplicatePanel(CommandSender sender){
List<String> apanels = new ArrayList<>();
for(Panel panel : panelList){
apanels.add(panel.getName());
ArrayList<String> apanels = new ArrayList<>();
for(String[] panelName : panelNames){
apanels.add(panelName[0]);
}
//names is a list of the titles for the Panels
Set<String> oset = new HashSet<>(apanels);
Set<String> oset = new HashSet<String>(apanels);
if (oset.size() < apanels.size()) {
//there are duplicate panel names
ArrayList<String> opanelsTemp = new ArrayList<>();
ArrayList<String> opanelsTemp = new ArrayList<String>();
for(String tempName : apanels){
if(opanelsTemp.contains(tempName)){
sender.sendMessage(tex.colour(tag) + ChatColor.RED + "Error duplicate panel name: " + tempName);
sender.sendMessage(papi(tag) + ChatColor.RED + " Error duplicate panel name: " + tempName);
return false;
}
opanelsTemp.add(tempName);
@ -446,23 +590,18 @@ public class CommandPanels extends JavaPlugin{
fileNamesFromDirectory(new File(directory + File.separator + fileName));
continue;
}
try {
int ind = fileName.lastIndexOf(".");
if (!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")) {
continue;
}
}catch (Exception ex){
int ind = fileName.lastIndexOf(".");
if(!fileName.substring(ind).equalsIgnoreCase(".yml") && !fileName.substring(ind).equalsIgnoreCase(".yaml")){
continue;
}
//check before adding the file to commandpanels
if(!checkPanels(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)))){
this.getServer().getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Error in: " + fileName);
continue;
}
panelFiles.add((directory + File.separator + fileName).replace(panelsf.toString() + File.separator,""));
for (String tempName : Objects.requireNonNull(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).getConfigurationSection("panels")).getKeys(false)) {
panelList.add(new Panel(new File((directory + File.separator + fileName)),tempName));
panelNames.add(new String[]{tempName, Integer.toString(panelFiles.size()-1)});
if(YamlConfiguration.loadConfiguration(new File(directory + File.separator + fileName)).contains("panels." + tempName + ".open-with-item")) {
openWithItem = true;
}
@ -471,58 +610,45 @@ public class CommandPanels extends JavaPlugin{
}
public void reloadPanelFiles() {
panelList.clear();
panelFiles.clear();
panelNames.clear();
openWithItem = false;
//load panel files
fileNamesFromDirectory(panelsf);
}
public void debug(Exception e, Player p) {
if (p == null) {
if(debug.consoleDebug){
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below");
e.printStackTrace();
}
}else{
if(debug.isEnabled(p)){
p.sendMessage(tag + ChatColor.DARK_RED + "Check the console for a detailed error.");
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below");
e.printStackTrace();
}
public void debug(Exception e) {
if (debug) {
getServer().getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CommandPanels] The plugin has generated a debug error, find the error below");
e.printStackTrace();
}
}
public void helpMessage(CommandSender p) {
p.sendMessage(tex.colour( tag + ChatColor.GREEN + "Commands:"));
p.sendMessage(papi( tag + ChatColor.GREEN + "Commands:"));
p.sendMessage(ChatColor.GOLD + "/cp <panel> [player:item] [player] " + ChatColor.WHITE + "Open a command panel.");
if (p.hasPermission("commandpanel.reload")) {
p.sendMessage(ChatColor.GOLD + "/cpr " + ChatColor.WHITE + "Reloads plugin config.");
}
if (p.hasPermission("commandpanel.addons")) {
p.sendMessage(ChatColor.GOLD + "/cpa " + ChatColor.WHITE + "View downloadable panels for CommandPanels.");
}
if (p.hasPermission("commandpanel.generate")) {
p.sendMessage(ChatColor.GOLD + "/cpg <rows> " + ChatColor.WHITE + "Generate GUI from popup menu.");
}
if (p.hasPermission("commandpanel.version")) {
p.sendMessage(ChatColor.GOLD + "/cpv " + ChatColor.WHITE + "Display the current version.");
}
if (p.hasPermission("commandpanel.refresh")) {
p.sendMessage(ChatColor.GOLD + "/cpu <player> [position:all] " + ChatColor.WHITE + "Update a panel for a player while it is still open.");
}
if (p.hasPermission("commandpanel.update")) {
p.sendMessage(ChatColor.GOLD + "/cpv latest " + ChatColor.WHITE + "Download the latest update upon server reload/restart.");
p.sendMessage(ChatColor.GOLD + "/cpv [version:cancel] " + ChatColor.WHITE + "Download an update upon server reload/restart.");
}
if (p.hasPermission("commandpanel.edit")) {
p.sendMessage(ChatColor.GOLD + "/cpe <panel file> " + ChatColor.WHITE + "Export panel to the Online Editor.");
}
if (p.hasPermission("commandpanel.import")) {
p.sendMessage(ChatColor.GOLD + "/cpi <file name> <URL> " + ChatColor.WHITE + "Downloads a panel from a raw link online.");
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
}
if (p.hasPermission("commandpanel.list")) {
p.sendMessage(ChatColor.GOLD + "/cpl " + ChatColor.WHITE + "Lists the currently loaded panels.");
}
if (p.hasPermission("commandpanel.data")) {
p.sendMessage(ChatColor.GOLD + "/cpdata " + ChatColor.WHITE + "Change panel data for a user.");
}
if (p.hasPermission("commandpanel.debug")) {
p.sendMessage(ChatColor.GOLD + "/cpd " + ChatColor.WHITE + "Enable and Disable debug mode globally.");
}
@ -559,17 +685,11 @@ public class CommandPanels extends JavaPlugin{
public Reader getReaderFromStream(InputStream initialStream) throws IOException {
//this reads the encrypted resource files in the jar file
byte[] buffer = IOUtils.toByteArray(initialStream);
return new CharSequenceReader(new String(buffer));
}
//split lists using \n escape character
public List<String> splitListWithEscape(List<String> list){
List<String> output = new ArrayList<>();
for(String str : list){
output.addAll(Arrays.asList(str.split("\\\\n")));
if(Bukkit.getVersion().contains("1.13") || legacy.isLegacy()){
return new Sequence_1_13(this).getReaderFromStream(initialStream);
}else{
return new Sequence_1_14(this).getReaderFromStream(initialStream);
}
return output;
}
public int getRandomNumberInRange(int min, int max) {
@ -582,6 +702,22 @@ public class CommandPanels extends JavaPlugin{
return r.nextInt((max - min) + 1) + min;
}
//used to translate hex colours into ChatColors
public String translateHexColorCodes(String message) {
final Pattern hexPattern = Pattern.compile("#" + "([A-Fa-f0-9]{6})");
Matcher matcher = hexPattern.matcher(message);
StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x"
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5)
);
}
return matcher.appendTail(buffer).toString();
}
//returns true if the item is the MMO Item
public boolean isMMOItem(ItemStack itm, String type, String id){
try {
@ -593,7 +729,7 @@ public class CommandPanels extends JavaPlugin{
itm.getType();
}
}catch (Exception ex){
debug(ex,null);
debug(ex);
}
return false;
}

View File

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

View File

@ -1,152 +1,137 @@
package me.rockyhawk.commandpanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.interactives.input.PlayerInput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.*;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Objects;
import java.util.*;
public class Utils implements Listener {
CommandPanels plugin;
public Utils(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void onItemDrag(InventoryDragEvent e) {
Player p = (Player)e.getWhoClicked();
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(e.getInventory().getType() != InventoryType.PLAYER){
e.setCancelled(true);
}
}
@EventHandler
public void onPanelClick(InventoryClickEvent e) {
//when clicked on a panel
Player p = (Player)e.getWhoClicked();
int clickedSlot = e.getSlot();
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) || e.getClick() == ClickType.DOUBLE_CLICK){
ItemStack clicked = e.getCurrentItem();
if(!plugin.openPanels.hasPanelOpen(p.getName()) || e.getSlotType() == InventoryType.SlotType.OUTSIDE){
return;
}
ConfigurationSection cf = plugin.openPanels.getOpenPanel(p.getName()); //this is the panel cf section
//set the panel to the top panel
Panel panel = plugin.openPanels.getOpenPanel(p.getName(),PanelPosition.Top);
if(e.getClickedInventory().getType() == InventoryType.CHEST){
//loop through possible hasvalue/hasperm 1,2,3,etc
if(e.getSlotType() == InventoryType.SlotType.OUTSIDE){
//if the panel is clicked on the outside area of the GUI
if (panel.getConfig().contains("outside-commands")) {
try {
plugin.commandRunner.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"),e.getClick());
}catch(Exception s){
plugin.debug(s,p);
//this loops through all the items in the panel
boolean foundSlot = false;
for(String slot : Objects.requireNonNull(cf.getConfigurationSection("item")).getKeys(false)){
if(slot.equals(Integer.toString(e.getSlot()))){
foundSlot = true;
}
}
return;
}
PanelPosition position = PanelPosition.Top;
if(e.getClickedInventory().getType() == InventoryType.PLAYER) {
//cancel the event and return, stops items going from players inventory to the panels
if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
if(!foundSlot){
e.setCancelled(true);
p.updateInventory();
return;
}
//do player or panel inventory checks
if (e.getSlotType() == InventoryType.SlotType.CONTAINER) {
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Middle)) {
position = PanelPosition.Middle;
clickedSlot -= 9;
}else{
e.setCancelled(itemsUnmovable(panel));
return;
}
} else{
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Bottom)) {
position = PanelPosition.Bottom;
//this is set to cancelled as if the command is to close the panel and there is a hotbar item in the same slot
//it will also trigger the hotbar item after the panel is closed
e.setCancelled(true);
}else{
e.setCancelled(itemsUnmovable(panel));
String section = plugin.itemCreate.hasSection(cf.getConfigurationSection("item." + e.getSlot()), p);
if(cf.contains("item." + e.getSlot() + section + ".itemType")){
if(cf.getStringList("item." + e.getSlot() + section + ".itemType").contains("placeable")){
//skip if the item is a placeable
e.setCancelled(false);
return;
}
}
}
//the panels proper position
panel = plugin.openPanels.getOpenPanel(p.getName(),position);
//this loops through all the items in the panel
String foundSlot = null;
for(String item : Objects.requireNonNull(panel.getConfig().getConfigurationSection("item")).getKeys(false)){
String slot = plugin.tex.placeholdersNoColour(panel, position, p, item);
if (slot.equals(Integer.toString(clickedSlot))) {
foundSlot = item;
break;
}
}
if(foundSlot == null){
e.setCancelled(true);
return;
}
p.updateInventory();
//get the section of the slot that was clicked
String section = plugin.has.hasSection(panel,position,panel.getConfig().getConfigurationSection("item." + foundSlot), p);
if(panel.getConfig().contains("item." + foundSlot + section + ".itemType")){
if(panel.getConfig().getStringList("item." + foundSlot + section + ".itemType").contains("placeable")){
//skip if the item is a placeable
e.setCancelled(false);
return;
//this will remove any pending user inputs, if there is already something there from a previous item
for(int o = 0; plugin.userInputStrings.size() > o; o++){
if(plugin.userInputStrings.get(o)[0].equals(p.getName())){
plugin.userInputStrings.remove(o);
o=o-1;
}
}
}
//updates the inventory to stop item glitches
e.setCancelled(true);
p.updateInventory();
//if an item has an area for input instead of commands
if(panel.getConfig().contains("item." + foundSlot + section + ".player-input")) {
plugin.inputUtils.playerInput.put(p,new PlayerInput(panel,panel.getConfig().getStringList("item." + foundSlot + section + ".player-input"),e.getClick()));
plugin.inputUtils.sendMessage(panel,position,p);
}
if(panel.getConfig().contains("item." + foundSlot + section + ".commands")) {
List<String> commands = panel.getConfig().getStringList("item." + foundSlot + section + ".commands");
if (!commands.isEmpty()) {
for (int i = 0; commands.size() > i; i++) {
try {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", e.getCurrentItem().getType().toString()));
} catch (Exception mate) {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "AIR"));
if(cf.contains("item." + e.getSlot() + section + ".commands")) {
List<String> commands = cf.getStringList("item." + e.getSlot() + section + ".commands");
if (commands.size() != 0) {
//this will replace a sequence tag command with the commands from the sequence
List<String> commandsAfterSequence = commands;
for (int i = 0; commands.size() - 1 >= i; i++) {
if(commands.get(i).startsWith("sequence=")){
String locationOfSequence = commands.get(i).split("\\s")[1];
List<String> commandsSequence = cf.getStringList(locationOfSequence);
commandsAfterSequence.remove(i);
commandsAfterSequence.addAll(i,commandsSequence);
}
}
commands = commandsAfterSequence;
for (int i = 0; commands.size() - 1 >= i; i++) {
try {
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("right=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("right=", "").trim());
commands.set(i, commands.get(i).replace("RIGHT=", "").trim());
if (e.isLeftClick() || (e.isShiftClick() && e.isLeftClick()) || (e.isShiftClick() && e.isRightClick())) {
continue;
}
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("rightshift=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("rightshift=", "").trim());
commands.set(i, commands.get(i).replace("RIGHTSHIFT=", "").trim());
if (e.isLeftClick() || (!e.isShiftClick() && e.isRightClick())) {
continue;
}
}
if (commands.get(i).split("\\s")[0].equalsIgnoreCase("left=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("left=", "").trim());
commands.set(i, commands.get(i).replace("LEFT=", "").trim());
if (e.isRightClick() || (e.isShiftClick() && e.isRightClick()) || (e.isShiftClick() && e.isLeftClick())) {
continue;
}
} else if (commands.get(i).split("\\s")[0].equalsIgnoreCase("leftshift=")) {
//if commands is for right clicking, remove the 'right=' and continue
commands.set(i, commands.get(i).replace("leftshift=", "").trim());
commands.set(i, commands.get(i).replace("LEFTSHIFT=", "").trim());
if (e.isRightClick() || (!e.isShiftClick() && e.isLeftClick())) {
continue;
}
}
if (!e.isLeftClick() && !e.isRightClick()) {
continue;
}
} catch (Exception click) {
//skip if you can't do this
}
//start custom command placeholders
try {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", clicked.getType().toString()));
} catch (Exception mate) {
commands.set(i, commands.get(i).replaceAll("%cp-clicked%", "Air"));
}
//end custom command PlaceHolders
String command = plugin.papi(p,commands.get(i));
int val = plugin.commandTags.commandPayWall(p,command);
if(val == 0){
return;
}
if(val == 2){
plugin.commandTags.commandTags(p, command, commands.get(i));
}
}
}
if (panel.getConfig().contains("item." + foundSlot + section + ".multi-paywall")) {
plugin.commandRunner.runMultiPaywall(panel,position,p,
panel.getConfig().getStringList("item." + foundSlot + section + ".multi-paywall"),
commands,e.getClick());
} else {
plugin.commandRunner.runCommands(panel, position, p, commands, e.getClick());
}
}
}
}
private boolean itemsUnmovable(Panel panel){
if(panel.getConfig().isSet("panelType")){
//cancel event and return to signal no commands and no movement will occur
return panel.getConfig().getStringList("panelType").contains("unmovable");
}
return false;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,658 @@
package me.rockyhawk.commandpanels.classresources;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import net.mmogroup.mmolib.api.item.NBTItem;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.util.Objects;
public class CommandTags {
CommandPanels plugin;
public CommandTags(CommandPanels pl) {
this.plugin = pl;
}
@SuppressWarnings("deprecation")
public void commandTags(Player p, String command, String commandRAW) {
//commandRAW is without placeholders
switch(command.split("\\s")[0]){
case "server=":{
//this contacts bungee and tells it to send the server change command
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF(command.split("\\s")[1]);
Player player = Bukkit.getPlayerExact(p.getName());
assert player != null;
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
break;
}
case "cpc":{
//this will close the current inventory
p.closeInventory();
break;
}
case "open=":{
//if player uses open= it will open the panel, with the option to add custom placeholders
String panelName = commandRAW.split("\\s")[1];
String cmd = commandRAW.replace("open= " + panelName,"");
panelName = plugin.papi(p,panelName);
Character[] cm = ArrayUtils.toObject(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(']'));
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.papi(p,contents.substring(contents.indexOf(':')+1));
plugin.customCommand.addCCP(panelName,p.getName(),placeholder,value);
i = i+contents.length()-1;
}
}
for(String[] tempName : plugin.panelNames){
if(tempName[0].equals(panelName)){
ConfigurationSection panelConfig = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + plugin.panelFiles.get(Integer.parseInt(tempName[1])))).getConfigurationSection("panels." + panelName);
if(plugin.openPanels.hasPanelOpen(p.getName())) {
plugin.openPanels.skipPanels.add(p.getName());
}
plugin.openVoids.openCommandPanel(p,p,panelName,panelConfig,false);
return;
}
}
break;
}
case "console=":{
//if player uses console= it will perform command in the console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replace("console=", "").trim());
break;
}
case "placeholder=":{
//if player uses placeholder= it will only change the placeholders for the panel
String panelName = commandRAW.split("\\s")[1];
String cmd = commandRAW.replace("placeholder= " + panelName,"");
panelName = plugin.papi(p,panelName);
Character[] cm = ArrayUtils.toObject(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(']'));
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.papi(p,contents.substring(contents.indexOf(':')+1));
plugin.customCommand.editCCP(panelName,p.getName(),placeholder,value);
i = i+contents.length()-1;
}
}
break;
}
case "setitem=":{
//if player uses setitem= [custom item] [slot] 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
ConfigurationSection panelCF = plugin.openPanels.getOpenPanel(p.getName());
ItemStack s = plugin.itemCreate.makeItemFromConfig(panelCF.getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, true);
p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(command.split("\\s")[2]), s);
break;
}
case "refresh":{
//this will just do a standard panel refresh, animate is set to 0
plugin.createGUI.openGui(null, p, plugin.openPanels.getOpenPanel(p.getName()), 0,0);
break;
}
case "op=":{
//if player uses op= it will perform command as op
boolean isop = p.isOp();
try {
p.setOp(true);
Bukkit.dispatchCommand(p,command.replace("op=", "").trim());
p.setOp(isop);
} catch (Exception exc) {
p.setOp(isop);
plugin.debug(exc);
p.sendMessage(plugin.tag + plugin.papi( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
}
break;
}
case "delay=":{
//if player uses op= it will perform command as op
final int delaySeconds = Integer.parseInt(command.split("\\s")[1]);
String finalCommand = command.split("\\s",3)[2];
new BukkitRunnable() {
@Override
public void run() {
commandTags(p, finalCommand, commandRAW);
this.cancel();
}
}.runTaskTimer(plugin, 20*delaySeconds, 20); //20 ticks == 1 second
break;
}
case "buy=":{
//if player uses buy= it will be eg. buy= <price> <item> <amount of item> <ID>
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()){
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
//legacy ID
byte id = 0;
if(plugin.legacy.isLegacy()) {
for (String argsTemp : command.split("\\s")) {
if (argsTemp.startsWith("id:")) {
id = Byte.parseByte(argsTemp.replace("id:", ""));
break;
}
}
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "tokenbuy=":{
//if player uses tokenbuy= it will be eg. tokenbuy= <price> <item> <amount of item> <ID>
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).isEmpty()) {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
//legacy ID
byte id = 0;
if(plugin.legacy.isLegacy()) {
for (String argsTemp : command.split("\\s")) {
if (argsTemp.startsWith("id:")) {
id = Byte.parseByte(argsTemp.replace("id:", ""));
break;
}
}
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3]),id));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needmoney-token")));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires TokenManager to work!"));
}
} catch (Exception buy) {
plugin.debug(buy);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "sell=":{
//if player uses sell= it will be eg. sell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.econ != null) {
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
break;
}
}
//legacy ID
byte id = -1;
if(plugin.legacy.isLegacy()) {
for (String argsTemp : command.split("\\s")) {
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)) {
continue;
}
}
if (id != -1) {
if (itm.getDurability() != id) {
continue;
}
}
}catch(Exception exc){
//skip unless plugin.debug enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.sold")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Selling Requires Vault and an Economy to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "tokensell=":{
//if player uses tokensell= it will be eg. tokensell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
boolean sold = false;
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(command.split("\\s")[2]))) {
//determine if the command contains parameters for extensions
String potion = "false";
for(String argsTemp : command.split("\\s")){
if(argsTemp.startsWith("potion:")){
potion = argsTemp.replace("potion:","");
}
}
//legacy ID
byte id = -1;
if(plugin.legacy.isLegacy()) {
for (String argsTemp : command.split("\\s")) {
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.papi( plugin.tag + ChatColor.RED + "Your item has the wrong potion effect"));
return;
}
}
if (id != -1) {
if (itm.getDurability() != id) {
continue;
}
}
}catch(Exception exc){
//skip if it cannot do unless plugin.debug is enabled
plugin.debug(exc);
}
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[2])), Integer.parseInt(command.split("\\s")[3])).getAmount();
itm.setAmount(amt);
p.getInventory().setItem(f, amt > 0 ? itm : null);
plugin.econ.depositPlayer(p, Double.parseDouble(command.split("\\s")[1]));
assert api != null;
api.addTokens(p, Long.parseLong(command.split("\\s")[1]));
sold = true;
p.updateInventory();
break;
}
}
}
if (!sold) {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needitems")));
} else {
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold-token")).isEmpty()) {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.sold-token")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Selling Requires TokenManager to work!"));
}
} catch (Exception sell) {
plugin.debug(sell);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "msg=":{
//if player uses msg= it will send the player a message
p.sendMessage(command.replace("msg=", "").trim());
break;
}
case "sound=":{
//if player uses sound= it will play a sound (sound= [sound])
try {
p.playSound(p.getLocation(), Sound.valueOf(command.split("\\s")[1]), 1F, 1F);
} catch (Exception s) {
plugin.debug(s);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "buycommand=":{
//if player uses buycommand [price] [command]
try {
if (plugin.econ != null) {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("buycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,commandp,commandRAW);
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needmoney")));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "tokenbuycommand=":{
//if player uses tokenbuycommand [price] [command]
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
assert api != null;
int balance = Integer.parseInt(Long.toString(api.getTokens(p).orElse(0)));
if (balance >= Double.parseDouble(command.split("\\s")[1])) {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//execute command under here
String commandp = command;
commandp = commandp.replace("tokenbuycommand=", "").trim();
String price = commandp.split(" ", 2)[0];
commandp = commandp.split(" ", 2)[1];
commandTags(p,commandp,commandRAW);
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).isEmpty()) {
p.sendMessage(plugin.papi( plugin.tag + Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).replaceAll("%cp-args%", price)));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.needmoney-token")));
}
} else {
p.sendMessage(plugin.papi( plugin.tag + ChatColor.RED + "Buying Requires Vault and an Economy to work!"));
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
case "teleport=":{
//if player uses teleport= x y z (optional other player)
if (command.split("\\s").length == 6) {
float x, y, z, yaw, pitch; //pitch is the heads Y axis and yaw is the X axis
x = Float.parseFloat(command.split("\\s")[1]);
y = Float.parseFloat(command.split("\\s")[2]);
z = Float.parseFloat(command.split("\\s")[3]);
yaw = Float.parseFloat(command.split("\\s")[4]);
pitch = Float.parseFloat(command.split("\\s")[5]);
p.teleport(new Location(p.getWorld(), x, y, z, yaw, pitch));
} else if (command.split("\\s").length <= 4) {
float x, y, z;
x = Float.parseFloat(command.split("\\s")[1]);
y = Float.parseFloat(command.split("\\s")[2]);
z = Float.parseFloat(command.split("\\s")[3]);
p.teleport(new Location(p.getWorld(), x, y, z));
} else {
try {
Player otherplayer = Bukkit.getPlayer(command.split("\\s")[4]);
float x, y, z;
x = Float.parseFloat(command.split("\\s")[1]);
y = Float.parseFloat(command.split("\\s")[2]);
z = Float.parseFloat(command.split("\\s")[3]);
assert otherplayer != null;
otherplayer.teleport(new Location(otherplayer.getWorld(), x, y, z));
} catch (Exception tpe) {
p.sendMessage(plugin.tag + plugin.config.getString("config.format.notitem"));
}
}
break;
}
case "sudo=":{
//if player uses sudo= [command] to send a command as them
p.chat( "/" + command.replaceAll("sudo=", "").trim());
break;
}
case "send=":{
//if player uses send= [message] to send a message as them
p.chat( command.replaceAll("send=", "").trim());
break;
}
case "stopsound=":{
//if player uses stopsound= [sound]
try {
p.stopSound(Sound.valueOf(command.split("\\s")[1]));
} catch (Exception ss) {
plugin.debug(ss);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
}
break;
}
default:
Bukkit.dispatchCommand(p, command);
}
}
@SuppressWarnings("deprecation")
public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
String tag = plugin.config.getString("config.format.tag") + " ";
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 the message is empty don't send
if(!plugin.config.getString("config.format.bought").isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}
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(!Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought-token")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney-token")));
return 0;
}
} else {
p.sendMessage(plugin.papi( tag + ChatColor.RED + "Paying TokenManager to work!"));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}
case "item-paywall=": {
//if player uses item-paywall= [Material] [Amount] [Id]
//or player can use item-paywall= [custom-item]
try {
short id = 0;
if(command.split("\\s").length == 4){
id = Short.parseShort(command.split("\\s")[3]);
}
//create the item to be removed
ItemStack sellItem;
if(command.split("\\s").length == 2) {
sellItem = plugin.itemCreate.makeItemFromConfig(plugin.openPanels.getOpenPanel(p.getName()).getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, true);
}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
int removedItem = 0;
//loop through items in the inventory
for(ItemStack content : p.getInventory().getContents()){
if(content == null){
//skip slot if empty
continue;
}
if(command.split("\\s").length == 2){
//if item paywall is custom item
if(content.isSimilar(sellItem)){
content.setAmount(content.getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
break;
}
//if custom item is an mmo item (1.14+ for the API)
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")) {
String customItemMaterial = plugin.openPanels.getOpenPanel(p.getName()).getString("custom-item." + command.split("\\s")[1] + ".material");
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (plugin.isMMOItem(sellItem,mmoType,mmoID) && sellItem.getAmount() <= content.getAmount()) {
content.setAmount(content.getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
break;
}
}
}catch (Exception ex){
plugin.debug(ex);
}
}else {
//if the item is a standard material
if (content.getType() == sellItem.getType()) {
if (sellItem.getAmount() <= content.getAmount()) {
content.setAmount(content.getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
break;
}
}
}
}
//send message and return
if(removedItem == 0){
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
}else{
if(!Objects.requireNonNull(plugin.config.getString("config.format.sold")).isEmpty()) {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.sold")));
}
}
return removedItem;
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}
case "xp-paywall=": {
//if player uses xp-paywall= [price]
try {
int balance = p.getLevel();
if (balance >= Integer.parseInt(command.split("\\s")[1])) {
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
//if the message is empty don't send
if(!Objects.requireNonNull(plugin.config.getString("config.format.bought")).isEmpty()) {
p.sendMessage(plugin.papi( tag + Objects.requireNonNull(plugin.config.getString("config.format.bought")).replaceAll("%cp-args%", command.split("\\s")[1])));
}
return 1;
} else {
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.needmoney")));
return 0;
}
} catch (Exception buyc) {
plugin.debug(buyc);
p.sendMessage(plugin.papi( tag + plugin.config.getString("config.format.error") + " " + "commands: " + command));
return 0;
}
}
}
return 2;
}
}

View File

@ -1,18 +1,15 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Objects;
public class ExecuteOpenVoids {
@ -22,143 +19,131 @@ public class ExecuteOpenVoids {
}
//this is the main method to open a panel
public void openCommandPanel(CommandSender sender, Player p, Panel panel, PanelPosition position, boolean openForOtherUser){
if(p == null){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Player not found."));
return;
}
public void openCommandPanel(CommandSender sender, Player p, String panelName, ConfigurationSection cf, boolean sendOpenedMessage){
if(p.isSleeping()){
//avoid plugin glitches when sleeping
return;
}
if((plugin.debug.isEnabled(sender) || plugin.config.getBoolean("config.auto-update-panels")) && panel.getFile() != null){
//reload the panel if debug is enabled
panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile()));
}
if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
if (sender.hasPermission("commandpanel.panel." + cf.getString("perm"))) {
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendOpenedMessage) {
try {
if (cf.contains("disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("disabled-worlds");
if (disabledWorlds.contains(p.getWorld().getName())) {
//panel cannot be used in the players world!
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
return;
}
//close the panel after the checks for permissions and worlds, so other panels can load
if(!plugin.openPanels.hasPanelOpen(p.getName()) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
p.closeInventory();
}else{
plugin.openPanels.closePanelsForLoader(p.getName());
}
try {
if (cf.contains("sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(cf.getString("sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + cf.getString("sound-on-open")));
}
}
}
if (cf.contains("commands-on-open")) {
//execute commands on panel open
try {
List<String> commands = cf.getStringList("commands-on-open");
for (int i = 0; commands.size() - 1 >= i; i++) {
int val = plugin.commandTags.commandPayWall(p,commands.get(i));
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags.commandTags(p, plugin.papi(p,commands.get(i)),commands.get(i));
}
}
}catch(Exception s){
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + cf.getString("commands-on-open")));
}
}
plugin.openPanels.openPanelForLoader(p.getName(), panelName, cf);
plugin.createGUI.openGui(panelName, p, cf,1,0);
if(sendOpenedMessage) {
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
}
} catch (Exception r) {
plugin.debug(r);
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
//check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cannot open a panel without a panel at the top already."));
return;
}
//close any foreign GUIs for CommandPanels
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
p.closeInventory();
}
//fire PanelOpenedEvent
PanelOpenedEvent openedEvent = new PanelOpenedEvent(p,panel,position);
Bukkit.getPluginManager().callEvent(openedEvent);
if(openedEvent.isCancelled()){
return;
}
//do these commands before the panel loads
beforeLoadCommands(panel,position,p);
try {
//create and open the GUI
plugin.createGUI.openGui(panel, p, position,PanelOpenType.Normal,0);
//execute commands once the panel opens
if (panel.getConfig().contains("commands-on-open")) {
try {
plugin.commandRunner.runCommands(panel,position,p, panel.getConfig().getStringList("commands-on-open"), null);
}catch(Exception s){
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open")));
}
}
if (panel.getConfig().contains("sound-on-open")) {
//play sound when panel is opened
if(!Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).equalsIgnoreCase("off")) {
try {
p.playSound(p.getLocation(), Sound.valueOf(Objects.requireNonNull(panel.getConfig().getString("sound-on-open")).toUpperCase()), 1F, 1F);
} catch (Exception s) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "sound-on-open: " + panel.getConfig().getString("sound-on-open")));
}
}
}
if(openForOtherUser) {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Panel Opened for " + p.getDisplayName()));
}
} catch (Exception r) {
plugin.debug(r,null);
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error")));
plugin.openPanels.closePanelForLoader(p.getName(),position);
p.closeInventory();
}
}else{
if(panel.getConfig().getString("custom-messages.perms") != null) {
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
}else {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
}
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
//this will give a hotbar item to a player
public void giveHotbarItem(CommandSender sender, Player p, Panel panel, boolean sendGiveMessage){
if (sender.hasPermission("commandpanel.item." + panel.getConfig().getString("perm")) && panel.getConfig().contains("open-with-item")) {
//check for disabled worlds
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
public void giveHotbarItem(CommandSender sender, Player p, ConfigurationSection cf, boolean sendGiveMessage){
if (sender.hasPermission("commandpanel.item." + cf.getString("perm")) && cf.contains("open-with-item")) {
try {
if (cf.contains("disabled-worlds")) {
List<String> disabledWorlds = cf.getStringList("disabled-worlds");
if (disabledWorlds.contains(p.getWorld().getName())) {
//panel cannot be used in the players world!
if (Objects.requireNonNull(plugin.config.getString("config.disabled-world-message")).equalsIgnoreCase("true")) {
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Panel is disabled in the world!"));
}
return;
}
}
}catch(NullPointerException offlinePlayer){
//SKIP because player is offline
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
return;
}
ItemStack s;
try {
s = plugin.itemCreate.makeItemFromConfig(Objects.requireNonNull(cf.getConfigurationSection("open-with-item")), p, false, true, true);
}catch(Exception n){
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " open-with-item: material"));
return;
}
plugin.setName(s, cf.getString("open-with-item.name"), cf.getStringList("open-with-item.lore"),p,false, true, true);
//if the sender has OTHER perms, or if sendGiveMessage is false, implying it is not for another person
if(sender.hasPermission("commandpanel.other") || !sendGiveMessage) {
try {
if(panel.getConfig().contains("open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(panel.getConfig().getString("open-with-item.stationary"))), panel.getHotbarItem(p));
if(cf.contains("open-with-item.stationary")) {
p.getInventory().setItem(Integer.parseInt(Objects.requireNonNull(cf.getString("open-with-item.stationary"))), s);
}else{
p.getInventory().addItem(panel.getHotbarItem(p));
p.getInventory().addItem(s);
}
if(sendGiveMessage) {
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
sender.sendMessage(plugin.papi( plugin.tag + ChatColor.GREEN + "Item Given to " + p.getDisplayName()));
}
} catch (Exception r) {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.notitem")));
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.notitem")));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
return;
}
if (!panel.getConfig().contains("open-with-item")) {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.noitem")));
if (!cf.contains("open-with-item")) {
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.noitem")));
return;
}
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
public void beforeLoadCommands(Panel panel,PanelPosition pos, Player p){
if (panel.getConfig().contains("pre-load-commands")) {
try {
plugin.commandRunner.runCommands(panel,pos,p, panel.getConfig().getStringList("pre-load-commands"), null);
}catch(Exception s){
plugin.debug(s,p);
}
}
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
}

View File

@ -0,0 +1,102 @@
package me.rockyhawk.commandpanels.classresources;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field;
import java.util.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.isLegacy()){
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.isLegacy()){
id = 3;
}
ItemStack head = new ItemStack(Material.matchMaterial(plugin.getHeads.playerHeadString()), 1,id);
ItemMeta headMeta = head.getItemMeta();
assert headMeta != null;
Class headMetaClass = headMeta.getClass();
try {
getField(headMetaClass, "profile", GameProfile.class, 0).set(headMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException var10) {
plugin.debug(var10);
}
head.setItemMeta(headMeta);
return head;
}
}
//used with getItem for heads
private <T> Field getField(Class<?> target, String name, Class<T> fieldType, int index) {
Field[] var4 = target.getDeclaredFields();
for (Field field : var4) {
if ((name == null || field.getName().equals(name)) && fieldType.isAssignableFrom(field.getType()) && index-- <= 0) {
field.setAccessible(true);
return field;
}
}
if (target.getSuperclass() != null) {
return getField(target.getSuperclass(), name, fieldType, index);
} else {
throw new IllegalArgumentException("Cannot find field with type " + fieldType);
}
}
}

View File

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

View File

@ -1,12 +1,7 @@
package me.rockyhawk.commandpanels.classresources;
import dev.lone.itemsadder.api.CustomStack;
import me.arcaniax.hdb.api.HeadDatabaseAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.classresources.customheads.SavedCustomHead;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.manager.ItemManager;
@ -16,21 +11,23 @@ import org.bukkit.block.banner.PatternType;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.*;
import org.bukkit.inventory.meta.trim.ArmorTrim;
import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import java.lang.reflect.Method;
import java.util.*;
import java.util.stream.Collectors;
import javax.swing.*;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
public class ItemCreation {
CommandPanels plugin;
@ -39,19 +36,18 @@ public class ItemCreation {
}
@SuppressWarnings("deprecation")
public ItemStack makeItemFromConfig(Panel panel, PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String material = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("material"));
public ItemStack makeItemFromConfig(ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean hideAttributes){
String material = plugin.papiNoColour(p,itemSection.getString("material"));
try {
if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) {
return null;
}
}catch(NullPointerException e){
plugin.debug(e,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
plugin.debug(e);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: could not load material!"));
return null;
}
ItemStack s = null;
boolean hideAttributes = false;
String mat;
String matraw;
String skullname;
@ -81,68 +77,24 @@ public class ItemCreation {
if(itemSection.contains("ID")){
id = Short.parseShort(itemSection.getString("ID"));
}
if (matraw.split("\\s")[0].equalsIgnoreCase("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
if (matraw.split("\\s")[0].toLowerCase().equals("cps=") || matraw.split("\\s")[0].toLowerCase().equals("cpo=")) {
skullname = p.getUniqueId().toString();
mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(plugin.legacy.isLegacy()){
id = 3;
}
}
if (matraw.split("\\s")[0].equalsIgnoreCase("hdb=")) {
if (matraw.split("\\s")[0].toLowerCase().equals("hdb=")) {
skullname = "hdb";
mat = plugin.getHeads.playerHeadString();
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(plugin.legacy.isLegacy()){
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")){
//create custom MMOItems item
if(matraw.split("\\s")[0].toLowerCase().equals("mmo=") && plugin.getServer().getPluginManager().isPluginEnabled("MMOItems")){
String itemType = matraw.split("\\s")[1];
String itemID = matraw.split("\\s")[2];
ItemManager itemManager = MMOItems.plugin.getItems();
@ -151,25 +103,6 @@ public class ItemCreation {
normalCreation = false;
}
//creates a written book item
if(matraw.split("\\s")[0].equalsIgnoreCase("book=")){
s = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) s.getItemMeta();
bookMeta.setTitle(matraw.split("\\s")[1]);
bookMeta.setAuthor(matraw.split("\\s")[1]);
List<String> bookLines = plugin.tex.placeholdersList(panel,position,p,itemSection.getStringList("write"),true);
String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", ""));
bookMeta.setPages(result);
s.setItemMeta(bookMeta);
normalCreation = false;
}
//creates item from custom-items section of panel
if(matraw.split("\\s")[0].equalsIgnoreCase("cpi=")){
s = makeCustomItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, false);
normalCreation = false;
}
if(normalCreation) {
s = new ItemStack(Objects.requireNonNull(Material.matchMaterial(mat)), 1, id);
}
@ -180,28 +113,28 @@ public class ItemCreation {
if (matraw.split("\\s")[1].equalsIgnoreCase("self")) {
//if cps= self
meta = (SkullMeta) s.getItemMeta();
if(!plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
if(!plugin.legacy.isLegacy()) {
try {
assert meta != null;
meta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString(skullname)));
} catch (Exception var23) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: cps= self"));
plugin.debug(var23);
}
}else{
meta.setOwner(p.getName());
}
s.setItemMeta(meta);
}else if (plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]).length() <= 16) {
}else if (plugin.papiNoColour(p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username
s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
s = plugin.customHeads.getPlayerHead(plugin.papiNoColour(p,matraw.split("\\s")[1]));
} else {
//custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
s = plugin.customHeads.getCustomHead(plugin.papiNoColour(p,matraw.split("\\s")[1]));
}
} catch (Exception var32) {
p.sendMessage(plugin.tex.colour( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32,p);
p.sendMessage(plugin.papi( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
plugin.debug(var32);
}
}
if (!skullname.equals("no skull") && matraw.split("\\s")[0].equalsIgnoreCase("cpo=")) {
@ -218,60 +151,81 @@ public class ItemCreation {
try {
s = api.getItemHead(matraw.split("\\s")[1].trim());
} catch (Exception var22) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " hdb: could not load skull!"));
plugin.debug(var22);
}
} else {
p.sendMessage(plugin.tex.colour(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
p.sendMessage(plugin.papi(plugin.tag + "Download HeadDatabaseHook from Spigot to use this feature!"));
}
}
//itemType values
if(itemSection.contains("itemType")){
//if hidden, reverse
if(itemSection.getStringList("itemType").contains("noAttributes")){
hideAttributes = true;
}
if(itemSection.getStringList("itemType").contains("placeable")){
addNBT = false;
if(itemSection.getStringList("itemType").contains("attributes")){
hideAttributes = !hideAttributes;
}
}
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 (itemSection.contains("map")) {
/*
This will do maps from custom images
the maps will be in the 'maps' folder, so
CommandPanels/maps/image.png <-- here
Commandpanels/panels/example.yml
The images should be 128x128
*/
try{
@SuppressWarnings("deprecation")
MapView map = Bukkit.getServer().getMap(0);
try {
map.getRenderers().clear();
map.setCenterX(30000000);
map.setCenterZ(30000000);
}catch(NullPointerException ignore){
//ignore catch
}
if(new File(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).exists()) {
map.addRenderer(new MapRenderer() {
public void render(MapView view, MapCanvas canvas, Player player) {
canvas.drawImage(0, 0, new ImageIcon(plugin.getDataFolder().getPath() + File.separator + "maps" + File.separator + itemSection.getString("map")).getImage());
}
});
MapMeta meta = (MapMeta) s.getItemMeta();
meta.setMapView(map);
s.setItemMeta(meta);
}else{
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: File not found."));
}
}catch(Exception map){
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " map: " + itemSection.getString("map")));
plugin.debug(map);
}
}
if(addNBT){
plugin.nbt.setNBT(s, "CommandPanelsItem","boolean_" + "true");
}
if (itemSection.contains("enchanted")) {
try {
ItemMeta EnchantMeta;
if(itemSection.isList("enchanted")){
//if list contains true, hide enchanted and add KNOCKBACK
if (Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("true")) {
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);
}
EnchantMeta.addEnchant(Enchantment.KNOCKBACK, 1, false);
EnchantMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
s.setItemMeta(EnchantMeta);
} else if (!Objects.requireNonNull(itemSection.getString("enchanted")).trim().equalsIgnoreCase("false")) {
EnchantMeta = s.getItemMeta();
assert EnchantMeta != null;
EnchantMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(NamespacedKey.minecraft(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[0].toLowerCase()))), Integer.parseInt(Objects.requireNonNull(itemSection.getString("enchanted")).split("\\s")[1]), true);
s.setItemMeta(EnchantMeta);
}
} catch (Exception ench) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench,p);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " enchanted: " + itemSection.getString("enchanted")));
plugin.debug(ench);
}
}
if (itemSection.contains("customdata")) {
ItemMeta customMeta = s.getItemMeta();
assert customMeta != null;
customMeta.setCustomModelData(Integer.parseInt(plugin.tex.placeholders(panel,position,p,itemSection.getString("customdata"))));
customMeta.setCustomModelData(Integer.parseInt(Objects.requireNonNull(itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
try {
@ -279,9 +233,8 @@ public class ItemCreation {
BannerMeta bannerMeta = (BannerMeta) s.getItemMeta();
List<Pattern> patterns = new ArrayList<>(); //Load patterns in order top to bottom
for (String temp : itemSection.getStringList("banner")) {
temp = plugin.tex.placeholdersNoColour(panel,position,p,temp);
String[] dyePattern = temp.split(",");
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED,STRIPE_TOP
patterns.add(new Pattern(DyeColor.valueOf(dyePattern[0]), PatternType.valueOf(dyePattern[1]))); //load patterns in config: RED:STRIPE_TOP
}
bannerMeta.setPatterns(patterns);
s.setItemMeta(bannerMeta);
@ -292,13 +245,9 @@ public class ItemCreation {
if (itemSection.contains("leatherarmor")) {
//if the item is leather armor, change the colour to this
try {
if (s.getType() == Material.LEATHER_BOOTS ||
s.getType() == Material.LEATHER_LEGGINGS ||
s.getType() == Material.LEATHER_CHESTPLATE ||
s.getType() == Material.LEATHER_HELMET ||
s.getType() == Material.matchMaterial("LEATHER_HORSE_ARMOR")) { //avoid exceptions on older versions which don't have leather armour
if (s.getType() == Material.LEATHER_BOOTS || s.getType() == Material.LEATHER_LEGGINGS || s.getType() == Material.LEATHER_CHESTPLATE || s.getType() == Material.LEATHER_HELMET) {
LeatherArmorMeta leatherMeta = (LeatherArmorMeta) s.getItemMeta();
String colourCode = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("leatherarmor"));
String colourCode = itemSection.getString("leatherarmor");
assert colourCode != null;
if (!colourCode.contains(",")) {
//use a color name
@ -319,129 +268,159 @@ public class ItemCreation {
}
} catch (Exception er) {
//don't colour the armor
plugin.debug(er,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
plugin.debug(er);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " leatherarmor: " + itemSection.getString("leatherarmor")));
}
}
if (itemSection.contains("potion")) {
//if the item is a potion, give it an effect
String[] effectType = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("potion")).split("\\s");
//potion legacy or current
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
if(plugin.legacy.MAJOR_VERSION.equals(MinecraftVersions.v1_8)){
plugin.classicPotion.applyPotionEffect(p, s, effectType);
}else {
plugin.legacyPotion.applyPotionEffect(p, s, effectType);
}
}else{
try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
assert potionMeta != null;
PotionType newData = PotionType.valueOf(effectType[0].toUpperCase());
//set meta
potionMeta.setBasePotionType(newData);
s.setItemMeta(potionMeta);
} catch (Exception er) {
//don't add the effect
plugin.debug(er,p);
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
}
}
}
if(itemSection.contains("potion-color")){
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_11)){
String[] rgb = Objects.requireNonNull(itemSection.getString("potion-color")).split(",");
Color color = Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]));
try {
PotionMeta potionMeta = (PotionMeta)s.getItemMeta();
String effectType = itemSection.getString("potion");
assert potionMeta != null;
potionMeta.setColor(color);
assert effectType != null;
potionMeta.setBasePotionData(new PotionData(PotionType.valueOf(effectType.toUpperCase())));
potionMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
s.setItemMeta(potionMeta);
} catch (Exception er) {
//don't add the effect
plugin.debug(er);
p.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + plugin.config.getString("config.format.error") + " potion: " + itemSection.getString("potion")));
}
}
if (itemSection.contains("damage")) {
//change the damage amount (placeholders accepted)
//if the damage is not unbreakable and should be a value
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
if(plugin.legacy.isLegacy()){
try {
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.papi(p, itemSection.getString("damage")))));
}catch(Exception e){
plugin.debug(e);
p.sendMessage(plugin.papi(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.papi(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 {
if(itemSection.getString("damage").equalsIgnoreCase("-1")){
//if the player wants the item to be unbreakable. Only works in non legacy versions
ItemMeta unbreak = s.getItemMeta();
unbreak.setUnbreakable(true);
s.setItemMeta(unbreak);
}else {
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel, position, p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage);
} catch (Exception e) {
plugin.debug(e, p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
}
}
}
// 1.20 Trim Feature for Player Armor
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
// trim: <Material> <Pattern>
String trim = itemSection.getString("trim");
String[] trimList = trim.split("\\s");
if(trimList.length == 2){
String trimMaterialString = trimList[0].toLowerCase();
String trimPatternString = trimList[1].toLowerCase();
// Check if Material and Pattern are valid and the itemstack is an armor piece
if(isTrimMaterial(trimMaterialString) && isTrimPattern(trimPatternString) && isArmor(s)){
// Getting the correct Pattern and Material - Seems to be experimental this way
// Material and Pattern don't have a valueOf-function to get them the easier way.
TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimMaterialString)));
TrimPattern trimPattern = Registry.TRIM_PATTERN.get(Objects.requireNonNull(NamespacedKey.fromString("minecraft:" + trimPatternString)));
ArmorMeta armorMeta = (ArmorMeta) s.getItemMeta();
armorMeta.setTrim(new ArmorTrim(trimMaterial, trimPattern));
s.setItemMeta(armorMeta);
plugin.debug(e);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
}
}
}
if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted)
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p,itemSection.getString("stack")))));
}
//do the items commands throughout the refresh
//check that the panel is already open and not running commands when opening
if (itemSection.contains("refresh-commands") && plugin.openPanels.hasPanelOpen(p.getName(), panel.getName(), position)) {
try {
plugin.commandRunner.runCommands(panel,position,p,itemSection.getStringList("refresh-commands"), null);
}catch(Exception ex){
plugin.debug(ex,p);
}
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.papi(p,itemSection.getString("stack")))));
}
} catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
plugin.debug(var33);
p.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.error") + " material: " + itemSection.getString("material")));
return null;
}
s = plugin.setName(panel,s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
plugin.setName(s, itemSection.getString("name"), itemSection.getStringList("lore"), p, placeholders, colours, hideAttributes);
return s;
}
//do custom-item items, they have an additional hasSection requirement
public ItemStack makeCustomItemFromConfig(Panel panel,PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.has.hasSection(panel,position,itemSection,p);
if(!section.equals("")){
itemSection = itemSection.getConfigurationSection(section.substring(1));
//hasperm hasvalue, etc sections will be done here
public String hasSection(ConfigurationSection cf, Player p){
if (cf.contains("hasvalue")) {
//this will do the hasvalue without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue.output");
}
String value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.value"))));
String compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue.compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + section;
}
//loop through possible hasvalue 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasvalue" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasvalue" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue" + count + ".output");
}
value = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".value"))));
compare = ChatColor.stripColor(plugin.papi(p,plugin.setCpPlaceholders(p,cf.getString("hasvalue" + count + ".compare"))));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + count + section;
}
}
}
}
return plugin.itemCreate.makeItemFromConfig(panel,position,itemSection, p, placeholders, colours, addNBT);
if (cf.contains("hasgreater")) {
//this will do the hasgreater without any numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater.output");
}
double value = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater.value"))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater.compare"))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
return ".hasgreater" + section;
}
//loop through possible hasgreater 1,2,3,etc
for (int count = 0; cf.getKeys(false).size() > count; count++) {
if (cf.contains("hasgreater" + count)) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasgreater" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater" + count + ".output");
}
value = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater" + count + ".value"))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.papiNoColour(p,cf.getString("hasgreater" + count + ".compare"))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
return ".hasgreater" + count + section;
}
}
}
}
if (cf.contains("hasperm")) {
//this will do hasperm with no numbers
boolean outputValue = true;
//outputValue will default to true
if (cf.contains("hasperm.output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasperm.output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
return ".hasperm" + section;
}
for(int count = 0; cf.getKeys(false).size() > count; count++){
if (cf.contains("hasperm" + count) && cf.contains("hasperm" + count + ".perm")) {
outputValue = true;
//outputValue will default to true
if (cf.contains("hasperm" + count + ".output")) {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasperm" + count + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
String section = hasSection(Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
return ".hasperm" + count + section;
}
}
}
}
return "";
}
@SuppressWarnings("deprecation")
@ -462,7 +441,7 @@ public class ItemCreation {
}
}
}
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(plugin.legacy.isLegacy()){
if (cont.getDurability() != 0 && !cont.getType().toString().equals("SKULL_ITEM")) {
file.set("panels." + panelName + ".item." + i + ".ID", cont.getDurability());
}
@ -480,168 +459,37 @@ 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("=")) {
file.set("panels." + panelName + ".item." + i + ".material", plugin.getHeads.playerHeadString());
SkullMeta meta = (SkullMeta) cont.getItemMeta();
if (plugin.customHeads.getHeadBase64(cont) != null && !plugin.legacy.isLegacy()) {
//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());
}
}
}
try {
BannerMeta bannerMeta = (BannerMeta) cont.getItemMeta();
List<String> dyePattern = new ArrayList<>();
for(Pattern pattern : bannerMeta.getPatterns()) { //sublist to skip first value
dyePattern.add(pattern.getColor() + "," + pattern.getPattern());
dyePattern.add(pattern.getColor().toString() + "," + pattern.getPattern().toString());
}
file.set("panels." + panelName + ".item." + i + ".banner", dyePattern);
}catch(Exception ignore){
//not a banner
file.set("panels." + panelName + ".item." + i + ".banner", null);
}
try {
//potion legacy PotionData or current PotionType
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
if(plugin.legacyPotion.retrievePotionData(cont) != null) {
file.set("panels." + panelName + ".item." + i + ".potion", plugin.legacyPotion.retrievePotionData(cont));
}
}else{
PotionMeta potionMeta = (PotionMeta) cont.getItemMeta();
assert potionMeta != null;
String potionType = potionMeta.getBasePotionType().toString(); // Gets the potion type as a string rather than bukkit type
file.set("panels." + panelName + ".item." + i + ".potion", potionType);
}
}catch(Exception ignore){
//not a banner
file.set("panels." + panelName + ".item." + i + ".potion", null);
}
file.set("panels." + panelName + ".item." + i + ".stack", cont.getAmount());
if(!cont.getEnchantments().isEmpty()){
Map<Enchantment, Integer> enchantments = cont.getEnchantments();
List<String> newEnchantments = new ArrayList<>();
for(Enchantment enchantment : enchantments.keySet()){
newEnchantments.add(enchantment.getKey().getKey() + " " + enchantments.get(enchantment));
}
file.set("panels." + panelName + ".item." + i + ".enchanted", newEnchantments);
file.set("panels." + panelName + ".item." + i + ".enchanted", "true");
}
file.set("panels." + panelName + ".item." + i + ".name", Objects.requireNonNull(cont.getItemMeta()).getDisplayName());
file.set("panels." + panelName + ".item." + i + ".lore", Objects.requireNonNull(cont.getItemMeta()).getLore());
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
file.set("panels." + panelName + ".item." + i + ".customdata", Objects.requireNonNull(cont.getItemMeta()).getCustomModelData());
}
}catch(Exception n){
//skip over an item that spits an error
}
}
return file;
}
/*
The ItemStack 'one' will be used, if it doesn't have a lore for example, it won't check to see if the other does have one
The isIdentical() function will check for the following
Material, Name, Lore, Enchanted, Potion
*/
@SuppressWarnings("deprecation")
public boolean isIdentical(ItemStack one, ItemStack two, Boolean nbtCheck){
//check material
if (one.getType() != two.getType()) {
return false;
}
if(one.hasItemMeta() != two.hasItemMeta()){
return false;
}
//check for name
try {
if (!one.getItemMeta().getDisplayName().equals(two.getItemMeta().getDisplayName())) {
if(one.getItemMeta().hasDisplayName()) {
return false;
}
}
}catch(Exception ignore){}
//check for ID 1.12.2 and below
try {
if (plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12) &&
(one.getDurability() != two.getDurability())) {
return false;
}
}catch(Exception ignore){}
//check for lore
try {
if (!one.getItemMeta().getLore().equals(two.getItemMeta().getLore())) {
if(one.getItemMeta().hasLore()) {
return false;
}
}
}catch(Exception ignore){}
//check for custom model data
try {
if (plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
if (one.getItemMeta().getCustomModelData() != (two.getItemMeta().getCustomModelData())) {
if(one.getItemMeta().hasCustomModelData()) {
return false;
}
}
}
}catch(Exception ignore){}
//check for nbt
if(nbtCheck) {
try {
if (!plugin.nbt.hasSameNBT(one, two)) {
return false;
}
} catch (Exception ignore) {}
}
//check for damage
try {
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
if(one.getDurability() != two.getDurability()) {
return false;
}
}else {
Damageable tempOne = (Damageable) one.getItemMeta();
Damageable tempTwo = (Damageable) two.getItemMeta();
if(tempOne.getDamage() != tempTwo.getDamage()){
return false;
}
}
} catch (Exception ignore) {}
//check for potions
try {
//choose between legacy PotionData (pre 1.20.5) or PotionType
if(plugin.legacy.MAJOR_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_19) ||
(plugin.legacy.MAJOR_VERSION == MinecraftVersions.v1_20 && plugin.legacy.MINOR_VERSION <= 4)){
String potionOne = plugin.legacyPotion.retrievePotionData(one);
String potionTwo = plugin.legacyPotion.retrievePotionData(two);
if(!potionOne.equals(potionTwo)){
return false;
}
}else{
//post 1.20.5 compare
PotionMeta meta1 = (PotionMeta) one.getItemMeta();
PotionMeta meta2 = (PotionMeta) two.getItemMeta();
if (meta1.getBasePotionType().toString().compareTo(meta2.getBasePotionType().toString()) != 0){
return false;
}
}
}catch(Exception ignore){}
//check for enchantments
if(one.getEnchantments() == two.getEnchantments()){
if(!one.getEnchantments().isEmpty()) {
return false;
}
}
return true;
}
private boolean isTrimMaterial(String material){
List<String> availableMaterial = Arrays.asList("AMETHYST",
"COPPER", "DIAMOND", "EMERALD", "GOLD", "IRON","LAPIS", "NETHERITE", "QUARTZ", "REDSTONE");
return availableMaterial.contains(material.toUpperCase());
}
private boolean isTrimPattern(String pattern){
List<String> availablePattern = Arrays.asList("COAST",
"DUNE", "EYE", "HOST", "RAISER", "RIB","SENTRY", "SHAPER", "SILENCE", "SNOUT", "SPIRE", "TIDE","VEX", "WARD", "WAYFINDER", "WILD");
return availablePattern.contains(pattern.toUpperCase());
}
private boolean isArmor(ItemStack stack){
return EnchantmentTarget.ARMOR.includes(stack);
}
}

View File

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

View File

@ -0,0 +1,577 @@
package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class OpenEditorGuis {
CommandPanels plugin;
public OpenEditorGuis(CommandPanels pl) {
plugin = pl;
}
public void openEditorGui(Player p, int pageChange) {
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
ArrayList<String> panelNames = new ArrayList<>(); //all panels from ALL files (panel names)
ArrayList<String> panelTitles = new ArrayList<>(); //all panels from ALL files (panel titles)
ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials)
try {
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
if (!plugin.checkPanels(temp)) {
continue;
}
for (String s : Objects.requireNonNull(temp.getConfigurationSection("panels")).getKeys(false)) {
key = s;
panelNames.add(plugin.papi( key));
panelTitles.add(plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))));
if (temp.contains("panels." + key + ".open-with-item.material")) {
panelItems.add(plugin.itemCreate.makeItemFromConfig(temp.getConfigurationSection("panels." + key + ".open-with-item"), p, false, true, true));
} else {
panelItems.add(new ItemStack(Material.PAPER));
}
}
}
} catch (Exception fail) {
//could not fetch all panel names (probably no panels exist)
plugin.debug(fail);
return;
}
int pageNumber = 1;
if (p.getOpenInventory().getTitle().equals("Command Panels Editor")) {
pageNumber = Integer.parseInt(ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(p.getOpenInventory().getItem(49)).getItemMeta()).getDisplayName()).replace("Page ", ""));
}
//will add the difference
pageNumber = pageNumber + pageChange;
if (pageNumber <= 0) {
//double check page number IS NOT under 1
pageNumber = 1;
}
//get amount of pages total
int pagesAmount = (int) Math.ceil(panelNames.size() / 45.0);
//make all the bottom bar items
ItemStack temp;
temp = new ItemStack(Material.SLIME_BALL, 1);
plugin.setName(temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true, true);
i.setItem(49, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Exit Menu", null, p, true, true, true);
i.setItem(45, temp);
temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList();
lore.add(ChatColor.GRAY + "- Click on a panel to edit items.");
lore.add(ChatColor.GRAY + "- Right click on a panel to edit settings.");
lore.add(ChatColor.GRAY + "- To edit an item in a panel, shift click");
lore.add(ChatColor.GRAY + " on the item of choice.");
lore.add(ChatColor.GRAY + "- When entering a value,");
lore.add(ChatColor.GRAY + " type 'remove' to set a");
lore.add(ChatColor.GRAY + " value to default, and use");
lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel.");
plugin.setName(temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true, true);
i.setItem(53, temp);
if (pageNumber != 1) {
//only show previous page button if number is not one
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Previous Page", null, p, true, true, true);
i.setItem(48, temp);
}
if (pageNumber < pagesAmount) {
//if page number is under pages amount
temp = new ItemStack(Material.PAPER, 1);
plugin.setName(temp, ChatColor.WHITE + "Next Page", null, p, true, true, true);
i.setItem(50, temp);
}
int count = 0;
int slot = 0;
lore.clear();
for (String panelName : panelNames) {
//count is +1 because count starts at 0 not 1
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
temp = panelItems.get(count);
plugin.setName(temp, ChatColor.WHITE + panelName, lore, p, false, true, true);
i.setItem(slot, temp);
slot += 1;
}
count += 1;
}
p.openInventory(i);
}
@SuppressWarnings("deprecation")
public void openPanelSettings(Player p, String panelName, ConfigurationSection cf) {
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Panel Settings: " + panelName));
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.IRON_INGOT, 1);
lore.add(ChatColor.GRAY + "Permission required to open panel");
lore.add(ChatColor.GRAY + "commandpanel.panel.[insert]");
if (cf.contains("perm")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("perm"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Permission", lore, p, true, true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Title of the Panel");
if (cf.contains("title")) {
lore.add(ChatColor.WHITE + "------------------");
lore.add(ChatColor.WHITE + cf.getString("title"));
}
plugin.setName(temp, ChatColor.WHITE + "Panel Title", lore, p, true, true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.JUKEBOX, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Sound when opening panel");
if (cf.contains("sound-on-open")) {
lore.add(ChatColor.WHITE + "------------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Sound", lore, p, true, true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.IRON_DOOR, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Custom commands to open panel");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Command", lore, p, true, true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.LAVA_BUCKET, 1);
lore.clear();
lore.add(ChatColor.DARK_RED + "Permanently delete Panel");
plugin.setName(temp, ChatColor.RED + "Delete Panel", lore, p, true, true, true);
i.setItem(21, temp);
temp = new ItemStack(Material.LADDER, 1);
lore.clear();
lore.add(ChatColor.GRAY + "How many rows the panel will be");
lore.add(ChatColor.GRAY + "choose an integer from 1 to 6");
plugin.setName(temp, ChatColor.WHITE + "Panel Rows", lore, p, true, true, true);
i.setItem(23, temp);
temp = new ItemStack(Material.STONE, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Worlds that cannot access the panel");
lore.add(ChatColor.GRAY + "- Left click to add world");
lore.add(ChatColor.GRAY + "- Right click to remove world");
if (cf.contains("disabled-worlds")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("disabled-worlds")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Disabled Worlds", lore, p, true, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.GLASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
if (cf.contains("empty")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("empty")).toUpperCase());
}
plugin.setName(temp, ChatColor.WHITE + "Panel Empty Item", lore, p, true, true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.ANVIL, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when opening");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("commands-on-open")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands-on-open")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Commands", lore, p, true, true, true);
i.setItem(15, temp);
temp = new ItemStack(Material.STRING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Special panel types");
lore.add(ChatColor.GRAY + "- Left click to add panel type");
lore.add(ChatColor.GRAY + "- Right click to remove panel type");
if (cf.contains("panelType")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("panelType")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Panel Types", lore, p, true, true, true);
i.setItem(17, temp);
temp = new ItemStack(Material.ITEM_FRAME, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Code name to open panel");
lore.add(ChatColor.GRAY + "/cp [name]");
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + panelName);
plugin.setName(temp, ChatColor.WHITE + "Panel Name", lore, p, true, true, true);
i.setItem(11, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(18, temp);
//This will create a wall of glass panes, separating panel settings with hotbar settings
if(plugin.legacy.isLegacy()) {
temp = new ItemStack(Material.matchMaterial("STAINED_GLASS_PANE"), 1,(short)15);
}else{
temp = new ItemStack(Material.matchMaterial("BLACK_STAINED_GLASS_PANE"), 1);
}
plugin.setName(temp, ChatColor.WHITE + "", null, p,false, true, true);
for(int d = 27; d < 36; d++){
i.setItem(d, temp);
}
//This is the items for hotbar items (open-with-item)
boolean hotbarItems = false;
if(cf.contains("open-with-item.material")){
hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection("open-with-item"), p, false, true, true);
}else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
}
lore.clear();
lore.add(ChatColor.GRAY + "Current Item");
if (cf.contains("open-with-item.material")) {
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.material")).toUpperCase());
}else{
lore.add(ChatColor.WHITE + "-----------------------");
lore.add(ChatColor.RED + "DISABLED");
}
plugin.setName(temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p, true, true, true);
i.setItem(40, temp);
if(hotbarItems) {
temp = new ItemStack(Material.NAME_TAG, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Name for Hotbar item");
if (cf.contains("open-with-item.name")) {
lore.add(ChatColor.WHITE + "----------");
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.name")));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.FEATHER, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the Hotbar item");
lore.add(ChatColor.GRAY + "- Left click to add lore");
lore.add(ChatColor.GRAY + "- Right click to remove lore");
if (cf.contains("open-with-item.lore")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("open-with-item.lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Lore", lore, p, true, true, true);
i.setItem(36, temp);
temp = new ItemStack(Material.BEDROCK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Hotbar location for the item");
lore.add(ChatColor.GRAY + "choose a number from 0 to 33");
if (cf.contains("open-with-item.stationary")) {
lore.add(ChatColor.WHITE + "-------------------------");
int location = cf.getInt("open-with-item.stationary") + 1;
lore.add(ChatColor.WHITE + String.valueOf(location));
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands from Hotbar Item");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
lore.add(ChatColor.GRAY + "If commands are added, the item will");
lore.add(ChatColor.GRAY + "no longer automatically open the panel");
if (cf.contains("open-with-item.commands")) {
lore.add(ChatColor.WHITE + "-------------------------------");
int count = 1;
for (String tempLore : cf.getStringList("open-with-item.commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true,true);
i.setItem(44, temp);
}
p.openInventory(i);
}
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
public void openItemSettings(Player p, String panelName, ConfigurationSection cf, String section) {
Inventory i = Bukkit.createInventory(null, 36, ChatColor.stripColor("Item Settings: " + panelName));
List<String> lore = new ArrayList();
ItemStack temp;
//remove if the player already had a string from previously
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
plugin.editorInputStrings.remove(o);
o = o - 1;
}
}
//make all the items
temp = new ItemStack(Material.NAME_TAG, 1);
lore.add(ChatColor.GRAY + "Display name of the item in the Panel");
if (cf.contains("name")) {
if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("name"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Name", lore, p, true, true, true);
i.setItem(1, temp);
temp = new ItemStack(Material.ANVIL, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Execute commands when item is clicked");
lore.add(ChatColor.GRAY + "- Left click to add command");
lore.add(ChatColor.GRAY + "- Right click to remove command");
if (cf.contains("commands")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("commands")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Commands", lore, p, true, true, true);
i.setItem(3, temp);
temp = new ItemStack(Material.ENCHANTED_BOOK, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
if (cf.contains("enchanted")) {
if (!Objects.equals(cf.getString("name"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("enchanted"));
}
} else {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + "false");
}
plugin.setName(temp, ChatColor.WHITE + "Item Enchantment", lore, p, true, true, true);
i.setItem(5, temp);
temp = new ItemStack(Material.POTION, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display potion effect of the item in the Panel");
if (cf.contains("potion")) {
if (!Objects.equals(cf.getString("potion"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("potion"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Potion Effect", lore, p, true, true, true);
i.setItem(7, temp);
temp = new ItemStack(Material.PAPER, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Duplicate item visuals in other slots");
lore.add(ChatColor.GRAY + "- Left click to add duplicate item/s");
lore.add(ChatColor.GRAY + "- Right click to remove duplicate item/s");
if (cf.contains("duplicate")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getString("duplicate").split(",")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true, true);
i.setItem(13, temp);
temp = new ItemStack(Material.FEATHER, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Display a lore under the item name");
lore.add(ChatColor.GRAY + "- Left click to add lore line");
lore.add(ChatColor.GRAY + "- Right click to remove lore line");
if (cf.contains("lore")) {
lore.add(ChatColor.WHITE + "-----------------------------");
int count = 1;
for (String tempLore : cf.getStringList("lore")) {
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
count += 1;
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Lores", lore, p, true, true, true);
i.setItem(19, temp);
temp = new ItemStack(Material.ITEM_FRAME, 2);
lore.clear();
lore.add(ChatColor.GRAY + "How many of the item will be stacked");
if (cf.contains("stack")) {
if (!Objects.equals(cf.getString("stack"), "")) {
try {
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("stack"))));
} catch (Exception ignored) {
}
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("stack"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true, true);
i.setItem(21, temp);
if(!plugin.legacy.isLegacy()) {
temp = new ItemStack(Material.PAINTING, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
if (cf.contains("customdata")) {
if (!Objects.equals(cf.getString("customdata"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("customdata"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true, true);
i.setItem(23, temp);
}
/*show the compass that opens the viewer for the sections..
it will only show the sections immidiatly under the other, so
if there is a hasperm inside another hasperm, it will not appear
until the other hasperm is opened.
*/
temp = new ItemStack(Material.COMPASS, 1);
lore.clear();
lore.add(ChatColor.GRAY + "View the items different");
lore.add(ChatColor.GRAY + "Sections and add complex values.");
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + section);
plugin.setName(temp, ChatColor.WHITE + "Item Sections", lore, p, true, true, true);
i.setItem(31, temp);
temp = new ItemStack(Material.LEATHER_HELMET, 1);
lore.clear();
lore.add(ChatColor.GRAY + "Choose a colour for the armor");
lore.add(ChatColor.GRAY + "use r,g,b or a spigot API color");
if (cf.contains("leatherarmor")) {
if (!Objects.equals(cf.getString("leatherarmor"), "")) {
lore.add(ChatColor.WHITE + "--------------------------------");
lore.add(ChatColor.WHITE + cf.getString("leatherarmor"));
}
}
plugin.setName(temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true, true);
i.setItem(25, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(27, temp);
temp = plugin.itemCreate.makeItemFromConfig(cf,p,false,false, true);
lore.clear();
lore.add(ChatColor.GRAY + "Click to set custom material");
lore.add(ChatColor.GRAY + "typically for custom heads");
plugin.setName(temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true, true);
i.setItem(35, temp);
p.openInventory(i);
}
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
public void openItemSections(Player p, String panelName, ConfigurationSection cf, String itemSection) {
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Item Sections: " + panelName));
ItemStack temp;
int slot = 0;
for(String section : cf.getKeys(false)){
//get list of item sections
if(slot > 35){
break;
}
if(section.contains("hasperm") || section.contains("hasvalue") || section.contains("hasgreater")){
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Left click to open item");
lore.add(ChatColor.GRAY + "Right click to change below settings");
if(cf.contains(section + ".output")) {
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + cf.getString(section + ".output"));
}else{
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + "true");
}
if(cf.contains(section + ".perm")) {
lore.add(ChatColor.WHITE + "Perm: " + ChatColor.GRAY + cf.getString(section + ".perm"));
}
if(cf.contains(section + ".value")) {
lore.add(ChatColor.WHITE + "Value: " + ChatColor.GRAY + cf.getString(section + ".value"));
}
if(cf.contains(section + ".compare")) {
lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
}
temp = plugin.itemCreate.makeItemFromConfig(cf.getConfigurationSection(section),p,false,false, true);
plugin.setName(temp, ChatColor.AQUA + section, lore, p,false, true, true);
i.setItem(slot, temp);
slot++;
}
}
temp = new ItemStack(Material.REDSTONE, 1);
plugin.setName(temp, ChatColor.WHITE + "Remove Section", null, p, true, true, true);
i.setItem(38, temp);
temp = new ItemStack(Material.SLIME_BALL, 1);
plugin.setName(temp, ChatColor.WHITE + "Add Section", null, p, true, true, true);
i.setItem(42, temp);
temp = new ItemStack(Material.BARRIER, 1);
plugin.setName(temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(36, temp);
temp = new ItemStack(Material.BOOK, 1);
List<String> lore = new ArrayList<>();
lore.add(ChatColor.GRAY + "Section Types:");
lore.add(ChatColor.GRAY + "- hasperm");
lore.add(ChatColor.GRAY + "- hasvalue");
lore.add(ChatColor.GRAY + "- hasgreater");
plugin.setName(temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true, true);
i.setItem(44, temp);
p.openInventory(i);
}
}

View File

@ -1,34 +0,0 @@
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

@ -1,17 +0,0 @@
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

@ -1,185 +0,0 @@
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

@ -1,118 +0,0 @@
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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,37 +5,33 @@ 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 Commandpanelsdebug implements CommandExecutor {
CommandPanels plugin;
public Commandpanelsdebug(CommandPanels pl) { this.plugin = pl; }
@Override
@EventHandler
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("commandpanel.debug")) {
if (args.length == 0) {
//command /cpd
if(!(sender instanceof Player)) {
plugin.debug.consoleDebug = !plugin.debug.consoleDebug;
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Global Debug Mode: " + plugin.debug.consoleDebug));
return true;
}
Player p = (Player)sender;
if(plugin.debug.isEnabled(p)){
plugin.debug.debugSet.remove(p);
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Disabled!"));
if (label.equalsIgnoreCase("cpd") || label.equalsIgnoreCase("commandpaneldebug") || label.equalsIgnoreCase("cpaneld")) {
if (sender.hasPermission("commandpanel.debug")) {
if (args.length == 0) {
//command /cpd
plugin.debug = !plugin.debug;
if(plugin.debug){
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Debug Mode Enabled!"));
}else{
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.GREEN + "Debug Mode Disabled!"));
}
}else{
plugin.debug.debugSet.add(p);
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Personal Debug Mode Enabled!"));
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpd"));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpd"));
sender.sendMessage(plugin.papi(plugin.tag + plugin.config.getString("config.format.perms")));
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
return true;
}
sender.sendMessage(plugin.papi(plugin.tag + ChatColor.RED + "Usage: /cpd"));
return true;
}
}

View File

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

View File

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

View File

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

View File

@ -1,151 +0,0 @@
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

@ -1,59 +0,0 @@
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.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class CommandTagEvent extends Event {
public final Player p;
public final Panel panel;
public String[] raw;
public String[] args;
public String name;
public PanelPosition pos;
public boolean commandTagUsed = false;
public CommandTagEvent(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 = 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");
}
}
public void commandTagUsed(){
commandTagUsed = true;
}
private static final HandlerList HANDLERS = new HandlerList();
public HandlerList getHandlers() {
return HANDLERS;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
}

View File

@ -1,57 +0,0 @@
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

@ -1,7 +0,0 @@
package me.rockyhawk.commandpanels.commandtags;
public enum PaywallOutput {
Blocked,
Passed,
NotApplicable
}

View File

@ -1,44 +0,0 @@
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

@ -1,50 +0,0 @@
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

@ -1,49 +0,0 @@
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

@ -1,77 +0,0 @@
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

@ -1,111 +0,0 @@
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

@ -1,21 +0,0 @@
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

@ -1,128 +0,0 @@
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,75 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.other;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class DataTags implements Listener {
CommandPanels plugin;
public DataTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("set-data=")){
e.commandTagUsed();
if(e.args.length == 3){
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(),
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.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(),
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.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(),
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(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 == 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(),plugin.tex.placeholdersNoColour(e.panel,e.pos,e.p,e.args[0]));
}
}
}

View File

@ -1,75 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.other;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class PlaceholderTags implements Listener {
CommandPanels plugin;
public PlaceholderTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("placeholder=")) {
e.commandTagUsed();
//placeholder is placeholder= [%placeholder%:value]
String cmd;
cmd = String.join(" ",e.raw);
if(e.panel == null){
return;
}
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(']'));
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel,e.pos,e.p,contents.substring(contents.indexOf(':')+1));
e.panel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1;
}
}
return;
}
if(e.name.equalsIgnoreCase("add-placeholder=")) {
e.commandTagUsed();
//this will only run the placeholder command if the placeholder doesn't yet exist in the panel
String cmd;
cmd = String.join(" ",e.raw);
if (e.panel == null) {
return;
}
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(']'));
//do not change the placeholder
String placeholder = contents.substring(0, contents.indexOf(':'));
//only convert placeholders for the value
if (!e.panel.placeholders.keys.containsKey(placeholder)) {
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel,e.pos, e.p, contents.substring(contents.indexOf(':') + 1));
e.panel.placeholders.addPlaceholder(placeholder, value);
}
i = i + contents.length() - 1;
}
}
}
}
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,161 +0,0 @@
package me.rockyhawk.commandpanels.commandtags.tags.other;
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.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;
import org.bukkit.scheduler.BukkitRunnable;
public class SpecialTags implements Listener {
CommandPanels plugin;
public SpecialTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("open=")) {
e.commandTagUsed();
//if player uses open= it will open the panel, with the option to add custom placeholders
String panelName = e.args[0];
String cmd = String.join(" ",e.args).replace(e.args[0] + " ","").trim();
Panel openPanel = null;
PanelPosition openPosition = e.pos;
for(Panel pane : plugin.panelList){
if(pane.getName().equals(panelName)){
openPanel = pane.copy();
}
}
if(openPanel == null){
return;
}
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(']'));
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel,e.pos,e.p,contents.substring(contents.indexOf(':')+1));
openPanel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1;
}else if(cm[i].equals('{')){
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf('}'));
openPosition = PanelPosition.valueOf(contents);
i = i+contents.length()-1;
}
}
openPanel.open(e.p,openPosition);
return;
}
if(e.name.equalsIgnoreCase("close=")) {
e.commandTagUsed();
//closes specific panel positions
PanelPosition position = PanelPosition.valueOf(e.args[0]);
if(position == PanelPosition.Middle && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Middle);
}else if(position == PanelPosition.Bottom && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
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.commandRunner.runCommand(e.panel,e.pos,e.p,"cpc");
}
return;
}
if(e.name.equalsIgnoreCase("title=")) {
e.commandTagUsed();
//added into the 1.11 API
//will send a title to the player title= <player> <fadeIn> <stay> <fadeOut>
if(e.args.length >= 5){
Player p = Bukkit.getPlayer(e.args[0]);
StringBuilder message = new StringBuilder();
for(int i = 4; i < e.args.length; i++){
message.append(e.args[i]).append(" ");
}
message.deleteCharAt(message.length()-1);
String title;
String subtitle = "";
if(message.toString().contains("/n/")) {
title = plugin.tex.placeholders(e.panel, e.pos, e.p, message.toString().split("/n/")[0]);
subtitle = plugin.tex.placeholders(e.panel, e.pos, e.p, message.toString().split("/n/")[1]);
}else{
title = plugin.tex.placeholders(e.panel, e.pos, e.p, message.toString().trim());
}
try{
p.sendTitle(title, subtitle, Integer.parseInt(e.args[1]), Integer.parseInt(e.args[2]), Integer.parseInt(e.args[3]));
}catch(Exception ex) {
plugin.debug(ex, e.p);
}
}
return;
}
if(e.name.equalsIgnoreCase("teleport=")) {
e.commandTagUsed();
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]);
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;
}
if(e.name.equalsIgnoreCase("delay=")) {
e.commandTagUsed();
//if player uses op= it will perform command as op
final int delayTicks = Integer.parseInt(e.args[0]);
String finalCommand = String.join(" ",e.args).replaceFirst(e.args[0],"").trim();
new BukkitRunnable() {
@Override
public void run() {
try {
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);
this.cancel();
}
this.cancel();
}
}.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,164 +0,0 @@
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.MiniMessageUtils;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class BasicTags implements Listener {
CommandPanels plugin;
public BasicTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("cpc") || e.name.equalsIgnoreCase("commandpanelclose")){
e.commandTagUsed();
//return if no panel open
if(!plugin.openPanels.hasPanelOpen(e.p.getName(),PanelPosition.Top)){
return;
}
//unclosable panels are at the Top only
if(plugin.openPanels.getOpenPanel(e.p.getName(),PanelPosition.Top).getConfig().contains("panelType")){
if(plugin.openPanels.getOpenPanel(e.p.getName(),PanelPosition.Top).getConfig().getStringList("panelType").contains("unclosable")){
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Top);
plugin.openPanels.skipPanelClose.add(e.p.getName());
}
}
//this will close the current inventory
e.p.closeInventory();
plugin.openPanels.skipPanelClose.remove(e.p.getName());
return;
}
if(e.name.equalsIgnoreCase("refresh")) {
e.commandTagUsed();
if(plugin.openPanels.hasPanelOpen(e.p.getName(),e.pos)) {
plugin.createGUI.openGui(e.panel, e.p, e.pos, PanelOpenType.Refresh, 0);
}
if(plugin.inventorySaver.hasNormalInventory(e.p)){
plugin.hotbar.updateHotbarItems(e.p);
}
return;
}
if(e.name.equalsIgnoreCase("console=")) {
e.commandTagUsed();
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), String.join(" ",e.args));
return;
}
if(e.name.equalsIgnoreCase("send=")) {
e.commandTagUsed();
e.p.chat(String.join(" ",e.args));
return;
}
if(e.name.equalsIgnoreCase("sudo=")) {
e.commandTagUsed();
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
boolean isop = e.p.isOp();
try {
e.p.setOp(true);
Bukkit.dispatchCommand(e.p,String.join(" ",e.args));
e.p.setOp(isop);
} catch (Exception exc) {
e.p.setOp(isop);
plugin.debug(exc,e.p);
e.p.sendMessage(plugin.tag + plugin.tex.colour( plugin.config.getString("config.format.error") + " op=: Error in op command!"));
}
return;
}
if(e.name.equalsIgnoreCase("sound=")) {
e.commandTagUsed();
try {
if(e.args.length == 3){
//volume (0.0 to 1.0), pitch (0.5 to 2.0)
e.p.playSound(e.p.getLocation(), Sound.valueOf(e.args[0]), Float.parseFloat(e.args[1]), Float.parseFloat(e.args[2]));
}else{
e.p.playSound(e.p.getLocation(), Sound.valueOf(e.args[0]), 1F, 1F);
}
} catch (Exception s) {
plugin.debug(s, e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.args[0]);
}
return;
}
if(e.name.equalsIgnoreCase("stopsound=")) {
e.commandTagUsed();
try {
e.p.stopSound(Sound.valueOf(e.args[0]));
} catch (Exception ss) {
plugin.debug(ss, e.p);
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.args[0]);
}
return;
}
if(e.name.equalsIgnoreCase("event=")) {
e.commandTagUsed();
PanelCommandEvent commandEvent = new PanelCommandEvent(e.p, String.join(" ",e.args), e.panel);
Bukkit.getPluginManager().callEvent(commandEvent);
return;
}
if(e.name.equalsIgnoreCase("minimessage=")){
e.commandTagUsed();
//do mini message if conditions are met
if (plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)) {
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
Component parsedText = plugin.miniMessage.doMiniMessage(String.join(" ", e.args));
player.sendMessage(parsedText);
} else {
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
}
}
}
}

View File

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

View File

@ -1,125 +0,0 @@
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;
public ItemTags(CommandPanels pl) {
this.plugin = pl;
}
@EventHandler
public void commandTag(CommandTagEvent e){
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;
}
if(e.name.equalsIgnoreCase("setitem=")){
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, false);
PanelPosition position = PanelPosition.valueOf(e.args[2]);
if(position == PanelPosition.Top) {
e.p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(e.args[1]), s);
}else if(position == PanelPosition.Middle) {
e.p.getInventory().setItem(Integer.parseInt(e.args[1])+9, s);
}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

@ -1,76 +1,68 @@
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;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
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)
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])) {
if(sender instanceof Player && args.length == 1){
Player p = ((Player) sender).getPlayer();
if(label.equalsIgnoreCase("cp") || label.equalsIgnoreCase("cpanel") || label.equalsIgnoreCase("commandpanel")){
ArrayList<String> apanels = new ArrayList<String>(); //all panels
String tpanels; //tpanels is the temp to check through the files
for(String fileName : plugin.panelFiles) { //will loop through all the files in folder
try {
YamlConfiguration temp = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName));
String key;
tpanels = "";
if (!plugin.checkPanels(temp)) {
continue;
}
for (Iterator var10 = temp.getConfigurationSection("panels").getKeys(false).iterator(); var10.hasNext(); tpanels = tpanels + key + " ") {
key = (String) var10.next();
if (!key.startsWith(args[0])) {
//this will narrow down the panels to what the user types
continue;
}
if (sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
if (panel.getConfig().contains("panelType")) {
if (panel.getConfig().getStringList("panelType").contains("nocommand")) {
//do not allow command with nocommand
if (sender.hasPermission("commandpanel.panel." + temp.getString("panels." + key + ".perm"))) {
if(temp.contains("panels." + key + ".panelType")) {
if (temp.getStringList("panels." + key + ".panelType").contains("nocommand")) {
//do not allow command with noCommand
continue;
}
}
if (plugin.panelPerms.isPanelWorldEnabled(p, panel.getConfig())) {
apanels.add(panel.getName());
if (temp.contains("panels." + key + ".disabled-worlds")) {
List<String> disabledWorlds = temp.getStringList("panels." + key + ".disabled-worlds");
if (!disabledWorlds.contains(p.getWorld().getName())) {
apanels.add(key);
}
} else {
apanels.add(key);
}
}
} catch (Exception skip) {
//ignore panel
}
}catch(Exception skip){
//ignore panel
}
return apanels;
//if file contains opened panel then start
}
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 apanels;
}
}
return null;
}
}

View File

@ -1,70 +0,0 @@
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 java.util.*;
public class DataTabComplete implements TabCompleter {
CommandPanels plugin;
public DataTabComplete(CommandPanels pl) { this.plugin = pl; }
@Override
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){
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){
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);
}
}
}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 {
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 new ArrayList<>();
}
}
return output;
}
return null;
}
}

View File

@ -1,29 +0,0 @@
package me.rockyhawk.commandpanels.completetabs;
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 ImportTabComplete implements TabCompleter {
CommandPanels plugin;
public ImportTabComplete(CommandPanels pl) { this.plugin = pl; }
@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
if(sender.hasPermission("commandpanel.import")) {
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

@ -1,35 +0,0 @@
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

@ -0,0 +1,52 @@
package me.rockyhawk.commandpanels.customcommands;
import me.rockyhawk.commandpanels.CommandPanels;
import java.util.ArrayList;
public class CommandPlaceholderLoader {
CommandPanels plugin;
public CommandPlaceholderLoader(CommandPanels pl) {
this.plugin = pl;
}
ArrayList<String[]> pendingPlaceholders = new ArrayList<>(); //should read: panelName, playerName, placeholder, argument
//this will be used with the cpPlaceholder void, when the panel is closed it will remove the placeholder
public void addCCP(String panelName, String playerName, String placeholder, String argument){
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
}
//will remove all pending placeholders for a certain player & panel
public void removeCCP(String panelName, String playerName){
for(int i = 0; i < pendingPlaceholders.size(); i++){
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0])){
pendingPlaceholders.remove(i);
i--;
}
}
}
//will return placeholder,argument
public ArrayList<String[]> getCCP(String playerName){
ArrayList<String[]> returnPlaceholders = new ArrayList<>();
for(String[] temp : pendingPlaceholders){
if(temp[1].equals(playerName)){
returnPlaceholders.add(new String[]{temp[2],temp[3]});
}
}
return returnPlaceholders;
}
//change a placeholder for a panel
public void editCCP(String panelName, String playerName, String placeholder, String argument){
for(int i = 0; i < pendingPlaceholders.size(); i++){
if(playerName.equals(pendingPlaceholders.get(i)[1]) && panelName.equals(pendingPlaceholders.get(i)[0]) && placeholder.equals(pendingPlaceholders.get(i)[2])){
pendingPlaceholders.remove(i);
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
return;
}
}
//if it reaches here it has not found the placeholder, add it manually
pendingPlaceholders.add(new String[]{panelName,playerName,placeholder,argument});
}
}

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