Skip to content

Commit 12dc3ee

Browse files
Use the first non-air block of the shell as the GUI icon
1 parent 8e754c9 commit 12dc3ee

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

src/main/java/me/eccentric_nz/TARDIS/TARDIS.java

+4
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ public void onEnable() {
489489
new TARDISWallSignConverter(this).convertSignBlocks();
490490
getConfig().set("conversions.block_wall_signs", true);
491491
}
492+
if (!getConfig().getBoolean("conversions.short_grass")) {
493+
new TARDISGrassConverter(this).checkBlockData();
494+
getConfig().set("conversions.short_grass", true);
495+
}
492496
TARDISBlockLoader bl = new TARDISBlockLoader(this);
493497
bl.loadGravityWells();
494498
bl.loadProtectedBlocks();

src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISPlayerShellListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private int getChameleonId(InventoryView view, int slot) {
246246
ItemStack shell = view.getItem(slot);
247247
ItemMeta im = shell.getItemMeta();
248248
PersistentDataContainer pdc = im.getPersistentDataContainer();
249-
if (!pdc.has(plugin.getCustomBlockKey())) {
249+
if (!pdc.has(plugin.getCustomBlockKey(), PersistentDataType.INTEGER)) {
250250
return -1;
251251
}
252252
return pdc.get(plugin.getCustomBlockKey(), PersistentDataType.INTEGER);

src/main/java/me/eccentric_nz/TARDIS/chameleon/shell/TARDISShellInventory.java

+31-4
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
*/
1717
package me.eccentric_nz.TARDIS.chameleon.shell;
1818

19+
import com.google.gson.JsonArray;
20+
import com.google.gson.JsonParser;
1921
import me.eccentric_nz.TARDIS.TARDIS;
2022
import me.eccentric_nz.TARDIS.custommodeldata.GUIChameleonPresets;
2123
import me.eccentric_nz.TARDIS.database.resultset.ResultSetShells;
2224
import me.eccentric_nz.TARDIS.utility.TARDISNumberParsers;
2325
import net.md_5.bungee.api.ChatColor;
2426
import org.bukkit.Material;
27+
import org.bukkit.block.data.BlockData;
2528
import org.bukkit.inventory.ItemStack;
2629
import org.bukkit.inventory.meta.ItemMeta;
2730
import org.bukkit.persistence.PersistentDataType;
@@ -69,7 +72,27 @@ private ItemStack[] getItemStack() {
6972
int i = 0;
7073
ArrayList<HashMap<String, String>> data = rss.getData();
7174
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);
7396
ItemMeta con = saved.getItemMeta();
7497
con.setDisplayName("Saved Construct");
7598
List<String> lore = new ArrayList<>();
@@ -81,7 +104,9 @@ private ItemStack[] getItemStack() {
81104
lore.add(ChatColor.AQUA + "Active shell");
82105
}
83106
con.setLore(lore);
84-
con.setCustomModelData(GUIChameleonPresets.SAVED.getCustomModelData());
107+
if (material == Material.BOWL) {
108+
con.setCustomModelData(GUIChameleonPresets.SAVED.getCustomModelData());
109+
}
85110
con.getPersistentDataContainer().set(plugin.getCustomBlockKey(), PersistentDataType.INTEGER, TARDISNumberParsers.parseInt(map.get("chameleon_id")));
86111
saved.setItemMeta(con);
87112
stacks[i] = saved;
@@ -96,6 +121,7 @@ private ItemStack[] getItemStack() {
96121
ItemStack use = new ItemStack(Material.BOWL, 1);
97122
ItemMeta uim = use.getItemMeta();
98123
uim.setDisplayName("Use selected shell");
124+
uim.setLore(List.of("Will apply shell to", "the Chameleon Circuit", "and rebuild the exterior."));
99125
uim.setCustomModelData(GUIChameleonPresets.USE_SELECTED.getCustomModelData());
100126
use.setItemMeta(uim);
101127
stacks[45] = use;
@@ -107,7 +133,7 @@ private ItemStack[] getItemStack() {
107133
delete.setItemMeta(dim);
108134
stacks[46] = delete;
109135
// update selected shell
110-
ItemStack update = new ItemStack(Material.BUCKET, 1);
136+
ItemStack update = new ItemStack(Material.BOWL, 1);
111137
ItemMeta upim = update.getItemMeta();
112138
upim.setDisplayName("Update selected shell");
113139
upim.setCustomModelData(GUIChameleonPresets.UPDATE_SELECTED.getCustomModelData());
@@ -125,7 +151,8 @@ private ItemStack[] getItemStack() {
125151
ItemStack save = new ItemStack(Material.BOWL, 1);
126152
ItemMeta pre = save.getItemMeta();
127153
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());
129156
save.setItemMeta(pre);
130157
stacks[50] = save;
131158
// Cancel / close

src/main/java/me/eccentric_nz/TARDIS/control/TARDISControlListener.java

+5-10
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,7 @@ public void onControlInteract(PlayerInteractEvent event) {
157157
if (action == Action.RIGHT_CLICK_BLOCK) {
158158
switch (type) {
159159
// random location button
160-
case 1 ->
161-
new RandomAction(plugin).process(cooldown, player, id, tardis, rsc.getSecondary());
160+
case 1 -> new RandomAction(plugin).process(cooldown, player, id, tardis, rsc.getSecondary());
162161
// console repeaters
163162
case 2, 3, 4, 5 -> new RepeaterAction(plugin).announce(player, block, type);
164163
// fast return button
@@ -170,8 +169,7 @@ public void onControlInteract(PlayerInteractEvent event) {
170169
// Temporal Locator sign
171170
case 11 -> new TemporarlLocatorAction(plugin).openGUI(player, tcc);
172171
// Control room light switch
173-
case 12 ->
174-
new LightSwitchAction(plugin, id, lights, player, tardis.getSchematic().getLights()).flickSwitch();
172+
case 12 -> new LightSwitchAction(plugin, id, lights, player, tardis.getSchematic().getLights()).flickSwitch();
175173
// TIS
176174
case 13 -> new TARDISInfoMenuButton(plugin, player).clickButton();
177175
// Disk Storage
@@ -196,8 +194,7 @@ public void onControlInteract(PlayerInteractEvent event) {
196194
new CustardCreamAction(plugin, player, block, id).dispense();
197195
}
198196
// force field
199-
case 29 ->
200-
new ForceFieldAction(plugin).toggleSheilds(player, blockLocation, tardis.getArtron_level());
197+
case 29 -> new ForceFieldAction(plugin).toggleSheilds(player, blockLocation, tardis.getArtron_level());
201198
// flight mode button
202199
case 30 -> new FlightModeAction(plugin).setMode(ownerUUID.toString(), player);
203200
// chameleon sign
@@ -211,8 +208,7 @@ public void onControlInteract(PlayerInteractEvent event) {
211208
}
212209
}
213210
// scanner
214-
case 33 ->
215-
new TARDISScanner(plugin).scan(player, id, tardis.getRenderer(), tardis.getArtron_level());
211+
case 33 -> new TARDISScanner(plugin).scan(player, id, tardis.getRenderer(), tardis.getArtron_level());
216212
// cloister bell
217213
case 35 -> new CloisterBellAction(plugin).ring(id, tardis);
218214
// weather menu
@@ -227,8 +223,7 @@ public void onControlInteract(PlayerInteractEvent event) {
227223
// zero room entry
228224
case 16 -> new ZeroRoomAction(plugin).doEntry(player, tardis, id);
229225
// maze exits
230-
case 40, 41, 42, 43 ->
231-
new MazeAction(plugin).reconfigure(type, player, id, blockLocation);
226+
case 40, 41, 42, 43 -> new MazeAction(plugin).reconfigure(type, player, id, blockLocation);
232227
default -> {
233228
}
234229
}

src/main/java/me/eccentric_nz/TARDIS/custommodeldata/GUIChameleonPresets.java

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public enum GUIChameleonPresets {
2424
// Chameleon Presets
2525
GO_TO_PAGE_2(12, 52, Material.ARROW),
2626
NEW(151, 49, Material.BOWL),
27+
SAVE(74, 50, Material.BOWL),
2728
USE_SELECTED(152, 45, Material.BOWL),
2829
UPDATE_SELECTED(153, 45, Material.BOWL),
2930
DELETE_SELECTED(1, 46, Material.BUCKET),

0 commit comments

Comments
 (0)