forked from Upstream/CommandPanels
3.18.0.0
This commit is contained in:
parent
b1c285149a
commit
5fa746950b
@ -6,6 +6,11 @@
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</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="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
|
9
.idea/libraries/CoinsAPI_1_8_9.xml
Normal file
9
.idea/libraries/CoinsAPI_1_8_9.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="CoinsAPI 1.8.9">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../../Tools/Build Tools/Jar Libraries/CoinsAPI 1.8.9.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_kyori_adventure_api_4_11_0.xml
Normal file
13
.idea/libraries/Maven__net_kyori_adventure_api_4_11_0.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: net.kyori:adventure-api:4.11.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-api/4.11.0/adventure-api-4.11.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_kyori_adventure_key_4_11_0.xml
Normal file
13
.idea/libraries/Maven__net_kyori_adventure_key_4_11_0.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: net.kyori:adventure-key:4.11.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-key/4.11.0/adventure-key-4.11.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: net.kyori:adventure-text-minimessage:4.11.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/adventure-text-minimessage/4.11.0/adventure-text-minimessage-4.11.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__net_kyori_examination_api_1_3_0.xml
Normal file
13
.idea/libraries/Maven__net_kyori_examination_api_1_3_0.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: net.kyori:examination-api:1.3.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-api/1.3.0/examination-api-1.3.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-api/1.3.0/examination-api-1.3.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-api/1.3.0/examination-api-1.3.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: net.kyori:examination-string:1.3.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-string/1.3.0/examination-string-1.3.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-string/1.3.0/examination-string-1.3.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/net/kyori/examination-string/1.3.0/examination-string-1.3.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
13
.idea/libraries/Maven__org_jetbrains_annotations_23_0_0.xml
Normal file
13
.idea/libraries/Maven__org_jetbrains_annotations_23_0_0.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<component name="libraryTable">
|
||||
<library name="Maven: org.jetbrains:annotations:23.0.0">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/23.0.0/annotations-23.0.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
@ -1,7 +1,7 @@
|
||||
<component name="libraryTable">
|
||||
<library name="spigot-api-1.18.1-R0.1-SNAPSHOT">
|
||||
<library name="spigot-api-1.19-R0.1-SNAPSHOT">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.18.1/bundler/libraries/spigot-api-1.18.1-R0.1-SNAPSHOT.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/../../../Intellij Plugin Testers/Plugin Tester 1.18.1/bundler/libraries/spigot-api-1.19-R0.1-SNAPSHOT.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
@ -6,6 +6,8 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resource" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resource_editor" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resource_example" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
@ -19,9 +21,16 @@
|
||||
<orderEntry type="library" name="PlaceholderAPI-2.10.9" level="project" />
|
||||
<orderEntry type="library" name="MMOItems-6.6.1" level="project" />
|
||||
<orderEntry type="library" name="MythicLib-1.1.3" level="project" />
|
||||
<orderEntry type="library" name="spigot-api-1.18.1-R0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="spigot" level="project" />
|
||||
<orderEntry type="library" name="spigot-1.13.2" level="project" />
|
||||
<orderEntry type="library" name="spigot" level="project" />
|
||||
<orderEntry type="library" name="CoinsAPI 1.8.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.kyori:adventure-text-minimessage:4.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.kyori:adventure-api:4.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.kyori:adventure-key:4.11.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.kyori:examination-api:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.kyori:examination-string:1.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:23.0.0" level="project" />
|
||||
<orderEntry type="library" name="spigot-api-1.19-R0.1-SNAPSHOT" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -1,4 +1,4 @@
|
||||
version: 3.17.5.0
|
||||
version: 3.18.0.0
|
||||
main: me.rockyhawk.commandpanels.CommandPanels
|
||||
name: CommandPanels
|
||||
author: RockyHawk
|
||||
@ -36,7 +36,7 @@ commands:
|
||||
aliases: [cpv, cpanelv]
|
||||
commandpaneledit:
|
||||
description: Edit panels ingame.
|
||||
usage: /commandpaneledit [panel]
|
||||
usage: /commandpaneledit <panel>
|
||||
aliases: [cpe, cpanele]
|
||||
commandpanellist:
|
||||
description: Lists the currently loaded panels.
|
||||
|
38
resource_editor/BottomSettings.yml
Normal file
38
resource_editor/BottomSettings.yml
Normal file
@ -0,0 +1,38 @@
|
||||
panels:
|
||||
BottomSettings:
|
||||
perm: default
|
||||
rows: 3
|
||||
title: '&8Bottom Settings'
|
||||
panelType:
|
||||
- static
|
||||
pre-load-commands:
|
||||
- event= CommandPanels_EditorOpened
|
||||
commands-on-close:
|
||||
- event= CommandPanels_EditorClosed
|
||||
item:
|
||||
'0':
|
||||
material: BARRIER
|
||||
stack: 1
|
||||
name: '&cExit'
|
||||
commands:
|
||||
- cpc
|
||||
'4':
|
||||
material: CHEST
|
||||
stack: 1
|
||||
name: '&fPanel Settings'
|
||||
commands:
|
||||
- "event= CommandPanels_OpenPanelSettings"
|
||||
'6':
|
||||
material: COOKIE
|
||||
stack: 1
|
||||
name: '&fItem Settings'
|
||||
commands:
|
||||
- "event= CommandPanels_OpenItemSettings"
|
||||
'8':
|
||||
material: COMPASS
|
||||
stack: 1
|
||||
name: '&fItem Sections'
|
||||
lore:
|
||||
- "&cIN PROGRESS"
|
||||
commands:
|
||||
- "event= CommandPanels_OpenItemSections"
|
227
resource_editor/ItemEditMenu.yml
Normal file
227
resource_editor/ItemEditMenu.yml
Normal file
@ -0,0 +1,227 @@
|
||||
panels:
|
||||
ItemEditMenu:
|
||||
perm: default
|
||||
rows: 3
|
||||
title: '&8Item Settings'
|
||||
panelType:
|
||||
- static
|
||||
custom-messages:
|
||||
input-message:
|
||||
- "&e[&bCommand Panels Editor&e]"
|
||||
- "&fEnter your value in the chat bar below."
|
||||
item:
|
||||
'4':
|
||||
material: FLINT_AND_STEEL
|
||||
name: '&fPlayer Input'
|
||||
lore:
|
||||
- "&7Add a player input to your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorItem_player-input
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_iteminput %cp-player-input%"
|
||||
'5':
|
||||
material: NAME_TAG
|
||||
name: '&fItem Name'
|
||||
lore:
|
||||
- "&7Choose a name for your item."
|
||||
commands:
|
||||
- event= CPEditorItem_name
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemname %cp-player-input%"
|
||||
'6':
|
||||
material: ITEM_FRAME
|
||||
name: '&fItem Stack'
|
||||
lore:
|
||||
- "&7Choose a number from 1 to 64."
|
||||
commands:
|
||||
- event= CPEditorItem_stack
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemstack %cp-player-input%"
|
||||
'7':
|
||||
material: ENCHANTED_BOOK
|
||||
name: '&fEnchantments'
|
||||
lore:
|
||||
- "&7Add enchantments to your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [type] [level]"
|
||||
- "&7- edit [line number] [type] [level]"
|
||||
- "&7- insert [line number] [type] [level]"
|
||||
- "&7- remove [line number]"
|
||||
- ""
|
||||
- "&7For example: add KNOCKBACK 3"
|
||||
commands:
|
||||
- event= CPEditorItem_enchanted
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemenchantment %cp-player-input%"
|
||||
'8':
|
||||
material: PAPER
|
||||
name: '&fItem NBT Data'
|
||||
lore:
|
||||
- "&7You can create custom NBT for your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [name] [value]"
|
||||
- "&7- remove [name]"
|
||||
- ""
|
||||
- "&7For example: add example_data this is the value"
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemnbt %cp-player-input%"
|
||||
'0':
|
||||
material: LAVA_BUCKET
|
||||
name: '&cDelete Item'
|
||||
lore:
|
||||
- "&7Enter 'confirm' to delete the item."
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemdelete %cp-player-input%"
|
||||
'9':
|
||||
material: REDSTONE_BLOCK
|
||||
name: '&fEditing Item: %cp-item-slot%'
|
||||
lore:
|
||||
- "&7Click here to change the"
|
||||
- "&7slot number you are editing."
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemslot %cp-player-input%"
|
||||
'18':
|
||||
material: ENDER_CHEST
|
||||
name: '&fMove Item'
|
||||
lore:
|
||||
- "&7Enter a slot to move this item to."
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemmove %cp-player-input%"
|
||||
'1':
|
||||
material: STONE
|
||||
name: '&fItem Material'
|
||||
lore:
|
||||
- "&7Choose a material for your item."
|
||||
commands:
|
||||
- event= CPEditorItem_material
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemmaterial %cp-player-input%"
|
||||
'13':
|
||||
material: COBBLESTONE
|
||||
name: '&fItem ID'
|
||||
lore:
|
||||
- "&7Material ID for Minecraft 1.12 and below."
|
||||
commands:
|
||||
- event= CPEditorItem_id
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemid %cp-player-input%"
|
||||
'14':
|
||||
material: PAINTING
|
||||
name: '&fCustom Model Data'
|
||||
lore:
|
||||
- "&7Enter Custom Model Data for your item."
|
||||
commands:
|
||||
- event= CPEditorItem_customdata
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemmodeldata %cp-player-input%"
|
||||
'15':
|
||||
material: ANVIL
|
||||
name: '&fItem Durability'
|
||||
lore:
|
||||
- "&7Enter a number if you want the item to be damaged."
|
||||
commands:
|
||||
- event= CPEditorItem_damage
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemdurability %cp-player-input%"
|
||||
'16':
|
||||
material: LEATHER_HELMET
|
||||
name: '&fArmour Colour'
|
||||
lore:
|
||||
- "&7Enter a value for your armour to be coloured."
|
||||
commands:
|
||||
- event= CPEditorItem_leatherarmor
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemarmour %cp-player-input%"
|
||||
'17':
|
||||
material: POTION
|
||||
name: '&fPotion Effect'
|
||||
lore:
|
||||
- "&7Choose a potion effect to be applied."
|
||||
commands:
|
||||
- event= CPEditorItem_potion
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itempotion %cp-player-input%"
|
||||
'23':
|
||||
material: FEATHER
|
||||
name: '&fItem Lore'
|
||||
lore:
|
||||
- "&7Add a lore to your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [text]"
|
||||
- "&7- edit [line number] [text]"
|
||||
- "&7- insert [line number] [text]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorItem_lore
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemlore %cp-player-input%"
|
||||
'24':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fItem Commands'
|
||||
lore:
|
||||
- "&7Add commands to your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorItem_commands
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemcommands %cp-player-input%"
|
||||
'25':
|
||||
material: MELON_SEEDS
|
||||
name: '&fItem Duplicates'
|
||||
lore:
|
||||
- "&7Enter slots to duplicate this item to."
|
||||
commands:
|
||||
- event= CPEditorItem_duplicate
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemduplicate %cp-player-input%"
|
||||
'26':
|
||||
material: SLIME_BALL
|
||||
name: '&fItem Types'
|
||||
lore:
|
||||
- "&7Add item types to your item."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [text]"
|
||||
- "&7- edit [line number] [text]"
|
||||
- "&7- insert [line number] [text]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorItem_itemType
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_itemtypes %cp-player-input%"
|
271
resource_editor/PanelEditMenu.yml
Normal file
271
resource_editor/PanelEditMenu.yml
Normal file
@ -0,0 +1,271 @@
|
||||
panels:
|
||||
PanelEditMenu:
|
||||
perm: default
|
||||
rows: 3
|
||||
title: '&8Panel Settings'
|
||||
panelType:
|
||||
- static
|
||||
custom-messages:
|
||||
input-message:
|
||||
- "&e[&bCommand Panels Editor&e]"
|
||||
- "&fEnter your value in the chat bar below."
|
||||
item:
|
||||
'3':
|
||||
material: PUMPKIN_SEEDS
|
||||
name: '&fEmpty Slot Item ID'
|
||||
lore:
|
||||
- "&7Material ID for Minecraft 1.12 and below."
|
||||
commands:
|
||||
- event= CPEditorPanel_emptyID
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelemptyid %cp-player-input%"
|
||||
'4':
|
||||
material: MELON_SEEDS
|
||||
name: '&fEmpty Slot Item'
|
||||
lore:
|
||||
- "&7This item will replace all"
|
||||
- "&7of the empty slots."
|
||||
commands:
|
||||
- event= CPEditorPanel_empty
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelempty %cp-player-input%"
|
||||
'5':
|
||||
material: COBBLESTONE
|
||||
name: '&fEnabled Worlds'
|
||||
lore:
|
||||
- "&7Add Enabled Worlds."
|
||||
- "&7The panel will only open in them."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [world]"
|
||||
- "&7- edit [line number] [world]"
|
||||
- "&7- insert [line number] [world]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_enabled-worlds
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelenabledworlds %cp-player-input%"
|
||||
'6':
|
||||
material: REDSTONE_BLOCK
|
||||
name: '&fDisabled Worlds'
|
||||
lore:
|
||||
- "&7Add Disabled Worlds."
|
||||
- "&7The panel will not open in them."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [world]"
|
||||
- "&7- edit [line number] [world]"
|
||||
- "&7- insert [line number] [world]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_disabled-worlds
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_paneldisabledworlds %cp-player-input%"
|
||||
'7':
|
||||
material: BEACON
|
||||
name: '&fPanel Permission'
|
||||
lore:
|
||||
- "&7Change the permission for your Panel."
|
||||
- "&7Use 'default' to disable this feature."
|
||||
- "&7The permission will be commandpanel.panel.[text]"
|
||||
commands:
|
||||
- event= CPEditorPanel_perm
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelpermission %cp-player-input%"
|
||||
'8':
|
||||
material: NOTE_BLOCK
|
||||
name: '&fPanel Open Sound'
|
||||
lore:
|
||||
- "&7Choose a sound when your panel opens."
|
||||
- "&7Make sure this is all uppercase."
|
||||
commands:
|
||||
- event= CPEditorPanel_sound-on-open
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelopensound %cp-player-input%"
|
||||
'0':
|
||||
material: LAVA_BUCKET
|
||||
name: '&cDelete Panel'
|
||||
lore:
|
||||
- "&7Enter 'confirm' to delete the panel."
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_paneldelete %cp-player-input%"
|
||||
'9':
|
||||
material: NAME_TAG
|
||||
name: '&fPanel Name: %cp-panel-name%'
|
||||
lore:
|
||||
- "&7Choose the name for your panel."
|
||||
commands:
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelname %cp-player-input%"
|
||||
'21':
|
||||
material: FEATHER
|
||||
name: '&fNo Permission Custom Message'
|
||||
lore:
|
||||
- "&7Add a No Permission custom message."
|
||||
commands:
|
||||
- event= CPEditorPanel_custom-messages.perm
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelpermissionmessage %cp-player-input%"
|
||||
'12':
|
||||
material: FEATHER
|
||||
name: '&fMaximum Input Custom Message'
|
||||
lore:
|
||||
- "&7Add a Player Input Maximum custom message."
|
||||
commands:
|
||||
- event= CPEditorPanel_custom-messages.input
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelmaxinputmessage %cp-player-input%"
|
||||
'13':
|
||||
material: FEATHER
|
||||
name: '&fPlayer Input Custom Message'
|
||||
lore:
|
||||
- "&7Add a Player Input custom message."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [text]"
|
||||
- "&7- edit [line number] [text]"
|
||||
- "&7- insert [line number] [text]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_custom-messages.player-input
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelplayerinputmessage %cp-player-input%"
|
||||
'14':
|
||||
material: BOOK
|
||||
name: '&fPanel Title'
|
||||
lore:
|
||||
- "&7Change your panel title."
|
||||
commands:
|
||||
- event= CPEditorPanel_title
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_paneletitle %cp-player-input%"
|
||||
'15':
|
||||
material: LADDER
|
||||
name: '&fPanel Rows'
|
||||
lore:
|
||||
- "&7How many rows the panel should be 1-6."
|
||||
commands:
|
||||
- event= CPEditorPanel_rows
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelrows %cp-player-input%"
|
||||
'16':
|
||||
material: LEVER
|
||||
name: '&fPanel Refresh Delay'
|
||||
lore:
|
||||
- "&7Refresh delay measured in ticks."
|
||||
commands:
|
||||
- event= CPEditorPanel_refresh-delay
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelrefreshdelay %cp-player-input%"
|
||||
'17':
|
||||
material: SLIME_BALL
|
||||
name: '&fPanel Types'
|
||||
lore:
|
||||
- "&7Add Panel Types."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [text]"
|
||||
- "&7- edit [line number] [text]"
|
||||
- "&7- insert [line number] [text]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_panelType
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_paneltype %cp-player-input%"
|
||||
'22':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fPanel Commands to Open Panel'
|
||||
lore:
|
||||
- "&7Commands that can be used to"
|
||||
- "&7open this panel."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_commands
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelcommands %cp-player-input%"
|
||||
'23':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fCommands Before Panel Open'
|
||||
lore:
|
||||
- "&7Commands before the panel has opened."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_pre-load-commands
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelprecommands %cp-player-input%"
|
||||
'24':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fCommands On Panel Open'
|
||||
lore:
|
||||
- "&7Commands when the panel has opened."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_commands-on-open
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelopencommands %cp-player-input%"
|
||||
'25':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fCommands On Panel Close'
|
||||
lore:
|
||||
- "&7Commands when the panel is closing."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_commands-on-close
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_panelclosecommands %cp-player-input%"
|
||||
'26':
|
||||
material: MAGMA_CREAM
|
||||
name: '&fOutside Panel Commands'
|
||||
lore:
|
||||
- "&7Add commands when clicking outside the panel."
|
||||
- ""
|
||||
- "&7Options"
|
||||
- "&7- add [command]"
|
||||
- "&7- edit [line number] [command]"
|
||||
- "&7- insert [line number] [command]"
|
||||
- "&7- remove [line number]"
|
||||
commands:
|
||||
- event= CPEditorPanel_outside-commands
|
||||
- cpc
|
||||
player-input:
|
||||
- "event= CPEditor_paneloutsidecommands %cp-player-input%"
|
@ -10,7 +10,6 @@ import me.rockyhawk.commandpanels.classresources.ItemCreation;
|
||||
import me.rockyhawk.commandpanels.classresources.placeholders.expansion.CpPlaceholderExpansion;
|
||||
import me.rockyhawk.commandpanels.completetabs.DataTabComplete;
|
||||
import me.rockyhawk.commandpanels.completetabs.ImportTabComplete;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.OpenEditorGuis;
|
||||
import me.rockyhawk.commandpanels.classresources.item_fall.ItemFallManager;
|
||||
import me.rockyhawk.commandpanels.classresources.placeholders.CreateText;
|
||||
import me.rockyhawk.commandpanels.classresources.placeholders.HexColours;
|
||||
@ -24,10 +23,10 @@ import me.rockyhawk.commandpanels.datamanager.PanelDataLoader;
|
||||
import me.rockyhawk.commandpanels.generatepanels.Commandpanelsgenerate;
|
||||
import me.rockyhawk.commandpanels.generatepanels.GenUtils;
|
||||
import me.rockyhawk.commandpanels.generatepanels.TabCompleteGenerate;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.CpIngameEditCommand;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.CpTabCompleteIngame;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.EditorUserInput;
|
||||
import me.rockyhawk.commandpanels.ingameeditor.EditorUtils;
|
||||
import me.rockyhawk.commandpanels.editor.CPEventHandler;
|
||||
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorCommand;
|
||||
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorMain;
|
||||
import me.rockyhawk.commandpanels.editor.CommandPanelsEditorTabComplete;
|
||||
import me.rockyhawk.commandpanels.interactives.input.UserInputUtils;
|
||||
import me.rockyhawk.commandpanels.interactives.Commandpanelrefresher;
|
||||
import me.rockyhawk.commandpanels.interactives.OpenOnJoin;
|
||||
@ -82,6 +81,8 @@ public class CommandPanels extends JavaPlugin{
|
||||
public List<Panel> panelList = new ArrayList<>(); //contains all the panels that are included in the panels folder
|
||||
|
||||
//get alternate classes
|
||||
public CommandPanelsEditorMain editorMain = new CommandPanelsEditorMain(this);
|
||||
|
||||
public CommandTags commandTags = new CommandTags(this);
|
||||
public PanelDataLoader panelData = new PanelDataLoader(this);
|
||||
public Placeholders placeholders = new Placeholders(this);
|
||||
@ -89,7 +90,6 @@ public class CommandPanels extends JavaPlugin{
|
||||
public CreateText tex = new CreateText(this);
|
||||
public HexColours hex = new HexColours(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);
|
||||
@ -206,10 +206,9 @@ public class CommandPanels extends JavaPlugin{
|
||||
|
||||
//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);
|
||||
this.getServer().getPluginManager().registerEvents(new CPEventHandler(this), this);
|
||||
Objects.requireNonNull(this.getCommand("commandpaneledit")).setTabCompleter(new CommandPanelsEditorTabComplete(this));
|
||||
Objects.requireNonNull(this.getCommand("commandpaneledit")).setExecutor(new CommandPanelsEditorCommand(this));
|
||||
}
|
||||
|
||||
//if panel-blocks set to false, don't load this
|
||||
@ -480,7 +479,7 @@ public class CommandPanels extends JavaPlugin{
|
||||
p.sendMessage(ChatColor.GOLD + "/cpb list " + ChatColor.WHITE + "List blocks that will open panels.");
|
||||
}
|
||||
if (p.hasPermission("commandpanel.edit")) {
|
||||
p.sendMessage(ChatColor.GOLD + "/cpe [panel] " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
|
||||
p.sendMessage(ChatColor.GOLD + "/cpe <panel> " + ChatColor.WHITE + "Edit a panel with the Panel Editor.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class Panel{
|
||||
|
||||
private ConfigurationSection panelConfig;
|
||||
private String panelName;
|
||||
private File panelFile;
|
||||
private File panelFile = null;
|
||||
public PanelPlaceholders placeholders = new PanelPlaceholders();
|
||||
public boolean isOpen = false;
|
||||
|
||||
|
@ -31,18 +31,17 @@ public class ExecuteOpenVoids {
|
||||
//avoid plugin glitches when sleeping
|
||||
return;
|
||||
}
|
||||
if(plugin.debug.isEnabled(sender) || plugin.config.getBoolean("config.auto-update-panels")){
|
||||
//reload the panel is debug is enabled
|
||||
if((plugin.debug.isEnabled(sender) || plugin.config.getBoolean("config.auto-update-panels")) && panel.getFile() != null){
|
||||
//reload the panel if debug is enabled
|
||||
panel.setConfig(YamlConfiguration.loadConfiguration(panel.getFile()));
|
||||
}
|
||||
if (!sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(panel.getConfig().getString("custom-messages.perms") != null) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
|
||||
return;
|
||||
}else {
|
||||
}else {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
//if the sender has OTHER perms, or if sendOpenedMessage is false, implying it is not for another person
|
||||
if(sender.hasPermission("commandpanel.other") || !openForOtherUser) {
|
||||
@ -50,11 +49,10 @@ public class ExecuteOpenVoids {
|
||||
if(!plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
if(panel.getConfig().getString("custom-messages.perms") != null) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
|
||||
return;
|
||||
}else {
|
||||
}else {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
@ -113,11 +111,9 @@ public class ExecuteOpenVoids {
|
||||
}else{
|
||||
if(panel.getConfig().getString("custom-messages.perms") != null) {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + panel.getConfig().getString("custom-messages.perms")));
|
||||
return;
|
||||
}else {
|
||||
}else {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package me.rockyhawk.commandpanels.commandtags.tags.economy;
|
||||
|
||||
import de.NeonnBukkit.CoinsAPI.API.CoinsAPI;
|
||||
import me.realized.tokenmanager.api.TokenManager;
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
@ -70,29 +69,5 @@ public class BuyCommandTags implements Listener {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("coinbuycommand=")){
|
||||
e.commandTagUsed();
|
||||
//if player uses coinbuycommand [price] [command]
|
||||
try {
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoinsAPINB")) {
|
||||
int balance = CoinsAPI.getCoins(e.p.getUniqueId().toString());
|
||||
if (balance >= Double.parseDouble(e.args[0])) {
|
||||
CoinsAPI.removeCoins(e.p.getUniqueId().toString(), (int) Long.parseLong(e.args[0]));
|
||||
//execute command under here
|
||||
String price = e.args[0];
|
||||
String command = String.join(" ",Arrays.copyOfRange(e.raw, 1, e.raw.length));
|
||||
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
|
||||
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.coins.success")).replaceAll("%cp-args%", price));
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.coins.failure"));
|
||||
}
|
||||
} else {
|
||||
plugin.tex.sendMessage(e.p, ChatColor.RED + "Buying Requires Vault and an Economy to work!");
|
||||
}
|
||||
} catch (Exception buyc) {
|
||||
plugin.debug(buyc,e.p);
|
||||
plugin.tex.sendMessage(e.p, plugin.config.getString("config.format.error") + " " + "commands: " + e.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
|
||||
import me.rockyhawk.commandpanels.classresources.SerializerUtils;
|
||||
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
@ -101,24 +100,19 @@ public class BasicTags implements Listener {
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("event=")) {
|
||||
e.commandTagUsed();
|
||||
PanelCommandEvent commandEvent = new PanelCommandEvent(e.p, e.args[0], e.panel);
|
||||
PanelCommandEvent commandEvent = new PanelCommandEvent(e.p, String.join(" ",e.args), e.panel);
|
||||
Bukkit.getPluginManager().callEvent(commandEvent);
|
||||
return;
|
||||
}
|
||||
if(e.name.equalsIgnoreCase("minimessage=")){
|
||||
e.commandTagUsed();
|
||||
String tag = plugin.config.getString("config.format.tag") + " ";
|
||||
if(Bukkit.getServer().getVersion().contains("Paper")){
|
||||
LegacyVersion legacy = new LegacyVersion(plugin);
|
||||
if(legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18)){
|
||||
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
|
||||
Component parsedText = SerializerUtils.serializeText(String.join(" ",e.args));
|
||||
player.sendMessage(parsedText);
|
||||
}else{
|
||||
plugin.tex.sendString(e.p, tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
|
||||
}
|
||||
if(plugin.legacy.LOCAL_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_18) && Bukkit.getServer().getVersion().contains("Paper")){
|
||||
Audience player = (Audience) e.p; // Needed because the basic Player from the Event can't send Paper's Components
|
||||
Component parsedText = SerializerUtils.serializeText(String.join(" ",e.args));
|
||||
player.sendMessage(parsedText);
|
||||
}else{
|
||||
plugin.tex.sendString(e.p, tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
|
||||
plugin.tex.sendString(e.p, plugin.tag + ChatColor.RED + "MiniMessage-Feature needs Paper 1.18 or newer to work!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
329
src/me/rockyhawk/commandpanels/editor/CPEventHandler.java
Normal file
329
src/me/rockyhawk/commandpanels/editor/CPEventHandler.java
Normal file
@ -0,0 +1,329 @@
|
||||
package me.rockyhawk.commandpanels.editor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CPEventHandler implements Listener {
|
||||
CommandPanels plugin;
|
||||
public CPEventHandler(CommandPanels pl) { this.plugin = pl; }
|
||||
|
||||
@EventHandler
|
||||
public void onCommandEventOpen(PanelCommandEvent e){
|
||||
if(!e.getMessage().startsWith("CommandPanels_")) {
|
||||
return;
|
||||
}
|
||||
if (e.getMessage().equals("CommandPanels_OpenPanelSettings")) {
|
||||
plugin.editorMain.openGuiPage("PanelEditMenu", e.getPlayer(), PanelPosition.Middle);
|
||||
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).setMenuOpen("PanelEditMenu");
|
||||
return;
|
||||
}
|
||||
if (e.getMessage().equals("CommandPanels_OpenItemSettings")) {
|
||||
plugin.editorMain.openGuiPage("ItemEditMenu", e.getPlayer(), PanelPosition.Middle);
|
||||
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).setMenuOpen("ItemEditMenu");
|
||||
return;
|
||||
}
|
||||
if (e.getMessage().equals("CommandPanels_EditorOpened")) {
|
||||
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).hasEditorOpen = true;
|
||||
return;
|
||||
}
|
||||
if (e.getMessage().equals("CommandPanels_EditorClosed")) {
|
||||
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).hasEditorOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
void savePanelFile(Panel p){
|
||||
try {
|
||||
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(p.getFile());
|
||||
newConfig.set("panels." + p.getName(), p.getConfig());
|
||||
newConfig.save(p.getFile());
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,null);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommandEventView(PanelCommandEvent e){
|
||||
if(!e.getMessage().startsWith("CPEditorItem_") && !e.getMessage().startsWith("CPEditorPanel_")){
|
||||
return;
|
||||
}
|
||||
|
||||
EditorSettings editor = plugin.editorMain.settings.get(e.getPlayer().getUniqueId());
|
||||
|
||||
Panel panel = null;
|
||||
for(Panel pnl : plugin.panelList) {
|
||||
if (pnl.getName().equals(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).panelName)) {
|
||||
panel = pnl.copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert panel != null;
|
||||
|
||||
if(e.getMessage().startsWith("CPEditorItem_")){
|
||||
String input = e.getMessage().replace("CPEditorItem_","");
|
||||
viewContents(e.getPlayer(), panel, "item." + editor.slotSelected + "." + input);
|
||||
}
|
||||
if(e.getMessage().startsWith("CPEditorPanel_")){
|
||||
String input = e.getMessage().replace("CPEditorPanel_","");
|
||||
viewContents(e.getPlayer() , panel, input);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommandEventSettings(PanelCommandEvent e){
|
||||
if(!e.getMessage().startsWith("CPEditor_")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String editType = e.getMessage().split("\\s")[0].replace("CPEditor_","");
|
||||
String playerInput = e.getMessage().replace("CPEditor_" + editType + " ","");
|
||||
EditorSettings editor = plugin.editorMain.settings.get(e.getPlayer().getUniqueId());
|
||||
Panel panel = null;
|
||||
for(Panel pnl : plugin.panelList) {
|
||||
if (pnl.getName().equals(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).panelName)) {
|
||||
panel = pnl.copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert panel != null;
|
||||
|
||||
if(editType.startsWith("item")) {
|
||||
switch (editType) {
|
||||
case "itemslot":
|
||||
plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).slotSelected = playerInput;
|
||||
break;
|
||||
case "itemmaterial":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".material", playerInput);
|
||||
break;
|
||||
case "itemname":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".name", playerInput);
|
||||
break;
|
||||
case "itemstack":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".stack", playerInput);
|
||||
break;
|
||||
case "itemdelete":
|
||||
if (playerInput.toLowerCase().startsWith("c")) {
|
||||
panel.getConfig().set("item." + editor.slotSelected, null);
|
||||
}
|
||||
break;
|
||||
case "itemmove":
|
||||
ConfigurationSection oldLocation = panel.getConfig().getConfigurationSection("item." + editor.slotSelected);
|
||||
if (panel.getConfig().isSet("item." + playerInput)) {
|
||||
ConfigurationSection newLocation = panel.getConfig().getConfigurationSection("item." + playerInput);
|
||||
panel.getConfig().set("item." + editor.slotSelected, newLocation);
|
||||
}
|
||||
panel.getConfig().set("item." + playerInput, oldLocation);
|
||||
break;
|
||||
case "itemmodeldata":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".customdata", playerInput);
|
||||
break;
|
||||
case "itemdurability":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".damage", playerInput);
|
||||
break;
|
||||
case "itemarmour":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".leatherarmor", playerInput);
|
||||
break;
|
||||
case "itemduplicate":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".duplicate", playerInput);
|
||||
break;
|
||||
case "itempotion":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".potion", playerInput);
|
||||
break;
|
||||
case "itemid":
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".ID", playerInput);
|
||||
break;
|
||||
case "itemlore":
|
||||
listChanger(playerInput, panel, "item." + editor.slotSelected + ".lore");
|
||||
if (!panel.getConfig().isSet("item." + editor.slotSelected + ".name")) {
|
||||
e.getPlayer().sendMessage(ChatColor.RED + "Your item needs to have a name for your lore to be visible!");
|
||||
}
|
||||
break;
|
||||
case "itemcommands":
|
||||
listChanger(playerInput, panel, "item." + editor.slotSelected + ".commands");
|
||||
break;
|
||||
case "iteminput":
|
||||
listChanger(playerInput, panel, "item." + editor.slotSelected + ".player-input");
|
||||
break;
|
||||
case "itemtypes":
|
||||
listChanger(playerInput, panel, "item." + editor.slotSelected + ".itemType");
|
||||
break;
|
||||
case "itemenchantment":
|
||||
listChanger(playerInput, panel, "item." + editor.slotSelected + ".enchanted");
|
||||
break;
|
||||
case "itemnbt":
|
||||
if (playerInput.startsWith("add")) {
|
||||
String[] str = playerInput.split("\\s", 3);
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".nbt." + str[1], str[2]);
|
||||
} else if (playerInput.startsWith("remove")) {
|
||||
String element = playerInput.split("\\s")[1];
|
||||
panel.getConfig().set("item." + editor.slotSelected + ".nbt." + element, null);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
switch (editType) {
|
||||
case "panelpermission":
|
||||
panel.getConfig().set("perm", playerInput);
|
||||
break;
|
||||
case "panelenabledworlds":
|
||||
listChanger(playerInput, panel, "enabled-worlds");
|
||||
break;
|
||||
case "paneldisabledworlds":
|
||||
listChanger(playerInput, panel, "disabled-worlds");
|
||||
break;
|
||||
case "panelopensound":
|
||||
panel.getConfig().set("sound-on-open", playerInput);
|
||||
break;
|
||||
case "panelemptyid":
|
||||
panel.getConfig().set("emptyID", playerInput);
|
||||
break;
|
||||
case "panelempty":
|
||||
panel.getConfig().set("empty", playerInput);
|
||||
break;
|
||||
case "paneltitle":
|
||||
panel.getConfig().set("title", playerInput);
|
||||
break;
|
||||
case "panelrows":
|
||||
panel.getConfig().set("rows", playerInput);
|
||||
break;
|
||||
case "panelrefreshdelay":
|
||||
panel.getConfig().set("refresh-delay", playerInput);
|
||||
break;
|
||||
case "paneltype":
|
||||
listChanger(playerInput, panel, "panelType");
|
||||
break;
|
||||
case "panelcommands":
|
||||
listChanger(playerInput, panel, "commands");
|
||||
break;
|
||||
case "panelprecommands":
|
||||
listChanger(playerInput, panel, "pre-load-commands");
|
||||
break;
|
||||
case "panelopencommands":
|
||||
listChanger(playerInput, panel, "commands-on-open");
|
||||
break;
|
||||
case "panelclosecommands":
|
||||
listChanger(playerInput, panel, "commands-on-close");
|
||||
break;
|
||||
case "paneloutsidecommands":
|
||||
listChanger(playerInput, panel, "outside-commands");
|
||||
break;
|
||||
case "panelplayerinputmessage":
|
||||
listChanger(playerInput, panel, "custom-messages.player-input");
|
||||
break;
|
||||
case "panelmaxinputmessage":
|
||||
panel.getConfig().set("custom-messages.input", playerInput);
|
||||
break;
|
||||
case "panelpermissionmessage":
|
||||
panel.getConfig().set("custom-messages.perm", playerInput);
|
||||
break;
|
||||
case "paneldelete":
|
||||
if (!playerInput.toLowerCase().startsWith("c")) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
//clear panel from file contents
|
||||
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
newConfig.set("panels." + panel.getName(), null);
|
||||
e.getPlayer().sendMessage(ChatColor.GREEN + "Panel deleted!");
|
||||
if(newConfig.getKeys(true).size() == 1){
|
||||
//file is empty
|
||||
if(panel.getFile().delete()){
|
||||
plugin.reloadPanelFiles();
|
||||
return;
|
||||
}
|
||||
}
|
||||
newConfig.save(panel.getFile());
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,e.getPlayer());
|
||||
}
|
||||
plugin.reloadPanelFiles();
|
||||
return;
|
||||
case "panelname":
|
||||
YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
newConfig.set("panels." + playerInput.split("\\s")[0], panel.getConfig());
|
||||
newConfig.set("panels." + panel.getName(), null);
|
||||
try {
|
||||
newConfig.save(panel.getFile());
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,e.getPlayer());
|
||||
}
|
||||
plugin.reloadPanelFiles();
|
||||
e.getPlayer().sendMessage(ChatColor.GREEN + "Panel name changed!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
savePanelFile(panel);
|
||||
|
||||
//This will open the editor back up
|
||||
panel.open(e.getPlayer(),PanelPosition.Top);
|
||||
plugin.editorMain.openGuiPage(plugin.editorMain.settings.get(e.getPlayer().getUniqueId()).menuOpen,e.getPlayer(),PanelPosition.Middle);
|
||||
plugin.editorMain.openGuiPage("BottomSettings",e.getPlayer(),PanelPosition.Bottom);
|
||||
}
|
||||
|
||||
/*
|
||||
this will allow for add, edit and remove settings
|
||||
add msg= test
|
||||
edit 1 msg= changed
|
||||
insert 1 msg= new line
|
||||
remove 1
|
||||
*/
|
||||
public void listChanger(String playerInput, Panel panel, String location){
|
||||
List<String> contents = panel.getConfig().getStringList(location);
|
||||
if(playerInput.startsWith("add")){
|
||||
String str = playerInput.split("\\s", 2)[1];
|
||||
contents.add(str);
|
||||
}else if(playerInput.startsWith("edit")){
|
||||
List<String> str = new ArrayList<>(Arrays.asList(playerInput.split("\\s")));
|
||||
str.subList(0,2).clear();
|
||||
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
|
||||
contents.set(element,String.join(" ",str));
|
||||
}else if(playerInput.startsWith("insert")){
|
||||
List<String> str = new ArrayList<>(Arrays.asList(playerInput.split("\\s")));
|
||||
str.subList(0,2).clear();
|
||||
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
|
||||
contents.add(element,String.join(" ",str));
|
||||
}else if(playerInput.startsWith("remove")){
|
||||
int element = Integer.parseInt(playerInput.split("\\s")[1])-1;
|
||||
contents.remove(element);
|
||||
}
|
||||
if(contents.isEmpty()){
|
||||
panel.getConfig().set(location, null);
|
||||
}else {
|
||||
panel.getConfig().set(location, contents);
|
||||
}
|
||||
}
|
||||
|
||||
public void viewContents(Player player, Panel panel, String location){
|
||||
if(panel.getConfig().isList(location)){
|
||||
player.sendMessage("Current Value: ");
|
||||
int n = 1;
|
||||
for(String value : panel.getConfig().getStringList(location)){
|
||||
player.sendMessage("(" + n + ") " + value);
|
||||
n++;
|
||||
}
|
||||
}else{
|
||||
player.sendMessage("Current Value: " + panel.getConfig().getString(location));
|
||||
}
|
||||
}
|
||||
|
||||
//if a string is a number
|
||||
public boolean isNumeric(String str) {
|
||||
try {
|
||||
Double.parseDouble(str);
|
||||
return true;
|
||||
} catch(NumberFormatException e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,7 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
package me.rockyhawk.commandpanels.editor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -11,12 +10,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CpIngameEditCommand implements CommandExecutor {
|
||||
public class CommandPanelsEditorCommand implements CommandExecutor {
|
||||
CommandPanels plugin;
|
||||
|
||||
public CpIngameEditCommand(CommandPanels pl) {
|
||||
public CommandPanelsEditorCommand(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
|
||||
@ -26,11 +23,6 @@ public class CpIngameEditCommand implements CommandExecutor {
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
|
||||
return true;
|
||||
}
|
||||
if(Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("false")){
|
||||
//this will cancel every /cpe command if ingame-editor is set to false
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Editor disabled!"));
|
||||
return true;
|
||||
}
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Please execute command as a Player!"));
|
||||
return true;
|
||||
@ -40,16 +32,19 @@ public class CpIngameEditCommand implements CommandExecutor {
|
||||
if (args.length == 1) { //check to make sure the person hasn't just left it empty
|
||||
for(Panel panel : plugin.panelList){
|
||||
if(panel.getName().equals(args[0])) {
|
||||
if(plugin.editorMain.settings.containsKey(p.getUniqueId())){
|
||||
plugin.editorMain.settings.get(p.getUniqueId()).setLastPanel(panel.getName());
|
||||
}else{
|
||||
plugin.editorMain.settings.put(p.getUniqueId(), new EditorSettings("PanelEditMenu",panel.getName()));
|
||||
}
|
||||
//below will start the command, once it got the right file and panel
|
||||
plugin.createGUI.openGui(panel.copy(), p, PanelPosition.Top, PanelOpenType.Editor,0);
|
||||
panel.copy().open(p,PanelPosition.Top);
|
||||
plugin.editorMain.openGuiPage(plugin.editorMain.settings.get(p.getUniqueId()).menuOpen,p,PanelPosition.Middle);
|
||||
plugin.editorMain.openGuiPage("BottomSettings",p,PanelPosition.Bottom);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (args.length == 0) {
|
||||
plugin.editorGuis.openEditorGui(p,0);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cpe <panel>"));
|
||||
return true;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package me.rockyhawk.commandpanels.editor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandPanelsEditorMain {
|
||||
CommandPanels plugin;
|
||||
public CommandPanelsEditorMain(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
public Map<UUID, EditorSettings> settings = new HashMap<>();
|
||||
|
||||
public void openGuiPage(String fileName, Player p, PanelPosition position){
|
||||
try {
|
||||
Panel panel = new Panel(YamlConfiguration.loadConfiguration(plugin.getReaderFromStream(plugin.getResource(fileName + ".yml"))), fileName);
|
||||
|
||||
panel.placeholders.addPlaceholder("panel-name",settings.get(p.getUniqueId()).panelName);
|
||||
panel.placeholders.addPlaceholder("item-slot",settings.get(p.getUniqueId()).slotSelected);
|
||||
|
||||
panel.open(p, position);
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.rockyhawk.commandpanels.editor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CommandPanelsEditorTabComplete implements TabCompleter {
|
||||
CommandPanels plugin;
|
||||
public CommandPanelsEditorTabComplete(CommandPanels pl) { this.plugin = pl; }
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(sender instanceof Player && args.length == 1){
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
try {
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!panel.getName().startsWith(args[0])){
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
}
|
||||
return apanels;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
21
src/me/rockyhawk/commandpanels/editor/EditorSettings.java
Normal file
21
src/me/rockyhawk/commandpanels/editor/EditorSettings.java
Normal file
@ -0,0 +1,21 @@
|
||||
package me.rockyhawk.commandpanels.editor;
|
||||
|
||||
public class EditorSettings {
|
||||
public String panelName;
|
||||
public String menuOpen;
|
||||
public String slotSelected = "0";
|
||||
public boolean hasEditorOpen = false;
|
||||
|
||||
public EditorSettings(String menu, String panel){
|
||||
menuOpen = menu;
|
||||
panelName = panel;
|
||||
}
|
||||
|
||||
public void setMenuOpen(String menu){
|
||||
menuOpen = menu;
|
||||
}
|
||||
|
||||
public void setLastPanel(String panel){
|
||||
panelName = panel;
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class CpTabCompleteIngame implements TabCompleter {
|
||||
CommandPanels plugin;
|
||||
public CpTabCompleteIngame(CommandPanels pl) { this.plugin = pl; }
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(sender instanceof Player && args.length == 1){
|
||||
Player p = ((Player) sender).getPlayer();
|
||||
if(label.equalsIgnoreCase("cpe") || label.equalsIgnoreCase("cpanele") || label.equalsIgnoreCase("commandpaneledit")){
|
||||
ArrayList<String> apanels = new ArrayList<String>(); //all panels
|
||||
try {
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(!panel.getName().startsWith(args[0])){
|
||||
//this will narrow down the panels to what the user types
|
||||
continue;
|
||||
}
|
||||
if(sender.hasPermission("commandpanel.panel." + panel.getConfig().getString("perm"))) {
|
||||
if(plugin.panelPerms.isPanelWorldEnabled(p,panel.getConfig())){
|
||||
apanels.add(panel.getName());
|
||||
}
|
||||
}
|
||||
//if file contains opened panel then start
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
}
|
||||
return apanels;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,702 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EditorUserInput implements Listener {
|
||||
CommandPanels plugin;
|
||||
public EditorUserInput(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerChatEditor(AsyncPlayerChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
for(String[] temp : plugin.editorInputStrings) {
|
||||
//[0] is player name [1] is panel name [2] is section type
|
||||
if (!temp[0].equals(p.getName())) {
|
||||
continue;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = temp[1];
|
||||
String panelTitle = temp[1];
|
||||
File panelFile = null;
|
||||
String section = temp[2];
|
||||
YamlConfiguration cfile = null;
|
||||
ConfigurationSection cf = null;
|
||||
try {
|
||||
for (Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (panel.getName().equals(panelName)) {
|
||||
cf = panel.getConfig();
|
||||
cfile = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
panelFile = panel.getFile();
|
||||
panelTitle = plugin.tex.colour(cf.getString("title"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception fail) {
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
plugin.editorInputStrings.remove(temp);
|
||||
return;
|
||||
}
|
||||
if(e.getMessage().equalsIgnoreCase(plugin.config.getString("config.input-cancel"))){
|
||||
plugin.editorInputStrings.remove(temp);
|
||||
plugin.reloadPanelFiles();
|
||||
e.getPlayer().sendMessage(plugin.tex.colour( Objects.requireNonNull(plugin.config.getString("config.input-cancelled"))));
|
||||
return;
|
||||
}
|
||||
plugin.editorInputStrings.remove(temp);
|
||||
if(section.startsWith("panel.")) {
|
||||
panelSectionCheck(p, section, panelName, panelTitle, cf, cfile, panelFile, e);
|
||||
}else if(section.startsWith("item:")){
|
||||
itemSectionCheck(p, section, panelName, cf, cfile, panelFile, e);
|
||||
}else if(section.startsWith("section.")){
|
||||
itemSectionSectionCheck(p, section, panelName, cf, cfile, panelFile, e);
|
||||
}
|
||||
plugin.reloadPanelFiles();
|
||||
if(section.startsWith("panel.")){
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
plugin.editorGuis.openEditorGui(p, 0); //I have to do this to run regular Bukkit voids in an ASYNC Event
|
||||
}
|
||||
});
|
||||
}else if(section.startsWith("item:")) {
|
||||
final ConfigurationSection finalCF = cf;
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
plugin.createGUI.openGui(new Panel(finalCF, panelName), p, PanelPosition.Top, PanelOpenType.Editor,0); //I have to do this to run regular Bukkit voids in an ASYNC Event
|
||||
}
|
||||
});
|
||||
}else if(section.startsWith("section.")){
|
||||
String itemSection = ChatColor.stripColor(section.replace("section." + section.split("\\.")[1] + ".", ""));
|
||||
final ConfigurationSection finalCF = cf.getConfigurationSection("item." + itemSection);
|
||||
if(section.contains("change")){
|
||||
final String changeItemSection = itemSection.substring(0, itemSection.lastIndexOf("."));
|
||||
final ConfigurationSection changeFinalCF = cf.getConfigurationSection("item." + changeItemSection);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
plugin.editorGuis.openItemSections(p,panelName,changeFinalCF,changeItemSection);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
plugin.editorGuis.openItemSections(p,panelName,finalCF,itemSection);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
boolean savePanelFile(ConfigurationSection cf, YamlConfiguration cfile, String panelName, File panelFile){
|
||||
try {
|
||||
cfile.set("panels." + panelName, cf);
|
||||
cfile.save(panelFile);
|
||||
return true;
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,null);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void panelSectionCheck(Player p, String section, String panelName, String panelTitle, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
|
||||
switch (section) {
|
||||
case "panel.delete":
|
||||
if (e.getMessage().contains("y")) {
|
||||
if(Objects.requireNonNull(cfile.getConfigurationSection("panels")).getKeys(false).size() != 1){
|
||||
//if the file has more than one panel in it
|
||||
if(savePanelFile(null, cfile, panelName, panelFile)){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
|
||||
}
|
||||
}else {
|
||||
//if the file only has one panel in it
|
||||
if (panelFile.delete()) {
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Deleted Panel!"));
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could Not Delete Panel!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "panel.perm":
|
||||
if(e.getMessage().contains(" ")){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Permission cannot contain spaces!"));
|
||||
break;
|
||||
}
|
||||
cf.set("perm", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Permission required is now " + "commandpanel.panel." + e.getMessage()));
|
||||
break;
|
||||
case "panel.rows":
|
||||
try {
|
||||
int rows = Integer.parseInt(e.getMessage());
|
||||
if (rows >= 7 || rows <= 0) {
|
||||
//if the number isn't between 1-6
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 6!"));
|
||||
return;
|
||||
}
|
||||
cf.set("rows", rows);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Panel to " + rows + " rows!"));
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,p);
|
||||
}
|
||||
break;
|
||||
case "panel.title":
|
||||
if(panelTitle.equals(plugin.tex.colour(e.getMessage()))){
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + e.getMessage() + ChatColor.RED + " is in use from another panel!"));
|
||||
break;
|
||||
}
|
||||
cf.set("title", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Title to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "panel.name":
|
||||
if(e.getMessage().contains(" ")){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Panel name cannot contain spaces!"));
|
||||
break;
|
||||
}
|
||||
if(panelName.equals(e.getMessage())){
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + e.getMessage() + " is in use from another panel!"));
|
||||
break;
|
||||
}
|
||||
cfile.set("panels." + e.getMessage(), cfile.get("panels." + panelName));
|
||||
//I have put null there instead of cf because that will replicate cp = null to delete it
|
||||
savePanelFile(null, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + e.getMessage()));
|
||||
break;
|
||||
case "panel.empty":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("empty", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Empty materials have been removed."));
|
||||
break;
|
||||
}
|
||||
String materialTemp = null;
|
||||
try {
|
||||
materialTemp = Objects.requireNonNull(Material.matchMaterial(e.getMessage())).toString();
|
||||
}catch(NullPointerException ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Material!"));
|
||||
}
|
||||
cf.set("empty", materialTemp);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Empty material to " + materialTemp));
|
||||
break;
|
||||
case "panel.sound-on-open":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("sound-on-open", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sounds have been removed."));
|
||||
break;
|
||||
}
|
||||
String tempSound;
|
||||
try {
|
||||
tempSound = Sound.valueOf(e.getMessage()).toString();
|
||||
}catch(Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + e.getMessage() + " is not a valid Sound!"));
|
||||
return;
|
||||
}
|
||||
cf.set("sound-on-open", tempSound);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Sound when opening is now " + tempSound));
|
||||
break;
|
||||
case "panel.panelType.add":
|
||||
List<String> typeAdd = new ArrayList<>();
|
||||
if(cf.contains("panelType")){
|
||||
typeAdd = cf.getStringList("panelType");
|
||||
}
|
||||
typeAdd.add(e.getMessage().toLowerCase());
|
||||
cf.set("panelType", typeAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new panel type: " + e.getMessage().toLowerCase()));
|
||||
break;
|
||||
case "panel.panelType.remove":
|
||||
List<String> typeRemove;
|
||||
if(cf.contains("panelType")){
|
||||
typeRemove = cf.getStringList("panelType");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No types found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
typeRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find type!"));
|
||||
break;
|
||||
}
|
||||
if(typeRemove.size() == 0){
|
||||
cf.set("panelType", null);
|
||||
}else{
|
||||
cf.set("panelType", typeRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed panel type " + e.getMessage()));
|
||||
break;
|
||||
case "panel.commands.add":
|
||||
List<String> commandsAdd = new ArrayList<>();
|
||||
if(cf.contains("commands")){
|
||||
commandsAdd = cf.getStringList("commands");
|
||||
}
|
||||
commandsAdd.add(e.getMessage());
|
||||
cf.set("commands", commandsAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.commands.remove":
|
||||
List<String> commandsRemove;
|
||||
if(cf.contains("commands")){
|
||||
commandsRemove = cf.getStringList("commands");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
commandsRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
|
||||
break;
|
||||
}
|
||||
if(commandsRemove.size() == 0){
|
||||
cf.set("commands", null);
|
||||
}else{
|
||||
cf.set("commands", commandsRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
|
||||
break;
|
||||
case "panel.commands-on-open.add":
|
||||
List<String> commandsOnOpenAdd = new ArrayList<>();
|
||||
if(cf.contains("commands-on-open")){
|
||||
commandsOnOpenAdd = cf.getStringList("commands-on-open");
|
||||
}
|
||||
commandsOnOpenAdd.add(e.getMessage());
|
||||
cf.set("commands-on-open", commandsOnOpenAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.commands-on-open.remove":
|
||||
List<String> commandsOnOpenRemove;
|
||||
if(cf.contains("commands-on-open")){
|
||||
commandsOnOpenRemove = cf.getStringList("commands-on-open");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
|
||||
break;
|
||||
}
|
||||
if(commandsOnOpenRemove.size() == 0){
|
||||
cf.set("commands-on-open", null);
|
||||
}else{
|
||||
cf.set("commands-on-open", commandsOnOpenRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
|
||||
break;
|
||||
case "panel.disabled-worlds.add":
|
||||
List<String> disabledWorldsAdd = new ArrayList<>();
|
||||
if(cf.contains("disabled-worlds")){
|
||||
disabledWorldsAdd = cf.getStringList("disabled-worlds");
|
||||
}
|
||||
disabledWorldsAdd.add(e.getMessage());
|
||||
cf.set("disabled-worlds", disabledWorldsAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new World: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.disabled-worlds.remove":
|
||||
List<String> disabledWorldsRemove;
|
||||
if(cf.contains("disabled-worlds")){
|
||||
disabledWorldsRemove = cf.getStringList("disabled-worlds");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No Worlds found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
disabledWorldsRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find World!"));
|
||||
break;
|
||||
}
|
||||
if(disabledWorldsRemove.size() == 0){
|
||||
cf.set("disabled-worlds", null);
|
||||
}else{
|
||||
cf.set("disabled-worlds", disabledWorldsRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed World line " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.material":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("open-with-item", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item have been removed."));
|
||||
//after an open-with-item has been altered, reload after changes
|
||||
plugin.reloadPanelFiles();
|
||||
break;
|
||||
}
|
||||
cf.set("open-with-item.material", e.getMessage());
|
||||
if(!cf.contains("open-with-item.name")){
|
||||
cf.set("open-with-item.name", panelName + " Item");
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Material to " + ChatColor.WHITE + e.getMessage()));
|
||||
//after an open-with-item has been altered, reload after changes
|
||||
plugin.reloadPanelFiles();
|
||||
break;
|
||||
case "panel.hotbar.stationary":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("open-with-item.stationary", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Hotbar item can now be moved."));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
int loc = Integer.parseInt(e.getMessage());
|
||||
if (loc >= 36 || loc <= -1) {
|
||||
//if the number isn't between the numbers
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 0 to 35!"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Hotbar Location to " + loc + "!"));
|
||||
cf.set("open-with-item.stationary", loc);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,p);
|
||||
}
|
||||
plugin.hotbar.reloadHotbarSlots();
|
||||
break;
|
||||
case "panel.hotbar.name":
|
||||
cf.set("open-with-item.name",e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Name to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.lore.add":
|
||||
List<String> loreAdd = new ArrayList<>();
|
||||
if(cf.contains("open-with-item.lore")){
|
||||
loreAdd = cf.getStringList("open-with-item.lore");
|
||||
}
|
||||
loreAdd.add(e.getMessage());
|
||||
cf.set("open-with-item.lore", loreAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.lore.remove":
|
||||
List<String> loreRemove;
|
||||
if(cf.contains("open-with-item.lore")){
|
||||
loreRemove = cf.getStringList("open-with-item.lore");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
loreRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
|
||||
break;
|
||||
}
|
||||
if(loreRemove.size() == 0){
|
||||
cf.set("open-with-item.lore", null);
|
||||
}else{
|
||||
cf.set("open-with-item.lore", loreRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.commands.add":
|
||||
List<String> commandAdd = new ArrayList<>();
|
||||
if(cf.contains("open-with-item.commands")){
|
||||
commandAdd = cf.getStringList("open-with-item.commands");
|
||||
}
|
||||
commandAdd.add(e.getMessage());
|
||||
cf.set("open-with-item.commands", commandAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
|
||||
break;
|
||||
case "panel.hotbar.commands.remove":
|
||||
List<String> commandRemove;
|
||||
if(cf.contains("open-with-item.commands")){
|
||||
commandRemove = cf.getStringList("open-with-item.commands");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
commandRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
|
||||
break;
|
||||
}
|
||||
if(commandRemove.size() == 0){
|
||||
cf.set("open-with-item.commands", null);
|
||||
}else{
|
||||
cf.set("open-with-item.commands", commandRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void itemSectionCheck(Player p, String section, String panelName, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
|
||||
/*
|
||||
I am using : instead of . because the
|
||||
item sections could contain 18.hasperm <- the periods
|
||||
so using a different symbol will help to separate the section from
|
||||
everything else
|
||||
*/
|
||||
String itemSlot = section.split(":")[1];
|
||||
String sectionChange = section.replace("item:" + itemSlot + ":","");
|
||||
switch (sectionChange) {
|
||||
case "name":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".name", "");
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Name is now default."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".name", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new name to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "head":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".material", plugin.getHeads.playerHeadString());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Material is now default."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".material", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set Material value to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "stack":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".stack", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Item has been unstacked."));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
int rows = Integer.parseInt(e.getMessage());
|
||||
if (rows >= 65 || rows <= 0) {
|
||||
//if the number isn't between 1-64
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Choose an integer between 1 to 64!"));
|
||||
return;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".stack", rows);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set stack to " + rows + "!"));
|
||||
} catch (Exception io) {
|
||||
plugin.debug(io,p);
|
||||
}
|
||||
break;
|
||||
case "enchanted":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".enchanted", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Enchantments have been removed."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".enchanted", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Enchantment to " + ChatColor.WHITE + e.getMessage()));
|
||||
break;
|
||||
case "potion":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".potion", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Potion effects have been removed."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".potion", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set new Potion to " + e.getMessage().toUpperCase()));
|
||||
break;
|
||||
case "customdata":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".customdata", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data has been removed."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".customdata", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Custom Model Data set to " + e.getMessage()));
|
||||
break;
|
||||
case "leatherarmor":
|
||||
if(e.getMessage().trim().equalsIgnoreCase("remove")){
|
||||
cf.set("item." + itemSlot + ".leatherarmor", null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour has been removed."));
|
||||
break;
|
||||
}
|
||||
cf.set("item." + itemSlot + ".leatherarmor", e.getMessage());
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Leather armor colour set to " + e.getMessage()));
|
||||
break;
|
||||
case "commands:add":
|
||||
List<String> commandsOnOpenAdd = new ArrayList<>();
|
||||
if(cf.contains("item." + itemSlot + ".commands")){
|
||||
commandsOnOpenAdd = cf.getStringList("item." + itemSlot + ".commands");
|
||||
}
|
||||
commandsOnOpenAdd.add(e.getMessage());
|
||||
cf.set("item." + itemSlot + ".commands", commandsOnOpenAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new command: " + e.getMessage()));
|
||||
break;
|
||||
case "commands:remove":
|
||||
List<String> commandsOnOpenRemove;
|
||||
if(cf.contains("item." + itemSlot + ".commands")){
|
||||
commandsOnOpenRemove = cf.getStringList("item." + itemSlot + ".commands");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No commands found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
commandsOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find command!"));
|
||||
plugin.debug(ex,p);
|
||||
break;
|
||||
}
|
||||
if(commandsOnOpenRemove.size() == 0){
|
||||
cf.set("item." + itemSlot + ".commands", null);
|
||||
}else{
|
||||
cf.set("item." + itemSlot + ".commands", commandsOnOpenRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed command line " + e.getMessage()));
|
||||
break;
|
||||
case "lore:add":
|
||||
List<String> loreOnOpenAdd = new ArrayList<>();
|
||||
if(cf.contains("item." + itemSlot + ".lore")){
|
||||
loreOnOpenAdd = cf.getStringList("item." + itemSlot + ".lore");
|
||||
}
|
||||
loreOnOpenAdd.add(e.getMessage());
|
||||
cf.set("item." + itemSlot + ".lore", loreOnOpenAdd);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new lore: " + e.getMessage()));
|
||||
break;
|
||||
case "lore:remove":
|
||||
List<String> loreOnOpenRemove;
|
||||
if(cf.contains("item." + itemSlot + ".lore")){
|
||||
loreOnOpenRemove = cf.getStringList("item." + itemSlot + ".lore");
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No lore found to remove!"));
|
||||
break;
|
||||
}
|
||||
try {
|
||||
loreOnOpenRemove.remove(Integer.parseInt(e.getMessage())-1);
|
||||
}catch (Exception ex){
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "Could not find lore!"));
|
||||
plugin.debug(ex,p);
|
||||
break;
|
||||
}
|
||||
if(loreOnOpenRemove.size() == 0){
|
||||
cf.set("item." + itemSlot + ".lore", null);
|
||||
}else{
|
||||
cf.set("item." + itemSlot + ".lore", loreOnOpenRemove);
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed lore line " + e.getMessage()));
|
||||
break;
|
||||
case "duplicate:add":
|
||||
if(cf.contains("item." + itemSlot + ".duplicate")){
|
||||
cf.set("item." + itemSlot + ".duplicate", cf.getString("item." + itemSlot + ".duplicate") + "," + e.getMessage());
|
||||
}else{
|
||||
cf.set("item." + itemSlot + ".duplicate", e.getMessage());
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added new duplicate item/s: " + e.getMessage()));
|
||||
break;
|
||||
case "duplicate:remove":
|
||||
if(cf.contains("item." + itemSlot + ".duplicate")){
|
||||
if(cf.getString("item." + itemSlot + ".duplicate").contains(",")) {
|
||||
try {
|
||||
String[] duplicateItems = cf.getString("item." + itemSlot + ".duplicate").split(",");
|
||||
StringBuilder items = new StringBuilder();
|
||||
for(int s = 0; s < duplicateItems.length; s++){
|
||||
if(Integer.parseInt(e.getMessage()) != s+1) {
|
||||
items.append(duplicateItems[s]);
|
||||
items.append(",");
|
||||
}
|
||||
}
|
||||
cf.set("item." + itemSlot + ".duplicate", items.toString());
|
||||
} catch (Exception ex) {
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could not delete or find item!"));
|
||||
plugin.debug(ex,p);
|
||||
break;
|
||||
}
|
||||
if(cf.getString("item." + itemSlot + ".duplicate").equals("")){
|
||||
cf.set("item." + itemSlot + ".duplicate", null);
|
||||
}
|
||||
}else{
|
||||
cf.set("item." + itemSlot + ".duplicate", null);
|
||||
}
|
||||
}else{
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.RED + "No items found to remove!"));
|
||||
break;
|
||||
}
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed duplicate item/s: " + e.getMessage()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void itemSectionSectionCheck(Player p, String section, String panelName, ConfigurationSection cf, YamlConfiguration cfile, File panelFile, AsyncPlayerChatEvent e){
|
||||
String secondValue = section.split("\\.")[1];
|
||||
//section includes slot at front eg, 1.hasvalue
|
||||
String itemSection = ChatColor.stripColor(section.replace("section." + secondValue + ".", ""));
|
||||
String playerMessage = ChatColor.stripColor(e.getMessage()).toLowerCase();
|
||||
switch (secondValue) {
|
||||
case "add":
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".output", "true");
|
||||
if(playerMessage.equals("hasperm")) {
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".perm", "admin");
|
||||
}else{
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".value", "10");
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".compare", "%cp-player-balance%");
|
||||
}
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".material", "DIRT");
|
||||
cf.set("item." + itemSection + "." + playerMessage + ".name", "");
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
plugin.reloadPanelFiles();
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Added Section " + ChatColor.WHITE + playerMessage));
|
||||
break;
|
||||
case "remove":
|
||||
cf.set("item." + itemSection + "." + playerMessage, null);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
plugin.reloadPanelFiles();
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Removed Section " + ChatColor.WHITE + playerMessage));
|
||||
break;
|
||||
case "change":
|
||||
cf.set("item." + itemSection + "." + playerMessage.split(":")[0], playerMessage.split(":")[1]);
|
||||
savePanelFile(cf, cfile, panelName, panelFile);
|
||||
plugin.reloadPanelFiles();
|
||||
p.sendMessage(plugin.tex.colour( plugin.tag + ChatColor.GREEN + "Set " + playerMessage.split(":")[0] + " to " + ChatColor.WHITE + playerMessage.split(":")[1]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,753 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class EditorUtils implements Listener {
|
||||
public YamlConfiguration tempEdit;
|
||||
public ArrayList<String> inventoryItemSettingsOpening = new ArrayList<>();
|
||||
CommandPanels plugin;
|
||||
public EditorUtils(CommandPanels pl) {
|
||||
this.plugin = pl;
|
||||
this.tempEdit = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder() + File.separator + "temp.yml"));
|
||||
}
|
||||
@EventHandler
|
||||
public void onClickMainEdit(InventoryClickEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
//if the inventory isn't the editor main window
|
||||
try {
|
||||
if (Objects.requireNonNull(e.getClickedInventory()).getType() != InventoryType.CHEST) {
|
||||
return;
|
||||
}
|
||||
}catch(NullPointerException nu){return;}
|
||||
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.colour("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName(), PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(e.getClickedInventory() != e.getView().getTopInventory()){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
ArrayList<String> panelNames = new ArrayList<String>(); //all panels from ALL files (panel names)
|
||||
ArrayList<String> panelTitles = new ArrayList<String>(); //all panels from ALL files (panel titles)
|
||||
ArrayList<ConfigurationSection> panelYaml = new ArrayList<ConfigurationSection>(); //all panels from ALL files (panel yaml files)
|
||||
try {
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
panelNames.add(plugin.tex.colour(panel.getName()));
|
||||
panelTitles.add(plugin.tex.colour( Objects.requireNonNull(panel.getConfig().getString("title"))));
|
||||
panelYaml.add(panel.getConfig());
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(e.getSlot() == 48){
|
||||
//previous page button
|
||||
try {
|
||||
if (Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER) {
|
||||
plugin.editorGuis.openEditorGui(p, -1);
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
}catch(NullPointerException ignored){}
|
||||
}
|
||||
if(e.getSlot() == 49){
|
||||
//sunflower page index
|
||||
if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.SLIME_BALL){
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(e.getSlot() == 50){
|
||||
//next page button
|
||||
try{
|
||||
if(Objects.requireNonNull(e.getCurrentItem()).getType() == Material.PAPER){
|
||||
plugin.editorGuis.openEditorGui(p, 1);
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
}catch(NullPointerException ignored){}
|
||||
}
|
||||
if(e.getSlot() == 45){
|
||||
//exit button
|
||||
p.closeInventory();
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
if(e.getSlot() <= 44){
|
||||
//if panel slots are selected
|
||||
try{
|
||||
if(Objects.requireNonNull(e.getCurrentItem()).getType() != Material.AIR){
|
||||
if(e.getClick().isLeftClick() && !e.getClick().isShiftClick()){
|
||||
//if left click
|
||||
int count = 0;
|
||||
for(String panelName : panelNames){
|
||||
if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){
|
||||
plugin.createGUI.openGui(new Panel(panelYaml.get(count), panelName), p,PanelPosition.Top,PanelOpenType.Editor,0);
|
||||
return;
|
||||
}
|
||||
count +=1;
|
||||
}
|
||||
}else{
|
||||
//if right click
|
||||
int count = 0;
|
||||
for(String panelName : panelNames){
|
||||
if(panelName.equals(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName()))){
|
||||
plugin.editorGuis.openPanelSettings(p,panelName,panelYaml.get(count));
|
||||
return;
|
||||
}
|
||||
count +=1;
|
||||
}
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
}catch(NullPointerException ignored){}
|
||||
}
|
||||
p.updateInventory();
|
||||
}
|
||||
@EventHandler
|
||||
public void onInventoryDrag(InventoryDragEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
File file = null; //all panels from ALL files (panel names)
|
||||
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
//this basically just determines if something is dragged.
|
||||
try {
|
||||
if (tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
|
||||
if (e.getOldCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) {
|
||||
clearTemp(p, panelName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}catch(Exception ex){
|
||||
return;
|
||||
}
|
||||
//I cannot use load temp because the Event type is different, also I need to loop through all the items
|
||||
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
|
||||
try {
|
||||
for (int slot : e.getInventorySlots()) {
|
||||
config.set("panels." + panelName + ".item." + slot, tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
//stacks can't be saved to file because it is not accurate in drag drop cases
|
||||
if(config.contains("panels." + panelName + ".item." + slot + ".stack")){
|
||||
config.set("panels." + panelName + ".item." + slot + ".stack",null);
|
||||
}
|
||||
saveFile(file, config);
|
||||
saveFile(file, config);
|
||||
}
|
||||
}catch(NullPointerException nu){
|
||||
plugin.debug(nu,p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onInventoryEdit(InventoryClickEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
String panelName = "";
|
||||
File file = null;
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (e.getView().getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
//change file below
|
||||
/*
|
||||
All item settings will be custom saved and carried over. When inventory is closed, then figure out where items are and allocate the settings to those items...
|
||||
This is so there is no errors with item amounts and also so settings can be moved around easily
|
||||
|
||||
Load temp item if the item is dropped into the panel
|
||||
|
||||
Save temp item if the item is picked up from inside the panel
|
||||
*/
|
||||
if(e.getClick().isShiftClick() && e.getClickedInventory() == e.getView().getTopInventory()){
|
||||
if(e.getInventory().getItem(e.getSlot()) == null) {
|
||||
return;
|
||||
}
|
||||
onEditPanelClose(p,e.getInventory(),e.getView());
|
||||
inventoryItemSettingsOpening.add(p.getName());
|
||||
//refresh the yaml config
|
||||
config = YamlConfiguration.loadConfiguration(file);
|
||||
plugin.editorGuis.openItemSettings(p,panelName,config.getConfigurationSection("panels." + panelName + ".item." + e.getSlot()), String.valueOf(e.getSlot()));
|
||||
p.updateInventory();
|
||||
return;
|
||||
}
|
||||
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName() + ".material")) {
|
||||
if(!plugin.getHeads.ifSkullOrHead(Objects.requireNonNull(e.getCursor()).getType().toString())) {
|
||||
//if the material doesn't match and also isn't a PLAYER_HEAD
|
||||
if (e.getCursor().getType() != Material.matchMaterial(Objects.requireNonNull(tempEdit.getString("panels." + panelName + ".temp." + p.getName() + ".material")))) {
|
||||
clearTemp(p, panelName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(e.getSlot() == -999){
|
||||
if(e.getCurrentItem() == null) {
|
||||
clearTemp(p, panelName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(e.getAction() == InventoryAction.CLONE_STACK){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_ALL){
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
clearTemp(p, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
removeOldItem(e, p, config, file, panelName);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ALL_CURSOR){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ALL_SLOT){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ONE_CURSOR){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.DROP_ONE_SLOT){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.HOTBAR_SWAP){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_SOME){
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){
|
||||
e.setCancelled(true);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_ALL){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
removeOldItem(e, p, config, file, panelName);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_HALF){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_ONE){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PICKUP_SOME){
|
||||
saveTempItem(e, p, config, panelName);
|
||||
saveFile(file,config);
|
||||
}else if(e.getAction() == InventoryAction.PLACE_ONE){
|
||||
loadTempItem(e, p, config, file, panelName);
|
||||
saveFile(file,config);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerClosePanel(InventoryCloseEvent e){
|
||||
//this is put here to avoid conflicts, close panel if it is open
|
||||
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName(),PanelPosition.Top)){
|
||||
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
|
||||
return;
|
||||
}
|
||||
//do editor settings if it is not a regular panel
|
||||
if(inventoryItemSettingsOpening.contains(e.getPlayer().getName())) {
|
||||
inventoryItemSettingsOpening.remove(e.getPlayer().getName());
|
||||
return;
|
||||
}
|
||||
onEditPanelClose((Player) e.getPlayer(), e.getInventory(), e.getView());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPanelSettings(InventoryClickEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!p.getOpenInventory().getTitle().contains("Panel Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
boolean hotbarItems = false;
|
||||
try {
|
||||
//need to loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Panel Settings: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
if(panel.getConfig().contains("open-with-item")){
|
||||
hotbarItems = true;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
if(e.getSlot() == 1){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.perm"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Permission"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 3){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.title"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Title"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 5){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.sound-on-open"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Sound ID"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 7){
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 21){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.delete"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Are you sure? (yes/no)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 23){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.rows"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Row Amount (1 to 6)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 13){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.empty"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material ID"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 15){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Command"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.commands-on-open.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Command to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 17){
|
||||
//adds abilities to add and remove types
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Panel type"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.panelType.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Panel Type to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 25){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New World Name"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "panel.disabled-worlds.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter World line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 11){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.name"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 18){
|
||||
plugin.editorGuis.openEditorGui(p,0);
|
||||
p.updateInventory();
|
||||
}
|
||||
if(e.getSlot() == 40){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.material"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Material"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 38 && hotbarItems){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.name"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Name"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 36 && hotbarItems){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.lore.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 42 && hotbarItems){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.stationary"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Location (0 to 35)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 44 && hotbarItems){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"panel.hotbar.commands.remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSettings(InventoryClickEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!p.getOpenInventory().getTitle().contains("Item Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
ConfigurationSection panelYaml = null; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
try {
|
||||
//loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Item Settings: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
panelYaml = panel.getConfig();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
String itemSlot;
|
||||
try {
|
||||
itemSlot = ChatColor.stripColor(e.getView().getTopInventory().getItem(35).getItemMeta().getDisplayName().split("\\s")[2]);
|
||||
}catch(Exception ex){
|
||||
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
|
||||
plugin.debug(ex,p);
|
||||
return;
|
||||
}
|
||||
if(e.getSlot() == 1){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":name"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Name"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 3){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Command"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":commands:remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter command line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 5){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":enchanted"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Enchantment"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 7){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":potion"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Potion Effect"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 13){
|
||||
//adds abilities to add and remove items
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item Location/s"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":duplicate:remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Duplicate Item/s to Remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 19){
|
||||
//adds abilities to add and remove lines
|
||||
if(e.getClick().isLeftClick()) {
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:add"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Lore"));
|
||||
}else{
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(), panelName, "item:" + itemSlot + ":lore:remove"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter lore line to remove (must be an integer)"));
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 21){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":stack"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Item Stack (must be an integer)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 23){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":customdata"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Model Data"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 25){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":leatherarmor"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Leather Armor Colour"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 31){
|
||||
//section includes the slot number at the front
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + itemSlot), itemSlot);
|
||||
p.updateInventory();
|
||||
}
|
||||
if(e.getSlot() == 35){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"item:" + itemSlot + ":head"});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter New Custom Material (eg. cps= self)"));
|
||||
p.closeInventory();
|
||||
}
|
||||
if(e.getSlot() == 27){
|
||||
if(itemSlot.contains(".")){
|
||||
String newSection = itemSlot.substring(0, itemSlot.lastIndexOf("."));
|
||||
plugin.editorGuis.openItemSections(p,panelName,panelYaml.getConfigurationSection("item." + newSection), newSection);
|
||||
}else {
|
||||
plugin.createGUI.openGui(new Panel(panelYaml, panelName), p,PanelPosition.Top, PanelOpenType.Editor, 0);
|
||||
}
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
//item section viewer click event
|
||||
@EventHandler
|
||||
public void onItemSection(InventoryClickEvent e) {
|
||||
Player p = (Player)e.getWhoClicked();
|
||||
if(!p.getOpenInventory().getTitle().contains("Item Sections:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
ConfigurationSection panelYaml = null;
|
||||
ConfigurationSection itemConfSection; //all panels from ALL files (panel names)
|
||||
boolean found = false;
|
||||
try {
|
||||
//loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if(e.getView().getTitle().equals("Item Sections: " + panel.getName())){
|
||||
panelName = panel.getName();
|
||||
panelYaml = panel.getConfig();
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
|
||||
//this section includes slot at front
|
||||
String section;
|
||||
try {
|
||||
section = ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(e.getView().getTopInventory().getItem(44)).getItemMeta()).getDisplayName().split("\\s")[2]);
|
||||
}catch(Exception ex){
|
||||
plugin.getServer().getConsoleSender().sendMessage("[CommandPanels] Could not get item slot");
|
||||
plugin.debug(ex,p);
|
||||
return;
|
||||
}
|
||||
itemConfSection = panelYaml.getConfigurationSection("item." + section);
|
||||
|
||||
if(e.getSlot() <= 35){
|
||||
if(e.getInventory().getItem(e.getSlot()) != null){
|
||||
if(e.getClick().isLeftClick()) {
|
||||
String newSection = section + "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
|
||||
plugin.editorGuis.openItemSettings(p, panelName, itemConfSection.getConfigurationSection(ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName())), newSection);
|
||||
p.updateInventory();
|
||||
}else{
|
||||
String itemNameSection = "." + ChatColor.stripColor(e.getInventory().getItem(e.getSlot()).getItemMeta().getDisplayName());
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.change." + section + itemNameSection});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Setting to change, eg, value:500"));
|
||||
p.closeInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(e.getSlot() == 38){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.remove." + section});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to remove, eg, hasperm or hasperm0"));
|
||||
p.closeInventory();
|
||||
}
|
||||
|
||||
if(e.getSlot() == 42){
|
||||
plugin.editorInputStrings.add(new String[]{p.getName(),panelName,"section.add." + section});
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.WHITE + "Enter Section name to add, eg, hasperm or hasperm0"));
|
||||
p.closeInventory();
|
||||
}
|
||||
|
||||
if(e.getSlot() == 36){
|
||||
plugin.editorGuis.openItemSettings(p,panelName,itemConfSection, section);
|
||||
p.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void saveTempItem(InventoryClickEvent e, Player p, YamlConfiguration file, String panelName){
|
||||
//saves item to temp, using getslot
|
||||
tempEdit.set("panels." + panelName + ".temp." + p.getName(),file.get("panels." + panelName + ".item." + e.getSlot()));
|
||||
saveFile("temp.yml", tempEdit);
|
||||
}
|
||||
public void loadTempItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
|
||||
//loads temp item to the current item
|
||||
if(tempEdit.contains("panels." + panelName + ".temp." + p.getName())){
|
||||
config.set("panels." + panelName + ".item." + e.getSlot(),tempEdit.get("panels." + panelName + ".temp." + p.getName()));
|
||||
saveFile(file, config);
|
||||
}
|
||||
}
|
||||
public void removeOldItem(InventoryClickEvent e, Player p, YamlConfiguration config,File file, String panelName){
|
||||
//removes the old item from config, if it has been picked up (use this only after saving)
|
||||
config.set("panels." + panelName + ".item." + e.getSlot(),null);
|
||||
saveFile(file, config);
|
||||
}
|
||||
public void clearTemp(Player p, String panelName){
|
||||
//empty temp item
|
||||
tempEdit.set("panels." + panelName + ".temp." + p.getName(),null);
|
||||
saveFile("temp.yml", tempEdit);
|
||||
}
|
||||
public void saveFile(String fileName, YamlConfiguration file){
|
||||
try {
|
||||
file.save(new File(plugin.getDataFolder() + File.separator + fileName));
|
||||
} catch (IOException s) {
|
||||
plugin.debug(s,null);
|
||||
}
|
||||
}
|
||||
public void saveFile(File file, YamlConfiguration config){
|
||||
try {
|
||||
config.save(file);
|
||||
} catch (IOException s) {
|
||||
plugin.debug(s,null);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onEditPanelClose(Player p, Inventory inv, InventoryView invView) {
|
||||
if(!p.getOpenInventory().getTitle().contains("Editing Panel:")){
|
||||
return;
|
||||
}
|
||||
if(!p.hasPermission("commandpanel.edit")){
|
||||
return;
|
||||
}
|
||||
String panelName = ""; //all panels from ALL files (panel names)
|
||||
File file = null; //all panels from ALL files (panel names)
|
||||
YamlConfiguration config = new YamlConfiguration(); //all panels from ALL files (panel yaml files)
|
||||
boolean found = false;
|
||||
try {
|
||||
//neew to loop through files to get file names
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
if (invView.getTitle().equals("Editing Panel: " + panel.getName())) {
|
||||
panelName = panel.getName();
|
||||
file = panel.getFile();
|
||||
config = YamlConfiguration.loadConfiguration(panel.getFile());
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}catch(Exception fail){
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
if(!found){
|
||||
return;
|
||||
}
|
||||
//save items as they appear
|
||||
config = plugin.itemCreate.generatePanelFile(panelName,inv,config);
|
||||
try {
|
||||
config.save(file);
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.GREEN + "Saved Changes!"));
|
||||
} catch (IOException s) {
|
||||
p.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Could Not Save Changes!"));
|
||||
plugin.debug(s,p);
|
||||
}
|
||||
plugin.reloadPanelFiles();
|
||||
}
|
||||
}
|
@ -1,570 +0,0 @@
|
||||
package me.rockyhawk.commandpanels.ingameeditor;
|
||||
|
||||
import me.rockyhawk.commandpanels.CommandPanels;
|
||||
import me.rockyhawk.commandpanels.api.Panel;
|
||||
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
|
||||
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class OpenEditorGuis {
|
||||
CommandPanels plugin;
|
||||
public OpenEditorGuis(CommandPanels pl) {
|
||||
plugin = pl;
|
||||
}
|
||||
|
||||
public void openEditorGui(Player p, int pageChange) {
|
||||
Inventory i = Bukkit.createInventory(null, 54, "Command Panels Editor");
|
||||
ArrayList<String> panelNames = new ArrayList<>(); //all panels from ALL files (panel names)
|
||||
ArrayList<String> panelTitles = new ArrayList<>(); //all panels from ALL files (panel titles)
|
||||
ArrayList<ItemStack> panelItems = new ArrayList<>(); //all panels from ALL files (panel materials)
|
||||
try {
|
||||
for(Panel panel : plugin.panelList) { //will loop through all the files in folder
|
||||
panelNames.add(plugin.tex.colour(panel.getName()));
|
||||
panelTitles.add(plugin.tex.colour(panel.getConfig().getString("title")));
|
||||
if (panel.getConfig().contains("open-with-item.material")) {
|
||||
panelItems.add(panel.getHotbarItem(p));
|
||||
} else {
|
||||
panelItems.add(new ItemStack(Material.PAPER));
|
||||
}
|
||||
}
|
||||
} catch (Exception fail) {
|
||||
//could not fetch all panel names (probably no panels exist)
|
||||
plugin.debug(fail,p);
|
||||
return;
|
||||
}
|
||||
|
||||
int pageNumber = 1;
|
||||
if (p.getOpenInventory().getTitle().equals("Command Panels Editor")) {
|
||||
pageNumber = Integer.parseInt(ChatColor.stripColor(Objects.requireNonNull(Objects.requireNonNull(p.getOpenInventory().getItem(49)).getItemMeta()).getDisplayName()).replace("Page ", ""));
|
||||
}
|
||||
//will add the difference
|
||||
pageNumber = pageNumber + pageChange;
|
||||
if (pageNumber <= 0) {
|
||||
//double check page number IS NOT under 1
|
||||
pageNumber = 1;
|
||||
}
|
||||
//get amount of pages total
|
||||
int pagesAmount = (int) Math.ceil(panelNames.size() / 45.0);
|
||||
//make all the bottom bar items
|
||||
ItemStack temp;
|
||||
temp = new ItemStack(Material.SLIME_BALL, 1);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Page " + pageNumber, null, p, true, true, true);
|
||||
i.setItem(49, temp);
|
||||
temp = new ItemStack(Material.BARRIER, 1);
|
||||
plugin.setName(null,temp, ChatColor.RED + "Exit Menu", null, p, true, true, true);
|
||||
i.setItem(45, temp);
|
||||
temp = new ItemStack(Material.BOOK, 1);
|
||||
List<String> lore = new ArrayList();
|
||||
lore.add(ChatColor.GRAY + "- Click on a panel to edit items.");
|
||||
lore.add(ChatColor.GRAY + "- Right click on a panel to edit settings.");
|
||||
lore.add(ChatColor.GRAY + "- To edit an item in a panel, shift click");
|
||||
lore.add(ChatColor.GRAY + " on the item of choice.");
|
||||
lore.add(ChatColor.GRAY + "- When entering a value,");
|
||||
lore.add(ChatColor.GRAY + " type 'remove' to set a");
|
||||
lore.add(ChatColor.GRAY + " value to default, and use");
|
||||
lore.add(ChatColor.GRAY + " '" + plugin.config.getString("config.input-cancel") + "' to cancel.");
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Editor Tips", lore, p, true, true, true);
|
||||
i.setItem(53, temp);
|
||||
if (pageNumber != 1) {
|
||||
//only show previous page button if number is not one
|
||||
temp = new ItemStack(Material.PAPER, 1);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Previous Page", null, p, true, true, true);
|
||||
i.setItem(48, temp);
|
||||
}
|
||||
if (pageNumber < pagesAmount) {
|
||||
//if page number is under pages amount
|
||||
temp = new ItemStack(Material.PAPER, 1);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Next Page", null, p, true, true, true);
|
||||
i.setItem(50, temp);
|
||||
}
|
||||
int count = 0;
|
||||
int slot = 0;
|
||||
lore.clear();
|
||||
for (String panelName : panelNames) {
|
||||
//count is +1 because count starts at 0 not 1
|
||||
if ((pageNumber * 45 - 45) < (count + 1) && (pageNumber * 45) > (count)) {
|
||||
temp = panelItems.get(count);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + panelName, lore, p, false, true, true);
|
||||
i.setItem(slot, temp);
|
||||
slot += 1;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void openPanelSettings(Player p, String panelName, ConfigurationSection cf) {
|
||||
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Panel Settings: " + panelName));
|
||||
List<String> lore = new ArrayList();
|
||||
ItemStack temp;
|
||||
//remove if the player already had a string from previously
|
||||
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
|
||||
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
|
||||
plugin.editorInputStrings.remove(o);
|
||||
o = o - 1;
|
||||
}
|
||||
}
|
||||
//make all the items
|
||||
temp = new ItemStack(Material.IRON_INGOT, 1);
|
||||
lore.add(ChatColor.GRAY + "Permission required to open panel");
|
||||
lore.add(ChatColor.GRAY + "commandpanel.panel.[insert]");
|
||||
if (cf.contains("perm")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + "commandpanel.panel." + cf.getString("perm"));
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Permission", lore, p, true, true, true);
|
||||
i.setItem(1, temp);
|
||||
|
||||
temp = new ItemStack(Material.NAME_TAG, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Title of the Panel");
|
||||
if (cf.contains("title")) {
|
||||
lore.add(ChatColor.WHITE + "------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("title"));
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Title", lore, p, true, true, true);
|
||||
i.setItem(3, temp);
|
||||
|
||||
temp = new ItemStack(Material.JUKEBOX, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Sound when opening panel");
|
||||
if (cf.contains("sound-on-open")) {
|
||||
lore.add(ChatColor.WHITE + "------------------------");
|
||||
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("sound-on-open")).toUpperCase());
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Sound", lore, p, true, true, true);
|
||||
i.setItem(5, temp);
|
||||
|
||||
temp = new ItemStack(Material.IRON_DOOR, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Custom commands to open panel");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add command");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove command");
|
||||
if (cf.contains("commands")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("commands")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Command", lore, p, true, true, true);
|
||||
i.setItem(7, temp);
|
||||
|
||||
temp = new ItemStack(Material.LAVA_BUCKET, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.DARK_RED + "Permanently delete Panel");
|
||||
plugin.setName(null,temp, ChatColor.RED + "Delete Panel", lore, p, true, true, true);
|
||||
i.setItem(21, temp);
|
||||
|
||||
temp = new ItemStack(Material.LADDER, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "How many rows the panel will be");
|
||||
lore.add(ChatColor.GRAY + "choose an integer from 1 to 6");
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Rows", lore, p, true, true, true);
|
||||
i.setItem(23, temp);
|
||||
|
||||
temp = new ItemStack(Material.STONE, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Worlds that cannot access the panel");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add world");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove world");
|
||||
if (cf.contains("disabled-worlds")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("disabled-worlds")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Disabled Worlds", lore, p, true, true, true);
|
||||
i.setItem(25, temp);
|
||||
|
||||
temp = new ItemStack(Material.GLASS, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Fill empty slots with an item");
|
||||
if (cf.contains("empty")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------");
|
||||
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("empty")).toUpperCase());
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Empty Item", lore, p, true, true, true);
|
||||
i.setItem(13, temp);
|
||||
|
||||
temp = new ItemStack(Material.ANVIL, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Execute commands when opening");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add command");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove command");
|
||||
if (cf.contains("commands-on-open")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("commands-on-open")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Commands", lore, p, true, true, true);
|
||||
i.setItem(15, temp);
|
||||
|
||||
temp = new ItemStack(Material.STRING, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Special panel types");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add panel type");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove panel type");
|
||||
if (cf.contains("panelType")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("panelType")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Types", lore, p, true, true, true);
|
||||
i.setItem(17, temp);
|
||||
|
||||
temp = new ItemStack(Material.ITEM_FRAME, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Code name to open panel");
|
||||
lore.add(ChatColor.GRAY + "/cp [name]");
|
||||
lore.add(ChatColor.WHITE + "-----------------------");
|
||||
lore.add(ChatColor.WHITE + panelName);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Name", lore, p, true, true, true);
|
||||
i.setItem(11, temp);
|
||||
|
||||
temp = new ItemStack(Material.BARRIER, 1);
|
||||
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
|
||||
i.setItem(18, temp);
|
||||
|
||||
//This will create a wall of glass panes, separating panel settings with hotbar settings
|
||||
if(plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
||||
temp = new ItemStack(Material.matchMaterial("STAINED_GLASS_PANE"), 1,(short)15);
|
||||
}else{
|
||||
temp = new ItemStack(Material.matchMaterial("BLACK_STAINED_GLASS_PANE"), 1);
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "", null, p,false, true, true);
|
||||
for(int d = 27; d < 36; d++){
|
||||
i.setItem(d, temp);
|
||||
}
|
||||
//This is the items for hotbar items (open-with-item)
|
||||
boolean hotbarItems = false;
|
||||
|
||||
if(cf.contains("open-with-item.material")){
|
||||
hotbarItems = true;
|
||||
temp = plugin.itemCreate.makeItemFromConfig(null, PanelPosition.Top,cf.getConfigurationSection("open-with-item"), p, false, true, false);
|
||||
}else{
|
||||
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
|
||||
}
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Current Item");
|
||||
if (cf.contains("open-with-item.material")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------");
|
||||
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.material")).toUpperCase());
|
||||
}else{
|
||||
lore.add(ChatColor.WHITE + "-----------------------");
|
||||
lore.add(ChatColor.RED + "DISABLED");
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Panel Hotbar Item", lore, p, true, true, true);
|
||||
i.setItem(40, temp);
|
||||
|
||||
if(hotbarItems) {
|
||||
temp = new ItemStack(Material.NAME_TAG, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Name for Hotbar item");
|
||||
if (cf.contains("open-with-item.name")) {
|
||||
lore.add(ChatColor.WHITE + "----------");
|
||||
lore.add(ChatColor.WHITE + Objects.requireNonNull(cf.getString("open-with-item.name")));
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Name", lore, p, true, true, true);
|
||||
i.setItem(38, temp);
|
||||
|
||||
temp = new ItemStack(Material.FEATHER, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Display a lore under the Hotbar item");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add lore");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove lore");
|
||||
if (cf.contains("open-with-item.lore")) {
|
||||
lore.add(ChatColor.WHITE + "-------------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("open-with-item.lore")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Lore", lore, p, true, true, true);
|
||||
i.setItem(36, temp);
|
||||
|
||||
temp = new ItemStack(Material.BEDROCK, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Hotbar location for the item");
|
||||
lore.add(ChatColor.GRAY + "choose a number from 0 to 35");
|
||||
if (cf.contains("open-with-item.stationary")) {
|
||||
lore.add(ChatColor.WHITE + "-------------------------");
|
||||
int location = cf.getInt("open-with-item.stationary");
|
||||
lore.add(ChatColor.WHITE + String.valueOf(location));
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Location", lore, p, true, true, true);
|
||||
i.setItem(42, temp);
|
||||
|
||||
temp = new ItemStack(Material.BOOK, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Execute commands from Hotbar Item");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add command");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove command");
|
||||
lore.add(ChatColor.GRAY + "If commands are added, the item will");
|
||||
lore.add(ChatColor.GRAY + "no longer automatically open the panel");
|
||||
if (cf.contains("open-with-item.commands")) {
|
||||
lore.add(ChatColor.WHITE + "-------------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("open-with-item.commands")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Hotbar Item Commands", lore, p, true, true,true);
|
||||
i.setItem(44, temp);
|
||||
}
|
||||
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
|
||||
public void openItemSettings(Player p, String panelName, ConfigurationSection cf, String section) {
|
||||
Inventory i = Bukkit.createInventory(null, 36, ChatColor.stripColor("Item Settings: " + panelName));
|
||||
List<String> lore = new ArrayList();
|
||||
ItemStack temp;
|
||||
//remove if the player already had a string from previously
|
||||
for (int o = 0; plugin.editorInputStrings.size() > o; o++) {
|
||||
if (plugin.editorInputStrings.get(o)[0].equals(p.getName())) {
|
||||
plugin.editorInputStrings.remove(o);
|
||||
o = o - 1;
|
||||
}
|
||||
}
|
||||
//make all the items
|
||||
temp = new ItemStack(Material.NAME_TAG, 1);
|
||||
lore.add(ChatColor.GRAY + "Display name of the item in the Panel");
|
||||
if (cf.contains("name")) {
|
||||
if (!Objects.equals(cf.getString("name"), "")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("name"));
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Name", lore, p, true, true, true);
|
||||
i.setItem(1, temp);
|
||||
|
||||
temp = new ItemStack(Material.ANVIL, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Execute commands when item is clicked");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add command");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove command");
|
||||
if (cf.contains("commands")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("commands")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Commands", lore, p, true, true, true);
|
||||
i.setItem(3, temp);
|
||||
|
||||
temp = new ItemStack(Material.ENCHANTED_BOOK, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Display enchantment of the item in the Panel");
|
||||
if (cf.contains("enchanted")) {
|
||||
if (!Objects.equals(cf.getString("name"), "")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("enchanted"));
|
||||
}
|
||||
} else {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + "false");
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Enchantment", lore, p, true, true, true);
|
||||
i.setItem(5, temp);
|
||||
|
||||
temp = new ItemStack(Material.POTION, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Display potion effect of the item in the Panel");
|
||||
if (cf.contains("potion")) {
|
||||
if (!Objects.equals(cf.getString("potion"), "")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("potion"));
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Potion Effect", lore, p, true, true, true);
|
||||
i.setItem(7, temp);
|
||||
|
||||
temp = new ItemStack(Material.PAPER, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Duplicate item visuals in other slots");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add duplicate item/s");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove duplicate item/s");
|
||||
if (cf.contains("duplicate")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getString("duplicate").split(",")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Duplicates", lore, p, true, true, true);
|
||||
i.setItem(13, temp);
|
||||
|
||||
temp = new ItemStack(Material.FEATHER, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Display a lore under the item name");
|
||||
lore.add(ChatColor.GRAY + "- Left click to add lore line");
|
||||
lore.add(ChatColor.GRAY + "- Right click to remove lore line");
|
||||
if (cf.contains("lore")) {
|
||||
lore.add(ChatColor.WHITE + "-----------------------------");
|
||||
int count = 1;
|
||||
for (String tempLore : cf.getStringList("lore")) {
|
||||
lore.add(ChatColor.WHITE + Integer.toString(count) + ") " + tempLore);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Lores", lore, p, true, true, true);
|
||||
i.setItem(19, temp);
|
||||
|
||||
temp = new ItemStack(Material.ITEM_FRAME, 2);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "How many of the item will be stacked");
|
||||
if (cf.contains("stack")) {
|
||||
if (!Objects.equals(cf.getString("stack"), "")) {
|
||||
try {
|
||||
temp.setAmount(Integer.parseInt(Objects.requireNonNull(cf.getString("stack"))));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("stack"));
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Stack Size", lore, p, true, true, true);
|
||||
i.setItem(21, temp);
|
||||
|
||||
if(!plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_15)) {
|
||||
temp = new ItemStack(Material.PAINTING, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Add Custom Model Data here");
|
||||
if (cf.contains("customdata")) {
|
||||
if (!Objects.equals(cf.getString("customdata"), "")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("customdata"));
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Custom Model Data", lore, p, true, true, true);
|
||||
i.setItem(23, temp);
|
||||
}
|
||||
|
||||
/*show the compass that opens the viewer for the sections..
|
||||
it will only show the sections immidiatly under the other, so
|
||||
if there is a hasperm inside another hasperm, it will not appear
|
||||
until the other hasperm is opened.
|
||||
*/
|
||||
temp = new ItemStack(Material.COMPASS, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "View the items different");
|
||||
lore.add(ChatColor.GRAY + "Sections and add complex values.");
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + section);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Sections", lore, p, true, true, true);
|
||||
i.setItem(31, temp);
|
||||
|
||||
temp = new ItemStack(Material.LEATHER_HELMET, 1);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Choose a colour for the armor");
|
||||
lore.add(ChatColor.GRAY + "use r,g,b or a spigot API color");
|
||||
if (cf.contains("leatherarmor")) {
|
||||
if (!Objects.equals(cf.getString("leatherarmor"), "")) {
|
||||
lore.add(ChatColor.WHITE + "--------------------------------");
|
||||
lore.add(ChatColor.WHITE + cf.getString("leatherarmor"));
|
||||
}
|
||||
}
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Leather Armor Colour", lore, p, true, true, true);
|
||||
i.setItem(25, temp);
|
||||
|
||||
temp = new ItemStack(Material.BARRIER, 1);
|
||||
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
|
||||
i.setItem(27, temp);
|
||||
|
||||
temp = plugin.itemCreate.makeItemFromConfig(null,PanelPosition.Top,cf,p,false,false, false);
|
||||
lore.clear();
|
||||
lore.add(ChatColor.GRAY + "Click to set custom material");
|
||||
lore.add(ChatColor.GRAY + "typically for custom heads");
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + section + " Preview", lore, p, true, true, true);
|
||||
i.setItem(35, temp);
|
||||
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
//section is similar to hassection, but with the slot eg, 1.hasperm.hasvalue
|
||||
public void openItemSections(Player p, String panelName, ConfigurationSection cf, String itemSection) {
|
||||
Inventory i = Bukkit.createInventory(null, 45, ChatColor.stripColor("Item Sections: " + panelName));
|
||||
ItemStack temp;
|
||||
int slot = 0;
|
||||
for(String section : cf.getKeys(false)){
|
||||
//get list of item sections
|
||||
if(slot > 35){
|
||||
break;
|
||||
}
|
||||
if(section.contains("hasperm") || section.contains("hasvalue") || section.contains("hasgreater")){
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(ChatColor.GRAY + "Left click to open item");
|
||||
lore.add(ChatColor.GRAY + "Right click to change below settings");
|
||||
if(cf.contains(section + ".output")) {
|
||||
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + cf.getString(section + ".output"));
|
||||
}else{
|
||||
lore.add(ChatColor.WHITE + "Output: " + ChatColor.GRAY + "true");
|
||||
}
|
||||
if(cf.contains(section + ".perm")) {
|
||||
lore.add(ChatColor.WHITE + "Perm: " + ChatColor.GRAY + cf.getString(section + ".perm"));
|
||||
}
|
||||
if(cf.contains(section + ".value")) {
|
||||
lore.add(ChatColor.WHITE + "Value: " + ChatColor.GRAY + cf.getString(section + ".value"));
|
||||
}
|
||||
if(cf.contains(section + ".compare")) {
|
||||
lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
|
||||
}
|
||||
|
||||
temp = plugin.itemCreate.makeItemFromConfig(null,PanelPosition.Top,cf.getConfigurationSection(section),p,false,false, false);
|
||||
plugin.setName(null,temp, ChatColor.AQUA + section, lore, p,false, true, true);
|
||||
i.setItem(slot, temp);
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
|
||||
temp = new ItemStack(Material.REDSTONE, 1);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Remove Section", null, p, true, true, true);
|
||||
i.setItem(38, temp);
|
||||
|
||||
temp = new ItemStack(Material.SLIME_BALL, 1);
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Add Section", null, p, true, true, true);
|
||||
i.setItem(42, temp);
|
||||
|
||||
temp = new ItemStack(Material.BARRIER, 1);
|
||||
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
|
||||
i.setItem(36, temp);
|
||||
|
||||
temp = new ItemStack(Material.BOOK, 1);
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add(ChatColor.GRAY + "Section Types:");
|
||||
lore.add(ChatColor.GRAY + "- hasperm");
|
||||
lore.add(ChatColor.GRAY + "- hasvalue");
|
||||
lore.add(ChatColor.GRAY + "- hasgreater");
|
||||
plugin.setName(null,temp, ChatColor.WHITE + "Item Section " + itemSection, lore, p, true, true, true);
|
||||
i.setItem(44, temp);
|
||||
|
||||
p.openInventory(i);
|
||||
}
|
||||
}
|
@ -85,7 +85,7 @@ public class Commandpanelrefresher implements Listener {
|
||||
}
|
||||
}
|
||||
try {
|
||||
if(plugin.debug.isEnabled(p)){
|
||||
if(plugin.debug.isEnabled(p) && pn.getFile() != null){
|
||||
//reload the panel is debug is enabled (only personal debug)
|
||||
pn.setConfig(YamlConfiguration.loadConfiguration(pn.getFile()));
|
||||
}
|
||||
|
@ -64,7 +64,12 @@ public class UserInputUtils implements Listener {
|
||||
}
|
||||
|
||||
public void sendMessage(Panel panel, PanelPosition pos, Player p){
|
||||
List<String> inputMessages = new ArrayList<>(plugin.config.getStringList("input.input-message"));
|
||||
List<String> inputMessages;
|
||||
if(panel.getConfig().contains("custom-messages.input-message")){
|
||||
inputMessages = new ArrayList<>(panel.getConfig().getStringList("custom-messages.input-message"));
|
||||
}else{
|
||||
inputMessages = new ArrayList<>(plugin.config.getStringList("input.input-message"));
|
||||
}
|
||||
for (String temp : inputMessages) {
|
||||
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("input.input-cancel")));
|
||||
p.sendMessage(plugin.tex.placeholders(panel,pos,p, temp));
|
||||
|
@ -12,7 +12,9 @@ public enum MinecraftVersions {
|
||||
v1_16( "1_16", 8 ),
|
||||
v1_17( "1_17", 9 ),
|
||||
v1_18( "1_18", 10 ),
|
||||
v1_19( "1_19", 11 );
|
||||
v1_19( "1_19", 11 ),
|
||||
v1_20( "1_20", 12 ),
|
||||
v1_21( "1_21", 13 );
|
||||
|
||||
private int order;
|
||||
private String key;
|
||||
|
@ -41,10 +41,7 @@ public class UtilsPanelsLoader implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerClosePanel(InventoryCloseEvent e){
|
||||
//only do this if editor is disabled as it will disabled this code
|
||||
if(!Objects.requireNonNull(plugin.config.getString("config.ingame-editor")).equalsIgnoreCase("true")) {
|
||||
//this is put here to avoid conflicts, close panel if it is closed
|
||||
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
|
||||
}
|
||||
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user