|
19 | 19 | import me.eccentric_nz.TARDIS.TARDIS; |
20 | 20 | import me.eccentric_nz.TARDIS.api.event.TARDISAbandonEvent; |
21 | 21 | import me.eccentric_nz.TARDIS.blueprints.TARDISPermission; |
22 | | -import me.eccentric_nz.TARDIS.builders.exterior.TARDISBuilderUtility; |
23 | 22 | import me.eccentric_nz.TARDIS.commands.admin.TARDISAbandonLister; |
24 | 23 | import me.eccentric_nz.TARDIS.control.TARDISPowerButton; |
25 | | -import me.eccentric_nz.TARDIS.custommodels.keys.ChameleonVariant; |
26 | | -import me.eccentric_nz.TARDIS.custommodels.keys.ColouredVariant; |
27 | 24 | import me.eccentric_nz.TARDIS.database.converters.TARDISAbandonUpdate; |
28 | 25 | import me.eccentric_nz.TARDIS.database.data.Current; |
29 | 26 | import me.eccentric_nz.TARDIS.database.resultset.ResultSetCurrentFromId; |
|
41 | 38 | import me.eccentric_nz.TARDIS.enumeration.ChameleonPreset; |
42 | 39 | import me.eccentric_nz.TARDIS.enumeration.TardisModule; |
43 | 40 | import net.kyori.adventure.text.Component; |
44 | | -import org.bukkit.*; |
| 41 | +import org.bukkit.Location; |
| 42 | +import org.bukkit.Tag; |
| 43 | +import org.bukkit.World; |
45 | 44 | import org.bukkit.block.Block; |
46 | 45 | import org.bukkit.block.Sign; |
47 | 46 | import org.bukkit.block.sign.Side; |
48 | 47 | import org.bukkit.block.sign.SignSide; |
49 | 48 | import org.bukkit.command.CommandSender; |
| 49 | +import org.bukkit.entity.ArmorStand; |
50 | 50 | import org.bukkit.entity.Entity; |
51 | | -import org.bukkit.entity.ItemFrame; |
52 | 51 | import org.bukkit.entity.Player; |
| 52 | +import org.bukkit.inventory.EntityEquipment; |
| 53 | +import org.bukkit.inventory.EquipmentSlot; |
53 | 54 | import org.bukkit.inventory.ItemStack; |
54 | 55 | import org.bukkit.inventory.meta.ItemMeta; |
55 | 56 |
|
@@ -282,39 +283,32 @@ boolean doAbandon(CommandSender sender, boolean list) { |
282 | 283 | // always clear sign |
283 | 284 | if (preset.usesArmourStand()) { |
284 | 285 | World world = current.location().getWorld(); |
285 | | - // remove name from the item frame item |
286 | | - for (Entity e : world.getNearbyEntities(current.location(), 1.0d, 1.0d, 1.0d)) { |
287 | | - if (e instanceof ItemFrame frame) { |
288 | | - Material dye = TARDISBuilderUtility.getMaterialForArmourStand(preset, id, true); |
289 | | - ItemStack is = ItemStack.of(dye, 1); |
| 286 | + // remove custom name from the armour stand / helmet item |
| 287 | + for (Entity e : world.getNearbyEntities(current.location(), 1.1d, 1.1d, 1.1d)) { |
| 288 | + if (e instanceof ArmorStand stand) { |
| 289 | + ItemStack is = stand.getItem(EquipmentSlot.HEAD); |
290 | 290 | ItemMeta im = is.getItemMeta(); |
291 | | - NamespacedKey model = switch (is.getType()) { |
292 | | - case BLACK_DYE -> ChameleonVariant.BLACK_CLOSED.getKey(); |
293 | | - case BLUE_DYE -> ChameleonVariant.BLUE_CLOSED.getKey(); |
294 | | - case BROWN_DYE -> ChameleonVariant.BROWN_CLOSED.getKey(); |
295 | | - case CYAN_DYE -> ChameleonVariant.CYAN_CLOSED.getKey(); |
296 | | - case GRAY_DYE -> ChameleonVariant.GRAY_CLOSED.getKey(); |
297 | | - case GREEN_DYE -> ChameleonVariant.GREEN_CLOSED.getKey(); |
298 | | - case LIGHT_BLUE_DYE -> ChameleonVariant.LIGHT_BLUE_CLOSED.getKey(); |
299 | | - case LIGHT_GRAY_DYE -> ChameleonVariant.LIGHT_GRAY_CLOSED.getKey(); |
300 | | - case LIME_DYE -> ChameleonVariant.LIME_CLOSED.getKey(); |
301 | | - case MAGENTA_DYE -> ChameleonVariant.MAGENTA_CLOSED.getKey(); |
302 | | - case ORANGE_DYE -> ChameleonVariant.ORANGE_CLOSED.getKey(); |
303 | | - case PINK_DYE -> ChameleonVariant.PINK_CLOSED.getKey(); |
304 | | - case PURPLE_DYE -> ChameleonVariant.PURPLE_CLOSED.getKey(); |
305 | | - case RED_DYE -> ChameleonVariant.RED_CLOSED.getKey(); |
306 | | - case WHITE_DYE -> ChameleonVariant.WHITE_CLOSED.getKey(); |
307 | | - case YELLOW_DYE -> ChameleonVariant.YELLOW_CLOSED.getKey(); |
308 | | - case CYAN_STAINED_GLASS_PANE -> ChameleonVariant.TENNANT_CLOSED.getKey(); |
309 | | - case GRAY_STAINED_GLASS_PANE -> ChameleonVariant.WEEPING_ANGEL_CLOSED.getKey(); |
310 | | - case ENDER_PEARL -> ChameleonVariant.PANDORICA_CLOSED.getKey(); |
311 | | - case LEATHER_HORSE_ARMOR -> ColouredVariant.TINTED_CLOSED.getKey(); |
312 | | - default -> new NamespacedKey(plugin, TARDISBuilderUtility.getCustomModelPath(is.getType().toString()) + "_closed"); |
313 | | - }; |
314 | | - im.setItemModel(model); |
315 | | - im.displayName(Component.empty()); |
| 291 | + String pb = ""; |
| 292 | + switch (preset) { |
| 293 | + case WEEPING_ANGEL -> pb = "Weeping Angel"; |
| 294 | + case PANDORICA -> pb = "Pandorica"; |
| 295 | + case ITEM -> { |
| 296 | + for (String k : plugin.getCustomModelConfig().getConfigurationSection("models").getKeys(false)) { |
| 297 | + if (is.getType().toString().equals(plugin.getCustomModelConfig().getString("models." + k + ".item"))) { |
| 298 | + pb = k; |
| 299 | + break; |
| 300 | + } |
| 301 | + } |
| 302 | + } |
| 303 | + default -> pb = "Police Box"; |
| 304 | + } |
| 305 | + Component custom = Component.text("Abandoned " + pb); |
| 306 | + im.displayName(custom); |
316 | 307 | is.setItemMeta(im); |
317 | | - frame.setItem(is, false); |
| 308 | + EntityEquipment ee = stand.getEquipment(); |
| 309 | + ee.setHelmet(is, true); |
| 310 | + stand.customName(custom); |
| 311 | + stand.setCustomNameVisible(true); |
318 | 312 | break; |
319 | 313 | } |
320 | 314 | } |
|
0 commit comments