This commit is contained in:
rockyhawk64 2021-07-13 20:05:30 +10:00
parent c26f8b2037
commit e7b7872294
53 changed files with 1413 additions and 552 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,180 @@
# |------------------------------------------------------------------------
# | CommandPanels Example File
# | By RockyHawk v3.0
# | https://www.spigotmc.org/resources/command-panels-custom-guis.67788/
# |------------------------------------------------------------------------
panels:
example_middle_two:
perm: default
rows: 4
title: '&e&lOnline Browser - Page $cp-data-nextpage$'
empty: LIGHT_BLUE_STAINED_GLASS_PANE
panelType:
- nocommand
placeholders:
primary:
start: '$'
end: '$'
secondary:
start: '{'
end: '}'
pre-load-commands:
- add-data= onlinepage 0
- add-data= nextpage 1
item:
'10':
material: 'cps= $cp-player-online-%math_1+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_1+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '$cp-player-online-%math_1+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'11':
material: 'cps= $cp-player-online-%math_2+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_2+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_2+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'12':
material: 'cps= $cp-player-online-%math_3+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_3+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_3+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'13':
material: 'cps= $cp-player-online-%math_4+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_4+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_4+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'14':
material: 'cps= $cp-player-online-%math_5+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_5+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_5+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'15':
material: 'cps= $cp-player-online-%math_6+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_6+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_6+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'16':
material: 'cps= $cp-player-online-%math_7+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_7+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_7+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'19':
material: 'cps= $cp-player-online-%math_8+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_8+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_8+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'20':
material: 'cps= $cp-player-online-%math_9+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_9+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_9+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'21':
material: 'cps= $cp-player-online-%math_10+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_10+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_10+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'22':
material: 'cps= $cp-player-online-%math_11+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_11+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_11+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'23':
material: 'cps= $cp-player-online-%math_12+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_12+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_12+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'24':
material: 'cps= $cp-player-online-%math_13+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_13+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_13+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'25':
material: 'cps= $cp-player-online-%math_14+14*{cp-data-onlinepage}%$'
name: '&e$cp-player-online-%math_14+14*{cp-data-onlinepage}%$'
hasvalue:
compare: '&e$cp-player-online-%math_14+14*{cp-data-onlinepage}%$'
value: 'Offline'
material: cps= eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmMyNzEwNTI3MTllZjY0MDc5ZWU4YzE0OTg5NTEyMzhhNzRkYWM0YzI3Yjk1NjQwZGI2ZmJkZGMyZDZiNWI2ZSJ9fX0=
stack: 1
name: '&7&l????'
'2':
material: LIGHT_BLUE_STAINED_GLASS_PANE
name: "&f"
hasgreater:
compare: '$cp-data-onlinepage$'
value: 1
material: STICK
stack: 1
name: "&c&lLast Page"
commands:
- math-data= onlinepage -1
- math-data= nextpage -1
- refresh
'6':
material: ARROW
stack: 1
name: "&e&lNext Page"
commands:
- 'math-data= onlinepage +1'
- 'math-data= nextpage +1'
- 'refresh'
'4':
material: OAK_SIGN
name: '&e&lOnline Players'
lore:
- '&b$cp-online-players$'
- ''
- '&8Player Browser made by:'
- '&8TinyTank800'

150
resource/example_top.yml Normal file
View File

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

View File

@ -1,4 +1,4 @@
version: 3.16.0.1
version: 3.16.1.0
main: me.rockyhawk.commandpanels.CommandPanels
name: CommandPanels
author: RockyHawk

View File

@ -33,10 +33,7 @@ import me.rockyhawk.commandpanels.ioclasses.nbt.NBTManager;
import me.rockyhawk.commandpanels.ioclasses.legacy.LegacyVersion;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.ioclasses.legacy.PlayerHeads;
import me.rockyhawk.commandpanels.openpanelsmanager.OpenGUI;
import me.rockyhawk.commandpanels.openpanelsmanager.OpenPanelsLoader;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPermissions;
import me.rockyhawk.commandpanels.openpanelsmanager.UtilsPanelsLoader;
import me.rockyhawk.commandpanels.openpanelsmanager.*;
import me.rockyhawk.commandpanels.openwithitem.HotbarItemLoader;
import me.rockyhawk.commandpanels.openwithitem.SwapItemEvent;
import me.rockyhawk.commandpanels.openwithitem.UtilsChestSortEvent;
@ -44,6 +41,8 @@ import me.rockyhawk.commandpanels.openwithitem.UtilsOpenWithItem;
import me.rockyhawk.commandpanels.panelblocks.BlocksTabComplete;
import me.rockyhawk.commandpanels.panelblocks.Commandpanelblocks;
import me.rockyhawk.commandpanels.panelblocks.PanelBlockOnClick;
import me.rockyhawk.commandpanels.playerinventoryhandler.InventorySaver;
import me.rockyhawk.commandpanels.playerinventoryhandler.ItemStackSerializer;
import me.rockyhawk.commandpanels.updater.Updater;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
@ -101,7 +100,10 @@ public class CommandPanels extends JavaPlugin{
public HotbarItemLoader hotbar = new HotbarItemLoader(this);
public NBTManager nbt = new NBTManager(this);
public File panelsf;
public InventorySaver inventorySaver = new InventorySaver(this);
public ItemStackSerializer itemSerializer = new ItemStackSerializer(this);
public File panelsf = new File(this.getDataFolder() + File.separator + "panels");
public YamlConfiguration blockConfig; //where panel block locations are stored
public void onEnable() {
@ -111,9 +113,9 @@ public class CommandPanels extends JavaPlugin{
updater.githubNewUpdate(false);
//register config files
this.panelsf = new File(this.getDataFolder() + File.separator + "panels");
this.blockConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "blocks.yml"));
panelData.dataConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "data.yml"));
inventorySaver.inventoryConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder() + File.separator + "inventories.yml"));
this.config = YamlConfiguration.loadConfiguration(new File(this.getDataFolder() + File.separator + "config.yml"));
//save the config.yml file
@ -152,6 +154,8 @@ public class CommandPanels extends JavaPlugin{
Objects.requireNonNull(this.getCommand("commandpanelversion")).setExecutor(new Commandpanelversion(this));
Objects.requireNonNull(this.getCommand("commandpanellist")).setExecutor(new Commandpanelslist(this));
this.getServer().getPluginManager().registerEvents(new Utils(this), this);
this.getServer().getPluginManager().registerEvents(updater, this);
this.getServer().getPluginManager().registerEvents(inventorySaver, this);
this.getServer().getPluginManager().registerEvents(new UtilsPanelsLoader(this), this);
this.getServer().getPluginManager().registerEvents(new GenUtils(this), this);
this.getServer().getPluginManager().registerEvents(new CommandpanelUserInput(this), this);
@ -201,17 +205,27 @@ public class CommandPanels extends JavaPlugin{
this.getServer().getPluginManager().registerEvents(new UtilsChestSortEvent(this), this);
}
//save the example.yml file and the template.yml file
//save the example_top.yml file and the template.yml file
if (!this.panelsf.exists()) {
try {
FileConfiguration exampleFileConfiguration;
FileConfiguration templateFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("template.yml")));
if(legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)){
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
}else {
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example.yml")));
}
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("exampleLegacy.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example.yml"));
}else {
//top
FileConfiguration exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_top.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_top.yml"));
//middle one
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_one.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_one.yml"));
//middle two
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_middle_two.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_middle_two.yml"));
//bottom
exampleFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("example_bottom.yml")));
exampleFileConfiguration.save(new File(this.panelsf + File.separator + "example_bottom.yml"));
}
FileConfiguration templateFileConfiguration = YamlConfiguration.loadConfiguration(getReaderFromStream(this.getResource("template.yml")));
templateFileConfiguration.save(new File(this.panelsf + File.separator + "template.yml"));
} catch (IOException var11) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " WARNING: Could not save the example file!");
@ -245,7 +259,17 @@ public class CommandPanels extends JavaPlugin{
}
public void onDisable() {
//close all the panels
for(String name : openPanels.openPanels.keySet()){
openPanels.closePanelForLoader(name, PanelPosition.Top);
try {
Bukkit.getPlayer(name).closeInventory();
}catch (Exception ignore){}
}
//save files
panelData.saveDataFile();
inventorySaver.saveInventoryFile();
if (Objects.requireNonNull(this.config.getString("updater.auto-update")).equalsIgnoreCase("true")) {
updater.autoUpdatePlugin(this.getFile().getName());
}
@ -261,7 +285,7 @@ public class CommandPanels extends JavaPlugin{
ItemMeta renamedMeta = renamed.getItemMeta();
//set cp placeholders
if(usePlaceholders){
customName = tex.placeholdersNoColour(panel,p,customName);
customName = tex.placeholdersNoColour(panel,PanelPosition.Top,p,customName);
}
if(useColours){
customName = tex.colour(customName);
@ -279,11 +303,11 @@ public class CommandPanels extends JavaPlugin{
List<String> re_lore;
if (lore != null) {
if(usePlaceholders && useColours){
re_lore = tex.placeholdersList(panel, p, lore, true);
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, true);
}else if(usePlaceholders){
re_lore = tex.placeholdersNoColour(panel,p, lore);
re_lore = tex.placeholdersNoColour(panel,PanelPosition.Top,p, lore);
}else if(useColours){
re_lore = tex.placeholdersList(panel, p, lore, false);
re_lore = tex.placeholdersList(panel,PanelPosition.Top, p, lore, false);
}else{
re_lore = lore;
}

View File

@ -1,6 +1,8 @@
package me.rockyhawk.commandpanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -19,7 +21,7 @@ public class Utils implements Listener {
@EventHandler
public void onItemDrag(InventoryDragEvent e) {
Player p = (Player)e.getWhoClicked();
if(!plugin.openPanels.hasPanelOpen(p.getName())){
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
if(e.getInventory().getType() != InventoryType.PLAYER){
@ -31,32 +33,64 @@ public class Utils implements Listener {
public void onPanelClick(InventoryClickEvent e) {
//when clicked on a panel
Player p = (Player)e.getWhoClicked();
int clickedSlot = e.getSlot();
ItemStack clicked = e.getCurrentItem();
if(!plugin.openPanels.hasPanelOpen(p.getName()) || e.getSlotType() == InventoryType.SlotType.OUTSIDE || e.getClick() == ClickType.DOUBLE_CLICK){
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) || e.getClick() == ClickType.DOUBLE_CLICK){
return;
}
Panel panel = plugin.openPanels.getOpenPanel(p.getName()); //this is the panel cf section
if(e.getSlot() == -999){return;}
//set the panel to the top panel
Panel panel = plugin.openPanels.getOpenPanel(p.getName(),PanelPosition.Top);
if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){
e.setCancelled(true);
}
if(e.getClickedInventory().getType() == InventoryType.PLAYER){
if(panel.getConfig().isSet("panelType")){
if(panel.getConfig().getStringList("panelType").contains("unmovable")){
e.setCancelled(true);
if(e.getSlotType() == InventoryType.SlotType.OUTSIDE){
//if the panel is clicked on the outside area of the GUI
if (panel.getConfig().contains("outside-commands")) {
try {
plugin.commandTags.runCommands(panel,PanelPosition.Top,p, panel.getConfig().getStringList("outside-commands"));
}catch(Exception s){
plugin.debug(s,p);
}
}
return;
}
//loop through possible hasvalue/hasperm 1,2,3,etc
PanelPosition position = PanelPosition.Top;
if(e.getClickedInventory().getType() == InventoryType.PLAYER) {
if (e.getSlotType() == InventoryType.SlotType.CONTAINER) {
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Middle)) {
position = PanelPosition.Middle;
clickedSlot -= 9;
}else{
e.setCancelled(itemsUnmovable(panel));
return;
}
} else{
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Bottom)) {
position = PanelPosition.Bottom;
//this is set to cancelled as if the command is to close the panel and there is a hotbar item in the same slot
//it will also trigger the hotbar item after the panel is closed
e.setCancelled(true);
}else{
e.setCancelled(itemsUnmovable(panel));
return;
}
}
}
//the panels proper position
panel = plugin.openPanels.getOpenPanel(p.getName(),position);
//this loops through all the items in the panel
boolean foundSlot = false;
for(String slot : Objects.requireNonNull(panel.getConfig().getConfigurationSection("item")).getKeys(false)){
if(slot.equals(Integer.toString(e.getSlot()))){
if (slot.equals(Integer.toString(clickedSlot))) {
foundSlot = true;
break;
}
}
if(!foundSlot){
@ -64,10 +98,11 @@ public class Utils implements Listener {
return;
}
String section = plugin.itemCreate.hasSection(panel,panel.getConfig().getConfigurationSection("item." + e.getSlot()), p);
//get the section of the slot that was clicked
String section = plugin.itemCreate.hasSection(panel,position,panel.getConfig().getConfigurationSection("item." + clickedSlot), p);
if(panel.getConfig().contains("item." + e.getSlot() + section + ".itemType")){
if(panel.getConfig().getStringList("item." + e.getSlot() + section + ".itemType").contains("placeable")){
if(panel.getConfig().contains("item." + clickedSlot + section + ".itemType")){
if(panel.getConfig().getStringList("item." + clickedSlot + section + ".itemType").contains("placeable")){
//skip if the item is a placeable
e.setCancelled(false);
return;
@ -85,8 +120,8 @@ public class Utils implements Listener {
}
}
if(panel.getConfig().contains("item." + e.getSlot() + section + ".commands")) {
List<String> commands = panel.getConfig().getStringList("item." + e.getSlot() + section + ".commands");
if(panel.getConfig().contains("item." + clickedSlot + section + ".commands")) {
List<String> commands = panel.getConfig().getStringList("item." + clickedSlot + section + ".commands");
if (commands.size() != 0) {
//this will replace a sequence tag command with the commands from the sequence
List<String> commandsAfterSequence = commands;
@ -155,17 +190,25 @@ public class Utils implements Listener {
//end custom command PlaceHolders
//make the command
String command = plugin.tex.placeholders(panel,p,commands.get(i));
String command = plugin.tex.placeholders(panel,position,p,commands.get(i));
int val = plugin.commandTags.commandPayWall(p,command);
if(val == 0){
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
if(val == PaywallOutput.Blocked){
return;
}
if(val == 2){
plugin.commandTags.runCommand(panel, p, commands.get(i));
if(val == PaywallOutput.NotApplicable){
plugin.commandTags.runCommand(panel,position, p, commands.get(i));
}
}
}
}
}
private boolean itemsUnmovable(Panel panel){
if(panel.getConfig().isSet("panelType")){
//cancel event and return to signal no commands and no movement will occur
return panel.getConfig().getStringList("panelType").contains("unmovable");
}
return false;
}
}

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -9,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Set;
public class CommandPanelsAPI {
CommandPanels plugin;
@ -19,12 +19,12 @@ public class CommandPanelsAPI {
//returns true if the player has a panel open
public boolean isPanelOpen(Player p){
return plugin.openPanels.hasPanelOpen(p.getName());
return plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top);
}
//get the name of a panel currently open, will return null if panel is not open
public Panel getOpenPanel(Player p){
return plugin.openPanels.getOpenPanel(p.getName());
public Panel getOpenPanel(Player p, PanelPosition position){
return plugin.openPanels.getOpenPanel(p.getName(), position);
}
//loaded panels in folder
@ -34,9 +34,14 @@ public class CommandPanelsAPI {
//import panel into folder
public void addPanel(Panel panel) throws IOException{
File addedFile = new File(plugin.panelsf + File.separator + panel.getFile().getName());
YamlConfiguration addedYaml = YamlConfiguration.loadConfiguration(panel.getFile());
addedYaml.save(addedFile);
File addedFile = new File(plugin.panelsf + File.separator + panel.getName() + ".yml");
YamlConfiguration newYaml = new YamlConfiguration();
if(panel.getConfig().contains("panels")){
newYaml.set("",panel.getConfig());
}else{
newYaml.set("panels." + panel.getName(),panel.getConfig());
}
newYaml.save(addedFile);
plugin.reloadPanelFiles();
}
@ -61,8 +66,13 @@ public class CommandPanelsAPI {
return null;
}
//if the players inventory has no panels in it
public boolean hasNormalInventory(Player p){
return plugin.inventorySaver.hasNormalInventory(p);
}
//make custom item using items section
public ItemStack makeItem(Player p, ConfigurationSection itemSection){
return plugin.itemCreate.makeCustomItemFromConfig(null,itemSection, p, true, true, false);
return plugin.itemCreate.makeCustomItemFromConfig(null,PanelPosition.Top,itemSection, p, true, true, false);
}
}

View File

@ -2,6 +2,8 @@ package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.classresources.placeholders.PanelPlaceholders;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@ -10,7 +12,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.stream.Collectors;
public class Panel{
CommandPanels plugin = JavaPlugin.getPlugin(CommandPanels.class);
@ -20,6 +21,7 @@ public class Panel{
private String panelName;
private File panelFile;
public PanelPlaceholders placeholders = new PanelPlaceholders();
public boolean isOpen = false;
//make the object, using a file is recommended
public Panel(File file, String name){
@ -69,19 +71,19 @@ public class Panel{
}
public ItemStack getItem(Player p, int slot){
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("item." + slot), p);
String section = plugin.itemCreate.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("item." + slot), p);
ConfigurationSection itemSection = panelConfig.getConfigurationSection("item." + slot + section);
return plugin.itemCreate.makeItemFromConfig(this,itemSection, p, true, true, false);
return plugin.itemCreate.makeItemFromConfig(this,PanelPosition.Top,itemSection, p, true, true, false);
}
public ItemStack getCustomItem(Player p, String itemName){
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("custom-item." + itemName), p);
String section = plugin.itemCreate.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("custom-item." + itemName), p);
ConfigurationSection itemSection = panelConfig.getConfigurationSection("custom-item." + itemName + section);
return plugin.itemCreate.makeCustomItemFromConfig(this,itemSection, p, true, true, false);
return plugin.itemCreate.makeCustomItemFromConfig(this,PanelPosition.Top,itemSection, p, true, true, false);
}
public ItemStack getHotbarItem(Player p){
ItemStack s = plugin.itemCreate.makeItemFromConfig(this,getHotbarSection(p), p, true, true, false);
ItemStack s = plugin.itemCreate.makeItemFromConfig(this,PanelPosition.Top,getHotbarSection(p), p, true, true, false);
int slot = -1;
if(getHotbarSection(p).isSet("stationary")){
slot = getHotbarSection(p).getInt("stationary");
@ -89,7 +91,7 @@ public class Panel{
return plugin.nbt.setNBT(s,"CommandPanelsHotbar",panelName + ":" + slot);
}
public ConfigurationSection getHotbarSection(Player p){
String section = plugin.itemCreate.hasSection(this,panelConfig.getConfigurationSection("open-with-item"), p);
String section = plugin.itemCreate.hasSection(this,PanelPosition.Top,panelConfig.getConfigurationSection("open-with-item"), p);
return panelConfig.getConfigurationSection("open-with-item" + section);
}
@ -97,17 +99,15 @@ public class Panel{
return this.panelConfig.contains("open-with-item");
}
//this will make a preview of the inventory using a certain player
//this will make a preview of the inventory using a certain player on the top
public Inventory getInventory(Player p){
return plugin.createGUI.openGui(this,p,2,0);
return plugin.createGUI.openGui(this,p,PanelPosition.Top, PanelOpenType.Return,0);
}
//open the panel for the player, it will disable debug mode
public void open(Player p){
if(plugin.debug.isEnabled(p)){
plugin.debug.debugSet.remove(p);
}
plugin.openVoids.openCommandPanel(p, p, this, false);
//open the panel for the player
public void open(Player p, PanelPosition position){
isOpen = true;
plugin.openVoids.openCommandPanel(p, p, this, position, false);
}
//create blank clone

View File

@ -1,5 +1,6 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -9,16 +10,22 @@ public class PanelClosedEvent extends Event{
private final Player p;
private final Panel panel;
private final PanelPosition pos;
public PanelClosedEvent(Player player, Panel panel) {
public PanelClosedEvent(Player player, Panel panel, PanelPosition position) {
this.p = player;
this.panel = panel;
this.pos = position;
}
public Player getPlayer(){
return this.p;
}
public PanelPosition getPosition(){
return this.pos;
}
public Inventory getInventory(){
return this.p.getInventory();
}

View File

@ -1,5 +1,6 @@
package me.rockyhawk.commandpanels.api;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
@ -11,6 +12,7 @@ public class PanelOpenedEvent extends Event implements Cancellable {
private boolean isCancelled;
private final Player p;
private final Panel panel;
private final PanelPosition pos;
public boolean isCancelled() {
return this.isCancelled;
@ -20,9 +22,14 @@ public class PanelOpenedEvent extends Event implements Cancellable {
this.isCancelled = isCancelled;
}
public PanelOpenedEvent(Player player, Panel panel) {
public PanelOpenedEvent(Player player, Panel panel, PanelPosition position) {
this.p = player;
this.panel = panel;
this.pos = position;
}
public PanelPosition getPosition(){
return this.pos;
}
public Player getPlayer(){

View File

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

View File

@ -3,6 +3,9 @@ package me.rockyhawk.commandpanels.classresources;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.commandtags.PaywallOutput;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
@ -21,7 +24,7 @@ public class ExecuteOpenVoids {
}
//this is the main method to open a panel
public void openCommandPanel(CommandSender sender, Player p, Panel panel, boolean openForOtherUser){
public void openCommandPanel(CommandSender sender, Player p, Panel panel, PanelPosition position, boolean openForOtherUser){
if(p.isSleeping()){
//avoid plugin glitches when sleeping
return;
@ -42,38 +45,34 @@ public class ExecuteOpenVoids {
return;
}
if(position != PanelPosition.Top && !plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Cannot open a panel without a panel at the top already."));
return;
}
//close any foreign GUIs for CommandPanels
if(!plugin.openPanels.hasPanelOpen(p.getName()) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top) && p.getOpenInventory().getType() != InventoryType.CRAFTING){
p.closeInventory();
}
//fire PanelOpenedEvent
PanelOpenedEvent openedEvent = new PanelOpenedEvent(p,panel);
PanelOpenedEvent openedEvent = new PanelOpenedEvent(p,panel,position);
Bukkit.getPluginManager().callEvent(openedEvent);
if(openedEvent.isCancelled()){
return;
}
//do these commands before the panel loads
beforeLoadCommands(panel,p);
beforeLoadCommands(panel,position,p);
try {
//create and open the GUI
plugin.createGUI.openGui(panel, p,1,0);
plugin.createGUI.openGui(panel, p, position,PanelOpenType.Normal,0);
//execute commands once the panel opens
if (panel.getConfig().contains("commands-on-open")) {
try {
List<String> commands = panel.getConfig().getStringList("commands-on-open");
for (String command : commands) {
int val = plugin.commandTags.commandPayWall(p, command);
if (val == 0) {
break;
}
if (val == 2) {
plugin.commandTags.runCommand(panel,p, command);
}
}
plugin.commandTags.runCommands(panel,position,p, panel.getConfig().getStringList("commands-on-open"));
}catch(Exception s){
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "commands-on-open: " + panel.getConfig().getString("commands-on-open")));
}
@ -96,7 +95,7 @@ public class ExecuteOpenVoids {
} catch (Exception r) {
plugin.debug(r,null);
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error")));
plugin.openPanels.closePanelForLoader(p.getName());
plugin.openPanels.closePanelForLoader(p.getName(),position);
p.closeInventory();
}
}else{
@ -139,21 +138,11 @@ public class ExecuteOpenVoids {
sender.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.perms")));
}
public void beforeLoadCommands(Panel panel, Player p){
public void beforeLoadCommands(Panel panel,PanelPosition pos, Player p){
if (panel.getConfig().contains("pre-load-commands")) {
try {
List<String> commands = panel.getConfig().getStringList("pre-load-commands");
for (String command : commands) {
int val = plugin.commandTags.commandPayWall(p, command);
if (val == 0) {
break;
}
if (val == 2) {
plugin.commandTags.runCommand(panel,p, command);
}
}
plugin.commandTags.runCommands(panel,pos,p, panel.getConfig().getStringList("pre-load-commands"));
}catch(Exception s){
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " " + "pre-load-commands: " + panel.getConfig().getString("pre-load-commands")));
plugin.debug(s,p);
}
}

View File

@ -5,6 +5,7 @@ import me.arcaniax.hdb.api.HeadDatabaseAPI;
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 net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.manager.ItemManager;
@ -40,8 +41,8 @@ public class ItemCreation {
}
@SuppressWarnings("deprecation")
public ItemStack makeItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String material = plugin.tex.placeholdersNoColour(panel,p,itemSection.getString("material"));
public ItemStack makeItemFromConfig(Panel panel, PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String material = plugin.tex.placeholdersNoColour(panel,position,p,itemSection.getString("material"));
try {
if (Objects.requireNonNull(material).equalsIgnoreCase("AIR")) {
return null;
@ -120,7 +121,7 @@ public class ItemCreation {
BookMeta bookMeta = (BookMeta) s.getItemMeta();
bookMeta.setTitle(matraw.split("\\s")[1]);
bookMeta.setAuthor(matraw.split("\\s")[1]);
List<String> bookLines = plugin.tex.placeholdersList(panel,p,itemSection.getStringList("write"),true);
List<String> bookLines = plugin.tex.placeholdersList(panel,position,p,itemSection.getStringList("write"),true);
String result = bookLines.stream().map(String::valueOf).collect(Collectors.joining("\n" + ChatColor.RESET, "", ""));
bookMeta.setPages(result);
s.setItemMeta(bookMeta);
@ -129,7 +130,7 @@ public class ItemCreation {
//creates item from custom-items section of panel
if(matraw.split("\\s")[0].equalsIgnoreCase("cpi=")){
s = makeCustomItemFromConfig(panel,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, true);
s = makeCustomItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matraw.split("\\s")[1]), p, true, true, true);
normalCreation = false;
}
@ -155,12 +156,12 @@ public class ItemCreation {
meta.setOwner(p.getName());
}
s.setItemMeta(meta);
}else if (plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]).length() <= 16) {
}else if (plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]).length() <= 16) {
//if cps= username
s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]));
s = plugin.customHeads.getPlayerHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
} else {
//custom data cps= base64
s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,p,matraw.split("\\s")[1]));
s = plugin.customHeads.getCustomHead(plugin.tex.placeholdersNoColour(panel,position,p,matraw.split("\\s")[1]));
}
} catch (Exception var32) {
p.sendMessage(plugin.tex.colour( plugin.tag + plugin.config.getString("config.format.error") + " head material: Could not load skull"));
@ -212,7 +213,7 @@ public class ItemCreation {
This will do maps from custom images
the maps will be in the 'maps' folder, so
CommandPanels/maps/image.png <-- here
CommandPanels/panels/example.yml
CommandPanels/panels/example_top.yml
The images should be 128x128
*/
try{
@ -265,7 +266,7 @@ public class ItemCreation {
if (itemSection.contains("customdata")) {
ItemMeta customMeta = s.getItemMeta();
assert customMeta != null;
customMeta.setCustomModelData(Integer.parseInt(Objects.requireNonNull(itemSection.getString("customdata"))));
customMeta.setCustomModelData(Integer.parseInt(plugin.tex.placeholders(panel,position,p,itemSection.getString("customdata"))));
s.setItemMeta(customMeta);
}
try {
@ -335,7 +336,7 @@ public class ItemCreation {
//if the damage is not unbreakable and should be a value
if (plugin.legacy.LOCAL_VERSION.lessThanOrEqualTo(MinecraftVersions.v1_12)) {
try {
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage")))));
s.setDurability(Short.parseShort(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
} catch (Exception e) {
plugin.debug(e, p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " damage: " + itemSection.getString("damage")));
@ -350,7 +351,7 @@ public class ItemCreation {
try {
Damageable itemDamage = (Damageable) s.getItemMeta();
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,p, itemSection.getString("damage")))));
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p, itemSection.getString("damage")))));
s.setItemMeta((ItemMeta) itemDamage);
} catch (Exception e) {
plugin.debug(e, p);
@ -365,7 +366,7 @@ public class ItemCreation {
}
if (itemSection.contains("stack")) {
//change the stack amount (placeholders accepted)
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,p,itemSection.getString("stack")))));
s.setAmount((int)Double.parseDouble(Objects.requireNonNull(plugin.tex.placeholders(panel,position,p,itemSection.getString("stack")))));
}
} catch (IllegalArgumentException | NullPointerException var33) {
plugin.debug(var33,p);
@ -377,16 +378,16 @@ public class ItemCreation {
}
//do custom-item items, they have an additional hasSection requirement
public ItemStack makeCustomItemFromConfig(Panel panel, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.itemCreate.hasSection(panel,itemSection,p);
public ItemStack makeCustomItemFromConfig(Panel panel,PanelPosition position, ConfigurationSection itemSection, Player p, boolean placeholders, boolean colours, boolean addNBT){
String section = plugin.itemCreate.hasSection(panel,position,itemSection,p);
if(!section.equals("")){
itemSection = itemSection.getConfigurationSection(section.substring(1));
}
return plugin.itemCreate.makeItemFromConfig(panel,itemSection, p, placeholders, colours, addNBT);
return plugin.itemCreate.makeItemFromConfig(panel,position,itemSection, p, placeholders, colours, addNBT);
}
//hasperm hasvalue, etc sections will be done here
public String hasSection(Panel panel, ConfigurationSection cf, Player p){
public String hasSection(Panel panel,PanelPosition position, ConfigurationSection cf, Player p){
if (cf.isSet("hasvalue")) {
//this will do the hasvalue without any numbers
boolean outputValue = true;
@ -395,11 +396,11 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue.output");
}
String value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue.value")));
String compare = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue.compare")));
String value = ChatColor.stripColor(plugin.tex.placeholders(panel,position,p,cf.getString("hasvalue.value")));
String compare = ChatColor.stripColor(plugin.tex.placeholders(panel,position,p,cf.getString("hasvalue.compare")));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasvalue")), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + section;
}
@ -412,11 +413,11 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasvalue" + count + ".output");
}
value = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue" + count + ".value")));
compare = ChatColor.stripColor(plugin.tex.placeholders(panel,p,cf.getString("hasvalue" + count + ".compare")));
value = ChatColor.stripColor(plugin.tex.placeholders(panel,position,p,cf.getString("hasvalue" + count + ".value")));
compare = ChatColor.stripColor(plugin.tex.placeholders(panel,position,p,cf.getString("hasvalue" + count + ".compare")));
if (compare.equals(value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasvalue items cannot be included to avoid item breaking
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasvalue" + count)), p);
//string section, it executes itself to check for subsections
return ".hasvalue" + count + section;
}
@ -431,11 +432,11 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater.output");
}
double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater.value"))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater.compare"))));
double value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,position,p,cf.getString("hasgreater.value"))));
double compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,position,p,cf.getString("hasgreater.compare"))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasgreater")), p);
return ".hasgreater" + section;
}
//loop through possible hasgreater 1,2,3,etc
@ -447,11 +448,11 @@ public class ItemCreation {
//if output is true, and values match it will be this item, vice versa
outputValue = cf.getBoolean("hasgreater" + count + ".output");
}
value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater" + count + ".value"))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,p,cf.getString("hasgreater" + count + ".compare"))));
value = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,position,p,cf.getString("hasgreater" + count + ".value"))));
compare = Double.parseDouble(ChatColor.stripColor(plugin.tex.placeholdersNoColour(panel,position,p,cf.getString("hasgreater" + count + ".compare"))));
if ((compare >= value) == outputValue) {
//onOpen being 3 means it is the editor panel.. hasgreater items cannot be included to avoid item breaking
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasgreater" + count)), p);
return ".hasgreater" + count + section;
}
}
@ -466,7 +467,7 @@ public class ItemCreation {
outputValue = cf.getBoolean("hasperm.output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm.perm"))) == outputValue) {
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasperm")), p);
return ".hasperm" + section;
}
for(int count = 0; cf.getKeys(false).size() > count; count++){
@ -478,7 +479,7 @@ public class ItemCreation {
outputValue = cf.getBoolean("hasperm" + count + ".output");
}
if (p.hasPermission(Objects.requireNonNull(cf.getString("hasperm" + count + ".perm"))) == outputValue) {
String section = hasSection(panel,Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
String section = hasSection(panel,position,Objects.requireNonNull(cf.getConfigurationSection("hasperm" + count)), p);
return ".hasperm" + count + section;
}
}

View File

@ -1,5 +1,4 @@
package me.rockyhawk.commandpanels.classresources.item_fall;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
import org.bukkit.Bukkit;
@ -22,6 +21,7 @@ public class ItemFallManager implements Listener {
public void run(){
for(String item : e.getPanel().getConfig().getConfigurationSection("item").getKeys(false)){
if(e.getPanel().getConfig().isSet("item." + item + ".itemType")){
//either the panel will drop the item or it will return to the inventory, no option to do both obviously
if(e.getPanel().getConfig().getStringList("item." + item + ".itemType").contains("dropItem")){
ItemStack stack = e.getPlayer().getOpenInventory().getTopInventory().getItem(Integer.parseInt(item));
if(stack == null || stack.getType() == Material.AIR){
@ -36,6 +36,12 @@ public class ItemFallManager implements Listener {
}
e.getPlayer().getWorld().dropItem(e.getPlayer().getLocation(),stack);
}else if(e.getPanel().getConfig().getStringList("item." + item + ".itemType").contains("returnItem")){
ItemStack stack = e.getPlayer().getOpenInventory().getTopInventory().getItem(Integer.parseInt(item));
if(stack == null || stack.getType() == Material.AIR){
continue;
}
plugin.inventorySaver.addItem(e.getPlayer(),stack);
}
}
}

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.classresources.placeholders;
import me.clip.placeholderapi.PlaceholderAPI;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -16,9 +17,9 @@ public class CreateText {
}
//CommandPanels send message function with all placeholders
public void sendMessage(Panel panel, Player p, String message){
public void sendMessage(Panel panel,PanelPosition position, Player p, String message){
if(!message.equals("")) {
p.sendMessage(placeholders(panel, p,plugin.tag + message));
p.sendMessage(placeholders(panel,position, p,plugin.tag + message));
}
}
@ -37,11 +38,11 @@ public class CreateText {
}
//papi except if it is a String List
public List<String> placeholdersNoColour(Panel panel, Player p, List<String> setpapi) {
public List<String> placeholdersNoColour(Panel panel,PanelPosition position, Player p, List<String> setpapi) {
try {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, attachPlaceholders(panel, p, temp));
setpapi.set(tempInt, attachPlaceholders(panel,position, p, temp));
tempInt += 1;
}
}catch(Exception ignore){
@ -52,12 +53,12 @@ public class CreateText {
}
//papi except if it is a String List
public List<String> placeholdersList(Panel panel, Player p, List<String> setpapi, boolean placeholder) {
public List<String> placeholdersList(Panel panel,PanelPosition position, Player p, List<String> setpapi, boolean placeholder) {
try {
if(placeholder) {
int tempInt = 0;
for (String temp : setpapi) {
setpapi.set(tempInt, attachPlaceholders(panel, p, temp));
setpapi.set(tempInt, attachPlaceholders(panel,position, p, temp));
tempInt += 1;
}
}
@ -84,9 +85,9 @@ public class CreateText {
}
//string papi with no colours
public String placeholdersNoColour(Panel panel, Player p, String setpapi) {
public String placeholdersNoColour(Panel panel, PanelPosition position, Player p, String setpapi) {
try {
setpapi = attachPlaceholders(panel, p,setpapi);
setpapi = attachPlaceholders(panel,position, p,setpapi);
return setpapi;
}catch(NullPointerException e){
return setpapi;
@ -94,9 +95,9 @@ public class CreateText {
}
//regular string papi
public String placeholders(Panel panel, Player p, String setpapi) {
public String placeholders(Panel panel, PanelPosition position, Player p, String setpapi) {
try {
setpapi = attachPlaceholders(panel, p,setpapi);
setpapi = attachPlaceholders(panel,position, p,setpapi);
setpapi = plugin.hex.translateHexColorCodes(ChatColor.translateAlternateColorCodes('&', setpapi));
return setpapi;
}catch(NullPointerException e){
@ -104,14 +105,14 @@ public class CreateText {
}
}
public String attachPlaceholders(Panel panel, Player p, String input){
public String attachPlaceholders(Panel panel, PanelPosition position, Player p, String input){
//do all the placeholders in order to fill into text
input = plugin.placeholders.setPlaceholders(panel, p, input, false);
input = plugin.placeholders.setPlaceholders(panel,position, p, input, false);
if (plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
OfflinePlayer offp = plugin.getServer().getOfflinePlayer(p.getUniqueId());
input = PlaceholderAPI.setPlaceholders(offp, input);
}
input = plugin.placeholders.setPlaceholders(panel, p, input, true);
input = plugin.placeholders.setPlaceholders(panel,position, p, input, true);
return input;
}
}

View File

@ -5,6 +5,7 @@ import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.ioclasses.legacy.MinecraftVersions;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -23,7 +24,7 @@ public class Placeholders {
this.plugin = pl;
}
public String setPlaceholders(Panel panel, Player p, String str, boolean primary){
public String setPlaceholders(Panel panel,PanelPosition position, Player p, String str, boolean primary){
String[] HOLDERS = getPlaceholderEnds(panel,primary);
while (str.contains(HOLDERS[0] + "cp-")) {
try {
@ -32,7 +33,7 @@ public class Placeholders {
String identifier = str.substring(start, end).replace(HOLDERS[0] + "cp-", "").replace(HOLDERS[1], "");
String value;
try {
value = doCpPlaceholders(panel,p,identifier, str);
value = cpPlaceholders(panel,position,p,identifier, str);
} catch (NullPointerException er) {
value = "";
}
@ -68,7 +69,7 @@ public class Placeholders {
}
@SuppressWarnings("deprecation")
private String doCpPlaceholders(Panel panel, Player p, String identifier, String string){
private String cpPlaceholders(Panel panel, PanelPosition position, Player p, String identifier, String string){
//do player input placeholder first
if (identifier.equals("player-input")) {
@ -82,7 +83,7 @@ public class Placeholders {
List<String> inputMessages = new ArrayList<String>(plugin.config.getStringList("config.input-message"));
for (String temp : inputMessages) {
temp = temp.replaceAll("%cp-args%", Objects.requireNonNull(plugin.config.getString("config.input-cancel")));
p.sendMessage(plugin.tex.placeholders(panel,p, temp));
p.sendMessage(plugin.tex.placeholders(panel,position,p, temp));
}
return "cpc";
}
@ -251,13 +252,13 @@ public class Placeholders {
try {
//if it is a regular custom item
ItemStack confItm = plugin.itemCreate.makeItemFromConfig(panel,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + matLoc),p,true,true, false);
ItemStack confItm = plugin.itemCreate.makeItemFromConfig(panel,position,panel.getConfig().getConfigurationSection("custom-item." + matLoc),p,true,true, false);
if(plugin.itemCreate.isIdentical(confItm,itm)){
isIdentical = true;
}
//if custom item is an mmo item (1.14+ for the API)
String customItemMaterial = plugin.openPanels.getOpenPanel(p.getName()).getConfig().getString("custom-item." + matLoc + ".material");
String customItemMaterial = panel.getConfig().getString("custom-item." + matLoc + ".material");
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && customItemMaterial.startsWith("mmo=")) {
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
@ -311,7 +312,7 @@ public class Placeholders {
try {
String point_value = identifier.replace("cp-setdata-", "");
String command = "set-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.runCommand(panel,p, command);
plugin.commandTags.runCommand(panel,position,p, command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);
@ -323,7 +324,7 @@ public class Placeholders {
try {
String point_value = identifier.replace("mathdata-", "");
String command = "math-data= " + point_value.split(",")[0] + " " + point_value.split(",")[1];
plugin.commandTags.runCommand(panel,p,command);
plugin.commandTags.runCommand(panel,position,p,command);
return "";
}catch (Exception ex){
plugin.debug(ex,p);

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -49,7 +50,7 @@ public class Commandpanel implements CommandExecutor {
if(args.length == 2){
if(!args[1].equals("item")){
if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), PanelPosition.Top, true);
}
}else{
sender.sendMessage(plugin.tex.colour(plugin.tag + ChatColor.RED + "Usage: /cp <panel> [item] [player]"));
@ -72,7 +73,7 @@ public class Commandpanel implements CommandExecutor {
//do player command
if (args.length == 1) {
if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, p, panel.copy(), false);
plugin.openVoids.openCommandPanel(sender, p, panel.copy(),PanelPosition.Top, false);
}
return true;
}else if(args.length == 2){
@ -80,7 +81,7 @@ public class Commandpanel implements CommandExecutor {
plugin.openVoids.giveHotbarItem(sender, p, panel, false);
}else{
if(!disableCommand) {
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(), true);
plugin.openVoids.openCommandPanel(sender, plugin.getServer().getPlayer(args[1]), panel.copy(),PanelPosition.Top, true);
}
}
return true;

View File

@ -2,12 +2,12 @@ package me.rockyhawk.commandpanels.commands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
@ -24,6 +24,14 @@ public class Commandpanelsreload implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equalsIgnoreCase("cpr") || label.equalsIgnoreCase("commandpanelreload") || label.equalsIgnoreCase("cpanelr")) {
if (sender.hasPermission("commandpanel.reload")) {
//close all the panels
for(String name : plugin.openPanels.openPanels.keySet()){
plugin.openPanels.closePanelForLoader(name, PanelPosition.Top);
try {
Bukkit.getPlayer(name).closeInventory();
}catch (Exception ignore){}
}
plugin.reloadPanelFiles();
if(new File(plugin.getDataFolder() + File.separator + "temp.yml").delete()){
//empty
@ -55,7 +63,6 @@ public class Commandpanelsreload implements CommandExecutor {
//this will require a server restart for new commands
public void registerCommands(){
ConfigurationSection tempFile;
File commandsLoc = new File("commands.yml");
YamlConfiguration cmdCF;
try {

View File

@ -18,7 +18,7 @@ public class Commandpanelversion implements CommandExecutor {
if(args.length == 0) {
if (sender.hasPermission("commandpanel.version")) {
//version command
String latestVersion = plugin.updater.githubNewUpdate(false);
String latestVersion = plugin.updater.getLatestVersion(false);
sender.sendMessage(plugin.tex.colour(plugin.tag));
sender.sendMessage(ChatColor.GREEN + "This Version " + ChatColor.GRAY + plugin.getDescription().getVersion());
sender.sendMessage(ChatColor.GREEN + "Latest Version " + ChatColor.GRAY + latestVersion);

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.commandtags;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@ -14,11 +15,13 @@ public class CommandTagEvent extends Event {
public String[] raw;
public String[] args;
public String name;
public PanelPosition pos;
public boolean commandTagUsed = false;
public CommandTagEvent(CommandPanels plugin, Panel panel1, Player player, String rawCommand1) {
public CommandTagEvent(CommandPanels plugin, Panel panel1, PanelPosition position, Player player, String rawCommand1) {
this.p = player;
this.panel = panel1;
this.pos = position;
//do nopapi= tag (donation feature) which will stop PlaceholderAPI placeholders from executing
boolean doApiPlaceholders = true;
@ -40,10 +43,10 @@ public class CommandTagEvent extends Event {
this.name = split[0].trim();
this.raw = split[1].trim().split("\\s");
if(doApiPlaceholders) {
this.args = plugin.tex.attachPlaceholders(panel1, player, split[1].trim()).split("\\s");
this.args = plugin.tex.attachPlaceholders(panel1,pos, player, split[1].trim()).split("\\s");
}else{
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, p,split[1].trim(),false)).split("\\s");
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, p,split[1].trim(),true)).split("\\s");
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),false)).split("\\s");
this.args = ChatColor.translateAlternateColorCodes('&',plugin.placeholders.setPlaceholders(panel, pos, p,split[1].trim(),true)).split("\\s");
}
}

View File

@ -1,5 +1,6 @@
package me.rockyhawk.commandpanels.commandtags;
import jdk.nashorn.internal.ir.Block;
import me.realized.tokenmanager.api.TokenManager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
@ -12,12 +13,16 @@ import me.rockyhawk.commandpanels.commandtags.tags.other.SpecialTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.BasicTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.BungeeTags;
import me.rockyhawk.commandpanels.commandtags.tags.standard.ItemTags;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class CommandTags {
@ -26,11 +31,23 @@ public class CommandTags {
this.plugin = pl;
}
public void runCommand(Panel panel,Player p,String commandRAW){
CommandTagEvent tags = new CommandTagEvent(plugin,panel,p,commandRAW);
public void runCommands(Panel panel, PanelPosition position,Player p, List<String> commands){
for (String command : commands) {
PaywallOutput val = plugin.commandTags.commandPayWall(panel,p,command);
if(val == PaywallOutput.Blocked){
break;
}
if(val == PaywallOutput.NotApplicable){
plugin.commandTags.runCommand(panel,position,p, command);
}
}
}
public void runCommand(Panel panel, PanelPosition position,Player p, String commandRAW){
CommandTagEvent tags = new CommandTagEvent(plugin,panel,position,p,commandRAW);
Bukkit.getPluginManager().callEvent(tags);
if(!tags.commandTagUsed){
Bukkit.dispatchCommand(p, plugin.tex.placeholders(panel,p,commandRAW.trim()));
Bukkit.dispatchCommand(p, plugin.tex.placeholders(panel,position,p,commandRAW.trim()));
}
}
@ -50,7 +67,7 @@ public class CommandTags {
}
@SuppressWarnings("deprecation")
public int commandPayWall(Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
public PaywallOutput commandPayWall(Panel panel, Player p, String command) { //return 0 means no funds, 1 is they passed and 2 means paywall is not this command
String tag = plugin.config.getString("config.format.tag") + " ";
switch(command.split("\\s")[0]){
case "paywall=": {
@ -60,19 +77,19 @@ public class CommandTags {
if (plugin.econ.getBalance(p) >= Double.parseDouble(command.split("\\s")[1])) {
plugin.econ.withdrawPlayer(p, Double.parseDouble(command.split("\\s")[1]));
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.currency.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return 1;
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p,plugin.config.getString("purchase.currency.failure"));
return 0;
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Paying Requires Vault and an Economy to work!");
return 0;
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return 0;
return PaywallOutput.Blocked;
}
}
case "tokenpaywall=": {
@ -86,24 +103,25 @@ public class CommandTags {
api.removeTokens(p, Long.parseLong(command.split("\\s")[1]));
//if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return 1;
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p,plugin.config.getString("purchase.tokens.failure"));
return 0;
return PaywallOutput.Blocked;
}
} else {
plugin.tex.sendString(p, tag + ChatColor.RED + "Needs TokenManager to work!");
return 0;
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return 0;
return PaywallOutput.Blocked;
}
}
case "item-paywall=": {
//if player uses item-paywall= [Material] [Amount] [Id]
//or player can use item-paywall= [custom-item]
//player can use item-paywall= [custom-item]
List<ItemStack> cont = new ArrayList<>(Arrays.asList(plugin.inventorySaver.getNormalInventory(p)));
try {
short id = 0;
if(command.split("\\s").length == 4){
@ -113,41 +131,53 @@ public class CommandTags {
//create the item to be removed
ItemStack sellItem;
if(command.split("\\s").length == 2) {
sellItem = plugin.itemCreate.makeCustomItemFromConfig(null,plugin.openPanels.getOpenPanel(p.getName()).getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
sellItem = plugin.itemCreate.makeCustomItemFromConfig(panel,PanelPosition.Top,panel.getConfig().getConfigurationSection("custom-item." + command.split("\\s")[1]), p, true, true, false);
}else{
sellItem = new ItemStack(Objects.requireNonNull(Material.matchMaterial(command.split("\\s")[1])), Integer.parseInt(command.split("\\s")[2]), id);
}
//this is not a boolean because it needs to return an int
int removedItem = 0;
PaywallOutput removedItem = PaywallOutput.Blocked;
//loop through items in the inventory
for(ItemStack content : p.getInventory().getContents()){
for(int f = 0; f < 36; f++){
if(content == null){
if(cont.get(f) == null){
//skip slot if empty
continue;
}
if(command.split("\\s").length == 2){
//if item paywall is custom item
if(plugin.itemCreate.isIdentical(sellItem,content)){
content.setAmount(content.getAmount() - sellItem.getAmount());
if(plugin.itemCreate.isIdentical(sellItem,cont.get(f))){
if (sellItem.getAmount() <= cont.get(f).getAmount()) {
if (plugin.inventorySaver.hasNormalInventory(p)) {
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
} else {
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
//if custom item is an mmo item (1.14+ for the API)
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && plugin.openPanels.getOpenPanel(p.getName()).getConfig().getString("custom-item." + command.split("\\s")[1] + ".material").startsWith("mmo=")) {
String customItemMaterial = plugin.openPanels.getOpenPanel(p.getName()).getConfig().getString("custom-item." + command.split("\\s")[1] + ".material");
if (plugin.getServer().getPluginManager().isPluginEnabled("MMOItems") && panel.getConfig().getString("custom-item." + command.split("\\s")[1] + ".material").startsWith("mmo=")) {
String customItemMaterial = panel.getConfig().getString("custom-item." + command.split("\\s")[1] + ".material");
String mmoType = customItemMaterial.split("\\s")[1];
String mmoID = customItemMaterial.split("\\s")[2];
if (plugin.isMMOItem(content,mmoType,mmoID) && sellItem.getAmount() <= content.getAmount()) {
content.setAmount(content.getAmount() - sellItem.getAmount());
if (plugin.isMMOItem(cont.get(f),mmoType,mmoID) && sellItem.getAmount() <= cont.get(f).getAmount()) {
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
}else{
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
@ -157,11 +187,16 @@ public class CommandTags {
}else {
//if the item is a standard material
if (content.getType() == sellItem.getType()) {
if (sellItem.getAmount() <= content.getAmount()) {
content.setAmount(content.getAmount() - sellItem.getAmount());
if (cont.get(f).getType() == sellItem.getType()) {
if (sellItem.getAmount() <= cont.get(f).getAmount()) {
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().getItem(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
p.updateInventory();
removedItem = 1;
}else{
cont.get(f).setAmount(cont.get(f).getAmount() - sellItem.getAmount());
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
removedItem = PaywallOutput.Passed;
break;
}
}
@ -169,7 +204,7 @@ public class CommandTags {
}
//send message and return
if(removedItem == 0){
if(removedItem == PaywallOutput.Blocked){
plugin.tex.sendString(p, tag + plugin.config.getString("purchase.item.failure"));
}else{
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.item.success")).replaceAll("%cp-args%",sellItem.getType().toString()));
@ -178,7 +213,7 @@ public class CommandTags {
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return 0;
return PaywallOutput.Blocked;
}
}
case "xp-paywall=": {
@ -189,18 +224,18 @@ public class CommandTags {
p.setLevel(p.getLevel() - Integer.parseInt(command.split("\\s")[1]));
//if the message is empty don't send
plugin.tex.sendString(p,Objects.requireNonNull(plugin.config.getString("purchase.xp.success")).replaceAll("%cp-args%", command.split("\\s")[1]));
return 1;
return PaywallOutput.Passed;
} else {
plugin.tex.sendString(p, plugin.config.getString("purchase.xp.failure"));
return 0;
return PaywallOutput.Blocked;
}
} catch (Exception buyc) {
plugin.debug(buyc,p);
plugin.tex.sendString(p, tag + plugin.config.getString("config.format.error") + " " + "commands: " + command);
return 0;
return PaywallOutput.Blocked;
}
}
}
return 2;
return PaywallOutput.NotApplicable;
}
}

View File

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

View File

@ -29,7 +29,7 @@ public class BuyCommandTags implements Listener {
//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.p,command);
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
plugin.tex.sendMessage(e.p,plugin.config.getString("purchase.currency.success").replaceAll("%cp-args%", price));
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.currency.failure"));
@ -56,7 +56,7 @@ public class BuyCommandTags implements Listener {
//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.p,command);
plugin.commandTags.runCommand(e.panel,e.pos,e.p,command);
plugin.tex.sendMessage(e.p, Objects.requireNonNull(plugin.config.getString("purchase.tokens.success")).replaceAll("%cp-args%", price));
} else {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.tokens.failure"));

View File

@ -80,10 +80,6 @@ public class BuyItemTags implements Listener {
}
}
}
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]),id));
} else {
Objects.requireNonNull(p.getLocation().getWorld()).dropItemNaturally(p.getLocation(), new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]),id));
}
plugin.inventorySaver.addItem(p,new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2]),id));
}
}

View File

@ -13,6 +13,9 @@ import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class SellItemTags implements Listener {
@ -28,7 +31,7 @@ public class SellItemTags implements Listener {
//if player uses sell= it will be eg. sell= <cashback> <item> <amount of item> [enchanted:KNOCKBACK:1] [potion:JUMP]
try {
if (plugin.econ != null) {
boolean sold = checkItem(e.p, e.args);
boolean sold = removeItem(e.p, e.args);
if (!sold) {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
} else {
@ -50,7 +53,7 @@ public class SellItemTags implements Listener {
try {
if (plugin.getServer().getPluginManager().isPluginEnabled("TokenManager")) {
TokenManager api = (TokenManager) Bukkit.getServer().getPluginManager().getPlugin("TokenManager");
boolean sold = checkItem(e.p, e.args);
boolean sold = removeItem(e.p, e.args);
if (!sold) {
plugin.tex.sendMessage(e.p, plugin.config.getString("purchase.item.failure"));
} else {
@ -68,10 +71,12 @@ public class SellItemTags implements Listener {
}
}
@SuppressWarnings("deprecation")
private boolean checkItem(Player p, String[] args){
for (int f = 0; f < p.getInventory().getSize(); f++) {
ItemStack itm = p.getInventory().getItem(f);
//returns false if player does not have item
private boolean removeItem(Player p, String[] args){
List<ItemStack> cont = new ArrayList<>(Arrays.asList(plugin.inventorySaver.getNormalInventory(p)));
for (int f = 0; f < 36; f++) {
ItemStack itm = cont.get(f);
if (itm != null && itm.getType().equals(Material.matchMaterial(args[1]))) {
//determine if the command contains parameters for extensions
String potion = "false";
@ -112,8 +117,13 @@ public class SellItemTags implements Listener {
if (itm.getAmount() >= new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])).getAmount()) {
int amt = itm.getAmount() - new ItemStack(Objects.requireNonNull(Material.matchMaterial(args[1])), Integer.parseInt(args[2])).getAmount();
itm.setAmount(amt);
if(plugin.inventorySaver.hasNormalInventory(p)){
p.getInventory().setItem(f, amt > 0 ? itm : null);
p.updateInventory();
}else{
cont.set(f,amt > 0 ? itm : null);
plugin.inventorySaver.inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
}
return true;
}
}

View File

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

View File

@ -31,7 +31,7 @@ public class PlaceholderTags implements Listener {
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1));
String value = plugin.tex.placeholders(e.panel,e.pos,e.p,contents.substring(contents.indexOf(':')+1));
e.panel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1;
}
@ -57,7 +57,7 @@ public class PlaceholderTags implements Listener {
//only convert placeholders for the value
if (!e.panel.placeholders.keys.containsKey(placeholder)) {
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel, e.p, contents.substring(contents.indexOf(':') + 1));
String value = plugin.tex.placeholders(e.panel,e.pos, e.p, contents.substring(contents.indexOf(':') + 1));
e.panel.placeholders.addPlaceholder(placeholder, value);
}
i = i + contents.length() - 1;

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.commandtags.tags.other;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.apache.commons.lang.ArrayUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -26,6 +27,7 @@ public class SpecialTags implements Listener {
String cmd = String.join(" ",e.args).replace(e.args[0],"").trim();
Panel openPanel = null;
PanelPosition openPosition = e.pos;
for(Panel pane : plugin.panelList){
if(pane.getName().equals(panelName)){
openPanel = pane.copy();
@ -42,12 +44,30 @@ public class SpecialTags implements Listener {
//do not change the placeholder
String placeholder = contents.substring(0,contents.indexOf(':'));
//only convert placeholders for the value
String value = plugin.tex.placeholders(e.panel,e.p,contents.substring(contents.indexOf(':')+1));
String value = plugin.tex.placeholders(e.panel,e.pos,e.p,contents.substring(contents.indexOf(':')+1));
openPanel.placeholders.addPlaceholder(placeholder,value);
i = i+contents.length()-1;
}else if(cm[i].equals('{')){
String contents = cmd.substring(i+1, i+cmd.substring(i).indexOf('}'));
openPosition = PanelPosition.valueOf(contents);
i = i+contents.length()-1;
}
}
openPanel.open(e.p);
openPanel.open(e.p,openPosition);
return;
}
if(e.name.equalsIgnoreCase("close=")) {
e.commandTagUsed();
//closes specific panel positions
PanelPosition position = PanelPosition.valueOf(e.args[0]);
if(position == PanelPosition.Middle && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Middle);
}else if(position == PanelPosition.Bottom && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
plugin.openPanels.closePanelForLoader(e.p.getName(),PanelPosition.Bottom);
}else if(position == PanelPosition.Top && plugin.openPanels.hasPanelOpen(e.p.getName(),position)){
//closing top closes all
e.p.closeInventory();
}
return;
}
if(e.name.equalsIgnoreCase("teleport=")) {
@ -79,17 +99,18 @@ public class SpecialTags implements Listener {
plugin.tex.sendMessage(e.p,plugin.config.getString("config.format.notitem"));
}
}
return;
}
if(e.name.equalsIgnoreCase("delay=")) {
e.commandTagUsed();
//if player uses op= it will perform command as op
final int delaySeconds = Integer.parseInt(e.args[0]);
final int delayTicks = Integer.parseInt(e.args[0]);
String finalCommand = String.join(" ",e.args).replace(e.args[0],"").trim();
new BukkitRunnable() {
@Override
public void run() {
try {
plugin.commandTags.runCommand(e.panel, e.p, finalCommand);
plugin.commandTags.runCommand(e.panel,e.pos, e.p, finalCommand);
} catch (Exception ex) {
//if there are any errors, cancel so that it doesn't loop errors
plugin.debug(ex, e.p);
@ -97,7 +118,7 @@ public class SpecialTags implements Listener {
}
this.cancel();
}
}.runTaskTimer(plugin, 20L * delaySeconds, 20); //20 ticks == 1 second
}.runTaskTimer(plugin, delayTicks, 1); //20 ticks == 1 second
}
}
}

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.commandtags.tags.standard;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.PanelCommandEvent;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.event.EventHandler;
@ -24,7 +25,7 @@ public class BasicTags implements Listener {
}
if(e.name.equalsIgnoreCase("refresh")) {
e.commandTagUsed();
plugin.createGUI.openGui(plugin.openPanels.getOpenPanel(e.p.getName()), e.p, 0, 0);
plugin.createGUI.openGui(e.panel, e.p, e.pos, PanelOpenType.Refresh, 0);
return;
}
if(e.name.equalsIgnoreCase("console=")) {

View File

@ -2,7 +2,7 @@ package me.rockyhawk.commandpanels.commandtags.tags.standard;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTagEvent;
import org.bukkit.configuration.ConfigurationSection;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
@ -17,17 +17,23 @@ public class ItemTags implements Listener {
public void commandTag(CommandTagEvent e){
if(e.name.equalsIgnoreCase("give-item=")){
e.commandTagUsed();
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,plugin.openPanels.getOpenPanel(e.p.getName()).getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
e.p.getInventory().addItem(itm);
ItemStack itm = plugin.itemCreate.makeCustomItemFromConfig(null,e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, false);
plugin.inventorySaver.addItem(e.p,itm);
return;
}
if(e.name.equalsIgnoreCase("setitem=")){
e.commandTagUsed();
//if player uses setitem= [custom item] [slot] it will change the item slot to something, used for placeable items
//if player uses setitem= [custom item] [slot] [position] it will change the item slot to something, used for placeable items
//make a section in the panel called "custom-item" then whatever the title of the item is, put that here
ConfigurationSection panelCF = plugin.openPanels.getOpenPanel(e.p.getName()).getConfig();
ItemStack s = plugin.itemCreate.makeItemFromConfig(null,panelCF.getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, true);
ItemStack s = plugin.itemCreate.makeItemFromConfig(null, e.pos,e.panel.getConfig().getConfigurationSection("custom-item." + e.args[0]), e.p, true, true, true);
PanelPosition position = PanelPosition.valueOf(e.args[2]);
if(position == PanelPosition.Top) {
e.p.getOpenInventory().getTopInventory().setItem(Integer.parseInt(e.args[1]), s);
}else if(position == PanelPosition.Middle) {
e.p.getInventory().setItem(Integer.parseInt(e.args[1])+9, s);
}else{
e.p.getInventory().setItem(Integer.parseInt(e.args[1]), s);
}
}
}
}

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.customcommands;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -23,7 +24,7 @@ public class Commandpanelcustom implements Listener {
for(String cmd : panelCommands){
if(cmd.equalsIgnoreCase(e.getMessage().replace("/", ""))){
e.setCancelled(true);
panel.open(e.getPlayer());
panel.open(e.getPlayer(), PanelPosition.Top);
return;
}
@ -51,7 +52,7 @@ public class Commandpanelcustom implements Listener {
for(String[] placeholder : placeholders){
openPanel.placeholders.addPlaceholder(placeholder[0],placeholder[1]);
}
openPanel.open(e.getPlayer());
openPanel.open(e.getPlayer(),PanelPosition.Top);
return;
}
}

View File

@ -2,6 +2,8 @@ package me.rockyhawk.commandpanels.ingameeditor;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -39,7 +41,7 @@ public class CpIngameEditCommand implements CommandExecutor {
for(Panel panel : plugin.panelList){
if(panel.getName().equals(args[0])) {
//below will start the command, once it got the right file and panel
plugin.createGUI.openGui(panel.copy(), p,3,0);
plugin.createGUI.openGui(panel.copy(), p, PanelPosition.Top, PanelOpenType.Editor,0);
return true;
}
}

View File

@ -2,6 +2,8 @@ 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;
@ -78,7 +80,7 @@ public class EditorUserInput implements Listener {
final ConfigurationSection finalCF = cf;
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.createGUI.openGui(new Panel(finalCF, panelName), p, 3,0); //I have to do this to run regular Bukkit voids in an ASYNC Event
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.")){

View File

@ -2,6 +2,8 @@ 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;
@ -35,7 +37,7 @@ public class EditorUtils implements Listener {
return;
}
}catch(NullPointerException nu){return;}
if(!p.getOpenInventory().getTitle().equals(ChatColor.stripColor(plugin.tex.colour("Command Panels Editor"))) || plugin.openPanels.hasPanelOpen(p.getName())){
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()){
@ -98,7 +100,7 @@ public class EditorUtils implements Listener {
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,3,0);
plugin.createGUI.openGui(new Panel(panelYaml.get(count), panelName), p,PanelPosition.Top,PanelOpenType.Editor,0);
return;
}
count +=1;
@ -123,7 +125,7 @@ public class EditorUtils implements Listener {
@EventHandler
public void onInventoryDrag(InventoryDragEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName())){
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
String panelName = ""; //all panels from ALL files (panel names)
@ -180,7 +182,7 @@ public class EditorUtils implements Listener {
@EventHandler
public void onInventoryEdit(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName())){
if(!p.getOpenInventory().getTitle().contains("Editing Panel:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
String panelName = "";
@ -293,8 +295,8 @@ public class EditorUtils implements Listener {
@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())){
plugin.openPanels.closePanelForLoader(e.getPlayer().getName());
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
@ -308,7 +310,7 @@ public class EditorUtils implements Listener {
@EventHandler
public void onPanelSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Panel Settings:") || plugin.openPanels.hasPanelOpen(p.getName())){
if(!p.getOpenInventory().getTitle().contains("Panel Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
e.setCancelled(true);
@ -459,7 +461,7 @@ public class EditorUtils implements Listener {
@EventHandler
public void onItemSettings(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Item Settings:") || plugin.openPanels.hasPanelOpen(p.getName())){
if(!p.getOpenInventory().getTitle().contains("Item Settings:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
e.setCancelled(true);
@ -570,7 +572,7 @@ public class EditorUtils implements Listener {
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, 3, 0);
plugin.createGUI.openGui(new Panel(panelYaml, panelName), p,PanelPosition.Top, PanelOpenType.Editor, 0);
}
p.updateInventory();
}
@ -580,7 +582,7 @@ public class EditorUtils implements Listener {
@EventHandler
public void onItemSection(InventoryClickEvent e) {
Player p = (Player)e.getWhoClicked();
if(!p.getOpenInventory().getTitle().contains("Item Sections:") || plugin.openPanels.hasPanelOpen(p.getName())){
if(!p.getOpenInventory().getTitle().contains("Item Sections:") || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
return;
}
e.setCancelled(true);

View File

@ -3,6 +3,7 @@ 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;
@ -260,7 +261,7 @@ public class OpenEditorGuis {
if(cf.contains("open-with-item.material")){
hotbarItems = true;
temp = plugin.itemCreate.makeItemFromConfig(null,cf.getConfigurationSection("open-with-item"), p, false, true, false);
temp = plugin.itemCreate.makeItemFromConfig(null, PanelPosition.Top,cf.getConfigurationSection("open-with-item"), p, false, true, false);
}else{
temp = new ItemStack(Material.REDSTONE_BLOCK, 1);
}
@ -497,7 +498,7 @@ public class OpenEditorGuis {
plugin.setName(null,temp, ChatColor.RED + "Back", null, p, true, true, true);
i.setItem(27, temp);
temp = plugin.itemCreate.makeItemFromConfig(null,cf,p,false,false, false);
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");
@ -536,7 +537,7 @@ public class OpenEditorGuis {
lore.add(ChatColor.WHITE + "Compare: " + ChatColor.GRAY + cf.getString(section + ".compare"));
}
temp = plugin.itemCreate.makeItemFromConfig(null,cf.getConfigurationSection(section),p,false,false, false);
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++;

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.interactives;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.commandtags.CommandTags;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -35,7 +36,7 @@ public class CommandpanelUserInput implements Listener {
e.setCancelled(true);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
new CommandTags(plugin).runCommand(null,e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
new CommandTags(plugin).runCommand(null, PanelPosition.Top,e.getPlayer(), command); //I have to do this to run regular Bukkit voids in an ASYNC Event
}
});
}

View File

@ -3,6 +3,7 @@ package me.rockyhawk.commandpanels.interactives;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelOpenType;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
@ -27,7 +28,6 @@ public class Commandpanelrefresher implements Listener {
}
}
//I have to convert HumanEntity to a player
Player p = e.getPlayer();
Panel pn = e.getPanel();
@ -68,7 +68,7 @@ public class Commandpanelrefresher implements Listener {
c=0;
}
//refresh here
if(plugin.openPanels.hasPanelOpen(p.getName(),pn.getName())){
if(e.getPanel().isOpen){
if(p.getOpenInventory().getTopInventory().getHolder() != p){
//if open inventory is not a panel (owned by the player holder), cancel
this.cancel();
@ -89,11 +89,11 @@ public class Commandpanelrefresher implements Listener {
//reload the panel is debug is enabled (only personal debug)
pn.setConfig(YamlConfiguration.loadConfiguration(pn.getFile()));
}
plugin.createGUI.openGui(pn, p, 0,animatecount);
} catch (Exception e) {
plugin.createGUI.openGui(pn, p,e.getPosition(), PanelOpenType.Refresh,animatecount);
} catch (Exception ex) {
//error opening gui
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName());
plugin.openPanels.closePanelForLoader(p.getName(),e.getPosition());
this.cancel();
}
}
@ -109,6 +109,7 @@ public class Commandpanelrefresher implements Listener {
this.cancel();
//remove duplicate items here
p.updateInventory();
if(plugin.inventorySaver.hasNormalInventory(p)) {
for (ItemStack itm : p.getInventory().getContents()) {
if (itm != null) {
if (plugin.nbt.hasNBT(itm)) {
@ -118,6 +119,7 @@ public class Commandpanelrefresher implements Listener {
}
}
}
}
}.runTaskTimer(this.plugin, 1,1); //20 ticks == 1 second (5 ticks = 0.25 of a second)
}
}

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.interactives;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -27,7 +28,7 @@ public class OpenOnJoin implements Listener {
private void openOnJoin(Player p, String joinType){
if(plugin.config.contains(joinType + p.getWorld().getName())){
String command = "open= " + plugin.config.getString(joinType + p.getWorld().getName());
plugin.commandTags.runCommand(null,p, command);
plugin.commandTags.runCommand(null, PanelPosition.Top,p, command);
}
}
}

View File

@ -37,7 +37,6 @@ public class NBT_1_14 {
ItemMeta itemMeta = item.getItemMeta();
return itemMeta.getPersistentDataContainer().get(ns_key, PersistentDataType.STRING);
}catch (Exception e){
plugin.debug(e,null);
return "";
}
}

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@ -21,31 +22,36 @@ public class OpenGUI {
}
@SuppressWarnings("deprecation")
public Inventory openGui(Panel panel, Player p, int onOpen, int animateValue) {
public Inventory openGui(Panel panel, Player p, PanelPosition position, PanelOpenType openType, int animateValue) {
ConfigurationSection pconfig = panel.getConfig();
Inventory i;
if(position == PanelPosition.Top) {
String title;
if (onOpen != 3) {
if (openType != PanelOpenType.Editor) {
//regular inventory
title = plugin.tex.placeholders(panel,p,pconfig.getString("title"));
title = plugin.tex.placeholders(panel, position, p, pconfig.getString("title"));
} else {
//editor inventory
title = "Editing Panel: " + panel.getName();
}
Inventory i;
if (isNumeric(pconfig.getString("rows"))) {
i = Bukkit.createInventory(p, pconfig.getInt("rows") * 9, title);
} else {
i = Bukkit.createInventory(p, InventoryType.valueOf(pconfig.getString("rows")), title);
}
}else{
i = p.getInventory();
}
Set<String> itemList = pconfig.getConfigurationSection("item").getKeys(false);
HashSet<Integer> takenSlots = new HashSet<>();
for (String item : itemList) {
String section = "";
//onOpen needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
if (onOpen != 3) {
section = plugin.itemCreate.hasSection(panel,pconfig.getConfigurationSection("item." + Integer.parseInt(item)), p);
//openType needs to not be 3 so the editor won't include hasperm and hasvalue, etc items
if (openType != PanelOpenType.Editor) {
section = plugin.itemCreate.hasSection(panel,position,pconfig.getConfigurationSection("item." + Integer.parseInt(item)), p);
//This section is for animations below here: VISUAL ONLY
//check for if there is animations inside the items section
@ -58,23 +64,26 @@ public class OpenGUI {
}
//will only add NBT if not an editor GUI
ItemStack s = plugin.itemCreate.makeItemFromConfig(panel,Objects.requireNonNull(pconfig.getConfigurationSection("item." + item + section)), p, onOpen != 3, onOpen != 3, onOpen != 3);
ItemStack s = plugin.itemCreate.makeItemFromConfig(panel,position,Objects.requireNonNull(pconfig.getConfigurationSection("item." + item + section)), p, openType != PanelOpenType.Editor, openType != PanelOpenType.Editor, openType != PanelOpenType.Editor);
//This is for CUSTOM ITEMS
if(pconfig.contains("item." + item + section + ".itemType")) {
//this is for contents in the itemType section
if (pconfig.getStringList("item." + item + section + ".itemType").contains("placeable") && onOpen == 0) {
//keep item the same, onOpen == 0 meaning panel is refreshing
i.setItem(Integer.parseInt(item), p.getOpenInventory().getItem(Integer.parseInt(item)));
if (pconfig.getStringList("item." + item + section + ".itemType").contains("placeable") && openType == PanelOpenType.Refresh) {
//keep item the same, openType == 0 meaning panel is refreshing
setItem(p.getOpenInventory().getItem(Integer.parseInt(item)),Integer.parseInt(item),i,p,position);
takenSlots.add(Integer.parseInt(item));
continue;
}
}
try {
//place item into the GUI
i.setItem(Integer.parseInt(item), s);
setItem(s,Integer.parseInt(item),i,p,position);
takenSlots.add(Integer.parseInt(item));
//i.setItem(Integer.parseInt(item), s);
//only place duplicate items in without the editor mode. These are merely visual and will not carry over commands
if(pconfig.contains("item." + item + section + ".duplicate") && onOpen != 3) {
if(pconfig.contains("item." + item + section + ".duplicate") && openType != PanelOpenType.Editor) {
try {
String[] duplicateItems = pconfig.getString("item." + item + section + ".duplicate").split(",");
for (String tempDupe : duplicateItems) {
@ -84,47 +93,36 @@ public class OpenGUI {
for(int n = bothNumbers[0]; n <= bothNumbers[1]; n++){
try{
if(!pconfig.contains("item." + n)){
i.setItem(n, s);
setItem(s,n,i,p,position);
takenSlots.add(Integer.parseInt(item));
}
}catch(NullPointerException ignore){
i.setItem(n, s);
setItem(s,n,i,p,position);
takenSlots.add(Integer.parseInt(item));
}
}
} else {
//if there is only one dupe item
try{
if(!pconfig.contains("item." + Integer.parseInt(tempDupe))){
i.setItem(Integer.parseInt(tempDupe), s);
setItem(s,Integer.parseInt(tempDupe),i,p,position);
takenSlots.add(Integer.parseInt(item));
}
}catch(NullPointerException ignore){
i.setItem(Integer.parseInt(tempDupe), s);
setItem(s,Integer.parseInt(tempDupe),i,p,position);
takenSlots.add(Integer.parseInt(item));
}
}
}
}catch(NullPointerException nullp){
plugin.debug(nullp,p);
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName());
}
}
} catch (ArrayIndexOutOfBoundsException var24) {
plugin.debug(var24,p);
if (plugin.debug.isEnabled(p)) {
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " item: One of the items does not fit in the Panel!"));
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName());
plugin.openPanels.closePanelForLoader(p.getName(),position);
}
}
} catch (ArrayIndexOutOfBoundsException ignore) {}
}
if (pconfig.contains("empty") && !Objects.equals(pconfig.getString("empty"), "AIR")) {
for (int c = 0; i.getSize() > c; ++c) {
boolean found = false;
if(itemList.contains(String.valueOf(c))){
if(i.getItem(c) == null){
found = true;
}
}
if (!found) {
ItemStack empty;
try {
//emptyID for older versions of minecraft (might be deprecated later on)
@ -134,7 +132,7 @@ public class OpenGUI {
}
//either use custom item or just material type
if(pconfig.contains("custom-item." + pconfig.getString("empty"))){
empty = plugin.itemCreate.makeItemFromConfig(panel,pconfig.getConfigurationSection("custom-item." + pconfig.getString("empty")),p,true,true,true);
empty = plugin.itemCreate.makeItemFromConfig(panel,position,pconfig.getConfigurationSection("custom-item." + pconfig.getString("empty")),p,true,true,true);
}else{
empty = new ItemStack(Objects.requireNonNull(Material.matchMaterial(pconfig.getString("empty").toUpperCase())), 1,id);
empty = plugin.nbt.setNBT(empty);
@ -143,44 +141,71 @@ public class OpenGUI {
renamedMeta.setDisplayName(" ");
empty.setItemMeta(renamedMeta);
}
if (empty.getType() == Material.AIR) {
continue;
if (empty.getType() != Material.AIR) {
for (int c = 0; getInvSize(i,position) > c; ++c) {
if (!takenSlots.contains(c)) {
//only place empty items if not editing
if(openType != PanelOpenType.Editor) {
setItem(empty,c,i,p,position);
}
}
}
}
} catch (IllegalArgumentException | NullPointerException var26) {
plugin.debug(var26,p);
p.sendMessage(plugin.tex.colour(plugin.tag + plugin.config.getString("config.format.error") + " empty: " + pconfig.getString("empty")));
p.closeInventory();
plugin.openPanels.closePanelForLoader(p.getName());
return null;
}
if (onOpen != 3) {
//only place empty items if not editing
if(i.getItem(c) == null && !pconfig.contains("item." + c)) {
i.setItem(c, empty);
}
}
if (openType == PanelOpenType.Normal) {
//declare old panel closed
if(plugin.openPanels.hasPanelOpen(p.getName(),position)){
plugin.openPanels.getOpenPanel(p.getName(),position).isOpen = false;
}
}
}
if (onOpen == 1) {
//onOpen 1 is default
//open new panel
plugin.openPanels.skipPanelClose.add(p.getName());
plugin.openPanels.openPanelForLoader(p.getName(),panel);
plugin.openPanels.openPanelForLoader(p.getName(),panel,position);
//only if it needs to open the top inventory
if(position == PanelPosition.Top) {
p.openInventory(i);
}
plugin.openPanels.skipPanelClose.remove(p.getName());
} else if (onOpen == 3) {
//onOpen 3 will open the editor panel
} else if (openType == PanelOpenType.Editor) {
//The editor will always be at panel position top
p.openInventory(i);
} else if (onOpen == 0) {
//onOpen 0 will just refresh the panel
} else if (openType == PanelOpenType.Refresh) {
//openType 0 will just refresh the panel
if(position == PanelPosition.Top) {
plugin.legacy.setStorageContents(p, plugin.legacy.getStorageContents(i));
} else if (onOpen == 2) {
}
} else if (openType == PanelOpenType.Return) {
//will return the inventory, not opening it at all
return i;
}
return i;
}
private int getInvSize(Inventory inv, PanelPosition position){
if(position == PanelPosition.Top){
return inv.getSize();
}else if(position == PanelPosition.Middle){
return 27;
}else{
return 9;
}
}
private void setItem(ItemStack item, int slot, Inventory inv, Player p, PanelPosition position) throws ArrayIndexOutOfBoundsException{
if(position == PanelPosition.Top){
inv.setItem(slot, item);
}else if(position == PanelPosition.Middle){
if(slot+9 < 36) {
p.getInventory().setItem(slot + 9, item);
}
}else{
if(slot < 9) {
p.getInventory().setItem(slot, item);
}
}
}
private boolean isNumeric(String strNum) {
if (strNum == null) {
return false;

View File

@ -3,7 +3,7 @@ package me.rockyhawk.commandpanels.openpanelsmanager;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
import me.rockyhawk.commandpanels.ioclasses.nbt.NBT_1_13;
import me.rockyhawk.commandpanels.api.PanelsInterface;
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;
@ -20,92 +20,102 @@ public class OpenPanelsLoader {
The configuration section is opened directly
into the correct panel, so there is no need for the panel name
*/
public HashMap<String, Panel> openPanels = new HashMap<>(); //player name and panel
public HashMap<String, PanelsInterface> openPanels = new HashMap<>(); //player name and panel interface
public HashSet<String> skipPanelClose = new HashSet<>(); //don't remove the player if they are in this list
//this will return the panel CF based on the player, if it isn't there it returns null
public Panel getOpenPanel(String playerName){
for(Map.Entry<String, Panel> entry : openPanels.entrySet()){
public Panel getOpenPanel(String playerName, PanelPosition position){
for(Map.Entry<String, PanelsInterface> entry : openPanels.entrySet()){
if(entry.getKey().equals(playerName)){
return entry.getValue();
return entry.getValue().getPanel(position);
}
}
return null;
}
//this will return the panel CF based on the player, if it isn't there it returns null
public String getOpenPanelName(String playerName){
for(Map.Entry<String, Panel> entry : openPanels.entrySet()){
if(entry.getKey().equals(playerName)){
return entry.getValue().getName();
}
}
return null;
}
//true if the player has a panel open
public boolean hasPanelOpen(String playerName, String panelName){
for(Map.Entry<String, Panel> entry : openPanels.entrySet()){
if(entry.getKey().equals(playerName) && entry.getValue().getName().equals(panelName)){
//true if the player has the corresponding panel open in the location
public boolean hasPanelOpen(String playerName, String panelName, PanelPosition position){
for(Map.Entry<String, PanelsInterface> entry : openPanels.entrySet()){
try {
if (entry.getKey().equals(playerName) && entry.getValue().getPanel(position).getName().equals(panelName)) {
return true;
}
}catch (NullPointerException ex){
return false;
}
}
return false;
}
//true if the player has a panel open
public boolean hasPanelOpen(String playerName) {
for(Map.Entry<String, Panel> entry : openPanels.entrySet()){
if(entry.getKey().equals(playerName)){
public boolean hasPanelOpen(String playerName, PanelPosition position) {
for(Map.Entry<String, PanelsInterface> entry : openPanels.entrySet()){
try {
if(entry.getKey().equals(playerName) && entry.getValue().getPanel(position) != null){
return true;
}
}catch (NullPointerException ex){
return false;
}
}
return false;
}
//tell loader that a panel has been opened
public void openPanelForLoader(String playerName, Panel panel){
openPanels.put(playerName, panel);
public void openPanelForLoader(String playerName, Panel panel, PanelPosition position){
if(!openPanels.containsKey(playerName)){
openPanels.put(playerName, new PanelsInterface(playerName));
}
openPanels.get(playerName).setPanel(panel,position);
openPanels.get(playerName).getPanel(position).isOpen = true;
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).trim().equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Opened " + panel.getName());
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Opened " + panel.getName() + " at " + position);
}
}
}
//close all of the panels for a player currently open
public void closePanelForLoader(String playerName){
public void closePanelForLoader(String playerName, PanelPosition position){
if(!openPanels.containsKey(playerName) || skipPanelClose.contains(playerName)){
return;
}
panelCloseCommands(playerName,openPanels.get(playerName));
panelCloseCommands(playerName,position,openPanels.get(playerName).getPanel(position));
if (plugin.config.contains("config.panel-snooper")) {
if (Objects.requireNonNull(plugin.config.getString("config.panel-snooper")).equalsIgnoreCase("true")) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + openPanels.get(playerName).getName());
Bukkit.getConsoleSender().sendMessage("[CommandPanels] " + playerName + " Closed " + openPanels.get(playerName).getPanel(position).getName() + " at " + position);
}
}
//fire PanelClosedEvent
PanelClosedEvent closedEvent = new PanelClosedEvent(Bukkit.getPlayer(playerName),openPanels.get(playerName));
PanelClosedEvent closedEvent = new PanelClosedEvent(Bukkit.getPlayer(playerName),openPanels.get(playerName).getPanel(position),position);
Bukkit.getPluginManager().callEvent(closedEvent);
openPanels.get(playerName).setPanel(null,position);
//remove if all panels closed or if top panel is closed
if(openPanels.get(playerName).allClosed()){
removePlayer(playerName);
}else if(openPanels.get(playerName).getPanel(PanelPosition.Top) == null){
removePlayer(playerName);
}
//fix up the inventory
plugin.inventorySaver.restoreInventory(Bukkit.getPlayer(playerName),position);
}
//removes player from openPanels map
public void removePlayer(String playerName){
openPanels.get(playerName).setPanel(null,PanelPosition.Top);
openPanels.get(playerName).setPanel(null,PanelPosition.Middle);
openPanels.get(playerName).setPanel(null,PanelPosition.Bottom);
openPanels.remove(playerName);
}
public void panelCloseCommands(String playerName, Panel panel){
public void panelCloseCommands(String playerName,PanelPosition position, Panel panel){
if (panel.getConfig().contains("commands-on-close")) {
//execute commands on panel close
try {
List<String> commands = panel.getConfig().getStringList("commands-on-close");
for (String command : commands) {
int val = plugin.commandTags.commandPayWall(Bukkit.getPlayer(playerName),command);
if(val == 0){
break;
}
if(val == 2){
plugin.commandTags.runCommand(panel,Bukkit.getPlayer(playerName), command);
}
}
plugin.commandTags.runCommands(panel,position,Bukkit.getPlayer(playerName),panel.getConfig().getStringList("commands-on-close"));
}catch(Exception s){
plugin.debug(s,null);
}

View File

@ -0,0 +1,8 @@
package me.rockyhawk.commandpanels.openpanelsmanager;
public enum PanelOpenType {
Editor,
Normal,
Return,
Refresh
}

View File

@ -0,0 +1,7 @@
package me.rockyhawk.commandpanels.openpanelsmanager;
public enum PanelPosition {
Top,
Middle,
Bottom
}

View File

@ -26,7 +26,7 @@ public class UtilsPanelsLoader implements Listener {
//tell panel loader that player has opened panel
@EventHandler
public void onPlayerClosePanel(PlayerQuitEvent e){
plugin.openPanels.closePanelForLoader(e.getPlayer().getName());
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
Player p = e.getPlayer();
p.updateInventory();
for(ItemStack itm : p.getInventory().getContents()){
@ -44,7 +44,7 @@ public class UtilsPanelsLoader implements Listener {
//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());
plugin.openPanels.closePanelForLoader(e.getPlayer().getName(),PanelPosition.Top);
}
}
@ -52,7 +52,7 @@ public class UtilsPanelsLoader implements Listener {
public void onInventoryItemClick(InventoryClickEvent e){
//this will check to ensure an item is not from CommandPanels on inventory open
Player p = (Player)e.getWhoClicked();
if(!plugin.openPanels.hasPanelOpen(p.getName())){
if(!plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Top)){
for(ItemStack itm : p.getInventory().getContents()){
if(plugin.openPanels.isNBTInjected(itm)){
p.getInventory().remove(itm);
@ -65,14 +65,14 @@ public class UtilsPanelsLoader implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void vanillaOpenedEvent(InventoryOpenEvent e){
if(e.isCancelled()) {
if (plugin.openPanels.hasPanelOpen(e.getPlayer().getName())) {
Panel closedPanel = plugin.openPanels.getOpenPanel(e.getPlayer().getName());
if (plugin.openPanels.hasPanelOpen(e.getPlayer().getName(),PanelPosition.Top)) {
Panel closedPanel = plugin.openPanels.getOpenPanel(e.getPlayer().getName(),PanelPosition.Top);
//manually remove player with no skip checks
plugin.openPanels.openPanels.remove(e.getPlayer().getName());
plugin.openPanels.removePlayer(e.getPlayer().getName());
//fire PanelClosedEvent
PanelClosedEvent closedEvent = new PanelClosedEvent(Bukkit.getPlayer(e.getPlayer().getName()),closedPanel);
PanelClosedEvent closedEvent = new PanelClosedEvent(Bukkit.getPlayer(e.getPlayer().getName()),closedPanel, PanelPosition.Top);
Bukkit.getPluginManager().callEvent(closedEvent);
//do message

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.openwithitem;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -49,11 +50,11 @@ public class HotbarItemLoader {
}
if(panel.getConfig().contains("open-with-item.commands")){
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
plugin.commandTags.runCommand(panel,p, command);
plugin.commandTags.runCommand(panel,PanelPosition.Top,p, command);
}
return true;
}
panel.open(p);
panel.open(p, PanelPosition.Top);
}
return true;
}
@ -86,11 +87,11 @@ public class HotbarItemLoader {
}
if(panel.getConfig().contains("open-with-item.commands")){
for(String command : panel.getConfig().getStringList("open-with-item.commands")){
plugin.commandTags.runCommand(panel,p, command);
plugin.commandTags.runCommand(panel,PanelPosition.Top,p, command);
}
return true;
}
panel.open(p);
panel.open(p,PanelPosition.Top);
}
return true;
}

View File

@ -2,6 +2,7 @@ package me.rockyhawk.commandpanels.openwithitem;
import de.jeff_media.chestsort.api.ChestSortEvent;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryType;
@ -13,6 +14,12 @@ public class UtilsChestSortEvent implements Listener {
}
@EventHandler
public void onChestSortEvent(ChestSortEvent e){
//cancel if a panel is opened at all
if(plugin.openPanels.hasPanelOpen(e.getPlayer().getName(), PanelPosition.Top)){
e.setCancelled(true);
return;
}
//hotbar item code below
if(!plugin.openWithItem){
//if none of the panels have open-with-item
return;

View File

@ -39,7 +39,7 @@ public class UtilsOpenWithItem implements Listener {
//skip if null to stop errors
return;
}
if(e.getClickedInventory().getType() == InventoryType.PLAYER) {
if(e.getClickedInventory().getType() == InventoryType.PLAYER && !e.isCancelled()) {
if (plugin.hotbar.stationaryExecute(e.getSlot(), p, true)) {
e.setCancelled(true);
p.updateInventory();

View File

@ -1,6 +1,7 @@
package me.rockyhawk.commandpanels.panelblocks;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.openpanelsmanager.PanelPosition;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -31,7 +32,7 @@ public class PanelBlockOnClick implements Listener {
if(!plugin.blockConfig.contains("blocks")){
return;
}
if(plugin.openPanels.hasPanelOpen(p.getName())) {
if(plugin.openPanels.hasPanelOpen(p.getName(), PanelPosition.Top)) {
//some blocks run this event twice, skip if panel already open
//as blocks cannot be clicked obviously if a panel is open
return;
@ -43,13 +44,13 @@ public class PanelBlockOnClick implements Listener {
e.setCancelled(true);
if(plugin.blockConfig.contains("blocks." + configLocation + ".commands")){
for(String command : plugin.blockConfig.getStringList("blocks." + configLocation + ".commands")){
plugin.commandTags.runCommand(null,p, command);
plugin.commandTags.runCommand(null,PanelPosition.Top,p, command);
}
return;
}
//uses the open= tag because it will open a panel with panel names, but also works with open= features like placeholders
String command = "open= " + plugin.blockConfig.getString("blocks." + configLocation + ".panel");
plugin.commandTags.runCommand(null,p, command);
plugin.commandTags.runCommand(null,PanelPosition.Top,p, command);
}
}
}

View File

@ -0,0 +1,127 @@
package me.rockyhawk.commandpanels.playerinventoryhandler;
import me.rockyhawk.commandpanels.CommandPanels;
import me.rockyhawk.commandpanels.api.Panel;
import me.rockyhawk.commandpanels.api.PanelClosedEvent;
import me.rockyhawk.commandpanels.api.PanelOpenedEvent;
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.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.PotionMeta;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class InventorySaver implements Listener {
CommandPanels plugin;
public InventorySaver(CommandPanels pl) {
this.plugin = pl;
}
public YamlConfiguration inventoryConfig;
public void saveInventoryFile(){
try {
inventoryConfig.save(plugin.getDataFolder() + File.separator + "inventories.yml");
} catch (IOException s) {
s.printStackTrace();
plugin.debug(s,null);
}
}
@EventHandler
public void onOpen(PanelOpenedEvent e){
if(e.getPosition() != PanelPosition.Top) {
addInventory(e.getPlayer());
}
}
@EventHandler
public void playerJoined(PlayerJoinEvent e){
restoreInventory(e.getPlayer(), PanelPosition.Top);
}
public void restoreInventory(Player p, PanelPosition position){
if(p == null){
return;
}
if(plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Middle) || plugin.openPanels.hasPanelOpen(p.getName(),PanelPosition.Bottom)){
if(position == PanelPosition.Bottom){
for(int s = 0; s < 9; s++){
p.getInventory().setItem(s,null);
}
}else if(position == PanelPosition.Middle){
for(int s = 9; s < 36; s++){
p.getInventory().setItem(s,null);
}
}
return;
}
if(inventoryConfig.isSet(p.getUniqueId().toString())){
p.getInventory().setContents(plugin.itemSerializer.itemStackArrayFromBase64(inventoryConfig.getString(p.getUniqueId().toString())));
inventoryConfig.set(p.getUniqueId().toString(),null);
}
}
public void addInventory(Player p){
if(!inventoryConfig.contains(p.getUniqueId().toString())){
inventoryConfig.set(p.getUniqueId().toString(),plugin.itemSerializer.itemStackArrayToBase64(p.getInventory().getContents()));
p.getInventory().clear();
}
}
public ItemStack[] getNormalInventory(Player p){
if(hasNormalInventory(p)){
return p.getInventory().getContents();
}else{
return plugin.itemSerializer.itemStackArrayFromBase64(inventoryConfig.getString(p.getUniqueId().toString()));
}
}
public boolean hasNormalInventory(Player p){
return !inventoryConfig.isSet(p.getUniqueId().toString());
}
public void addItem(Player p, ItemStack item){
if(hasNormalInventory(p)){
if (p.getInventory().firstEmpty() >= 0) {
p.getInventory().addItem(item);
return;
}
}else {
List<ItemStack> cont = new ArrayList<>(Arrays.asList(getNormalInventory(p)));
boolean found = false;
for (int i = 0; 36 > i; i++){
if(cont.get(i) == null){
cont.set(i,item);
found = true;
break;
}
if(cont.get(i).isSimilar(item)){
cont.get(i).setAmount(cont.get(i).getAmount()+1);
found = true;
break;
}
}
if(found){
inventoryConfig.set(p.getUniqueId().toString(), plugin.itemSerializer.itemStackArrayToBase64(cont.toArray(new ItemStack[0])));
return;
}
}
p.getLocation().getWorld().dropItemNaturally(p.getLocation(), item);
}
}

View File

@ -0,0 +1,59 @@
package me.rockyhawk.commandpanels.playerinventoryhandler;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class ItemStackSerializer {
CommandPanels plugin;
public ItemStackSerializer(CommandPanels pl) {
this.plugin = pl;
}
public String itemStackArrayToBase64(ItemStack[] items) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
// Write the size of the inventory
dataOutput.writeInt(items.length);
// Save every element in the list
for (ItemStack item : items) {
dataOutput.writeObject(item);
}
// Serialize that array
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
plugin.debug(e,null);
}
return null;
}
public ItemStack[] itemStackArrayFromBase64(String data) {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] items = new ItemStack[dataInput.readInt()];
// Read the serialized inventory
for (int i = 0; i < items.length; i++) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException | IOException e) {
plugin.debug(e,null);
}
return null;
}
}

View File

@ -3,6 +3,9 @@ package me.rockyhawk.commandpanels.updater;
import me.rockyhawk.commandpanels.CommandPanels;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.*;
@ -11,7 +14,7 @@ import java.net.URL;
import java.util.Objects;
import java.util.logging.Level;
public class Updater {
public class Updater implements Listener {
CommandPanels plugin;
public Updater(CommandPanels pl) {
this.plugin = pl;
@ -22,7 +25,27 @@ public class Updater {
public String downloadVersionManually = null;
public String catchedLatestVersion = "null";
public String githubNewUpdate(boolean sendMessages){
//send update message when the player joins the game with the permission
@EventHandler
public void joinGame(PlayerJoinEvent e){
if(e.getPlayer().hasPermission("commandpanel.update")){
if(githubNewUpdate(false)){
new BukkitRunnable() {
@Override
public void run() {
plugin.tex.sendMessage(e.getPlayer(),ChatColor.YELLOW + "A new update is available for download!");
plugin.tex.sendString(e.getPlayer(),ChatColor.YELLOW
+ "Current version "
+ ChatColor.RED + plugin.getDescription().getVersion() + ChatColor.YELLOW
+ " Latest version " + ChatColor.GREEN + catchedLatestVersion);
this.cancel();
}
}.runTaskTimer(plugin, 30, 1); //20 ticks == 1 second
}
}
}
public boolean githubNewUpdate(boolean sendMessages){
//refresh latest version
getLatestVersion(sendMessages);
@ -30,14 +53,11 @@ public class Updater {
if(sendMessages) {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GREEN + " Running a custom version.");
}
return null;
return false;
}
//if update is true there is a new update
boolean update = false;
if(!catchedLatestVersion.equals(plugin.getDescription().getVersion())){
update = true;
}
boolean update = !catchedLatestVersion.equals(plugin.getDescription().getVersion());
if(update){
if(sendMessages) {
@ -47,11 +67,12 @@ public class Updater {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.WHITE + " following command:" + ChatColor.AQUA + " /cpv latest" + ChatColor.WHITE + " and restart the server");
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.GOLD + " ================================================");
}
return true;
}
return catchedLatestVersion;
return false;
}
public void getLatestVersion(boolean sendMessages){
public String getLatestVersion(boolean sendMessages){
//check for null
if(catchedLatestVersion.equals("null")){
catchedLatestVersion = plugin.getDescription().getVersion();
@ -77,6 +98,7 @@ public class Updater {
Bukkit.getConsoleSender().sendMessage("[CommandPanels]" + ChatColor.RED + " Cannot check for update.");
}
}
return catchedLatestVersion;
}
//the pluginFileName can only be obtained from the main class