16
16
*/
17
17
package me .eccentric_nz .TARDIS .chameleon .shell ;
18
18
19
+ import com .google .gson .JsonArray ;
20
+ import com .google .gson .JsonParser ;
19
21
import me .eccentric_nz .TARDIS .TARDIS ;
20
22
import me .eccentric_nz .TARDIS .custommodeldata .GUIChameleonPresets ;
21
23
import me .eccentric_nz .TARDIS .database .resultset .ResultSetShells ;
22
24
import me .eccentric_nz .TARDIS .utility .TARDISNumberParsers ;
23
25
import net .md_5 .bungee .api .ChatColor ;
24
26
import org .bukkit .Material ;
27
+ import org .bukkit .block .data .BlockData ;
25
28
import org .bukkit .inventory .ItemStack ;
26
29
import org .bukkit .inventory .meta .ItemMeta ;
27
30
import org .bukkit .persistence .PersistentDataType ;
@@ -69,7 +72,27 @@ private ItemStack[] getItemStack() {
69
72
int i = 0 ;
70
73
ArrayList <HashMap <String , String >> data = rss .getData ();
71
74
for (HashMap <String , String > map : data ) {
72
- ItemStack saved = new ItemStack (Material .BOWL , 1 );
75
+ // get the first non-air block of the shell
76
+ Material material = null ;
77
+ String blueprint = map .get ("blueprintData" );
78
+ JsonArray json = JsonParser .parseString (blueprint ).getAsJsonArray ();
79
+ outer :
80
+ for (int k = 0 ; k < 10 ; k ++) {
81
+ JsonArray inner = json .get (k ).getAsJsonArray ();
82
+ for (int j = 0 ; j < 4 ; j ++) {
83
+ String block = inner .get (j ).getAsString ();
84
+ plugin .debug (block );
85
+ if (!block .equals ("minecraft:air" )) {
86
+ BlockData blockData = plugin .getServer ().createBlockData (block );
87
+ material = blockData .getMaterial ();
88
+ break outer ;
89
+ }
90
+ }
91
+ }
92
+ if (material == null ) {
93
+ material = Material .BOWL ;
94
+ }
95
+ ItemStack saved = new ItemStack (material , 1 );
73
96
ItemMeta con = saved .getItemMeta ();
74
97
con .setDisplayName ("Saved Construct" );
75
98
List <String > lore = new ArrayList <>();
@@ -81,7 +104,9 @@ private ItemStack[] getItemStack() {
81
104
lore .add (ChatColor .AQUA + "Active shell" );
82
105
}
83
106
con .setLore (lore );
84
- con .setCustomModelData (GUIChameleonPresets .SAVED .getCustomModelData ());
107
+ if (material == Material .BOWL ) {
108
+ con .setCustomModelData (GUIChameleonPresets .SAVED .getCustomModelData ());
109
+ }
85
110
con .getPersistentDataContainer ().set (plugin .getCustomBlockKey (), PersistentDataType .INTEGER , TARDISNumberParsers .parseInt (map .get ("chameleon_id" )));
86
111
saved .setItemMeta (con );
87
112
stacks [i ] = saved ;
@@ -96,6 +121,7 @@ private ItemStack[] getItemStack() {
96
121
ItemStack use = new ItemStack (Material .BOWL , 1 );
97
122
ItemMeta uim = use .getItemMeta ();
98
123
uim .setDisplayName ("Use selected shell" );
124
+ uim .setLore (List .of ("Will apply shell to" , "the Chameleon Circuit" , "and rebuild the exterior." ));
99
125
uim .setCustomModelData (GUIChameleonPresets .USE_SELECTED .getCustomModelData ());
100
126
use .setItemMeta (uim );
101
127
stacks [45 ] = use ;
@@ -107,7 +133,7 @@ private ItemStack[] getItemStack() {
107
133
delete .setItemMeta (dim );
108
134
stacks [46 ] = delete ;
109
135
// update selected shell
110
- ItemStack update = new ItemStack (Material .BUCKET , 1 );
136
+ ItemStack update = new ItemStack (Material .BOWL , 1 );
111
137
ItemMeta upim = update .getItemMeta ();
112
138
upim .setDisplayName ("Update selected shell" );
113
139
upim .setCustomModelData (GUIChameleonPresets .UPDATE_SELECTED .getCustomModelData ());
@@ -125,7 +151,8 @@ private ItemStack[] getItemStack() {
125
151
ItemStack save = new ItemStack (Material .BOWL , 1 );
126
152
ItemMeta pre = save .getItemMeta ();
127
153
pre .setDisplayName ("Save Chameleon shell" );
128
- pre .setCustomModelData (GUIChameleonPresets .CURRENT .getCustomModelData ());
154
+ ns .setLore (List .of ("Will save shell and" , "rebuild the exterior." ));
155
+ pre .setCustomModelData (GUIChameleonPresets .SAVE .getCustomModelData ());
129
156
save .setItemMeta (pre );
130
157
stacks [50 ] = save ;
131
158
// Cancel / close
0 commit comments