21
21
import me .eccentric_nz .TARDIS .customblocks .TARDISDisplayItemUtils ;
22
22
import me .eccentric_nz .TARDIS .database .resultset .ResultSetColour ;
23
23
import me .eccentric_nz .TARDIS .enumeration .ChameleonPreset ;
24
+ import me .eccentric_nz .TARDIS .flight .vehicle .TARDISArmourStand ;
25
+ import me .eccentric_nz .TARDIS .flight .vehicle .VehicleUtility ;
24
26
import me .eccentric_nz .TARDIS .move .TARDISDoorListener ;
25
27
import me .eccentric_nz .TARDIS .travel .TARDISDoorLocation ;
26
28
import me .eccentric_nz .TARDIS .utility .TARDISBlockSetters ;
31
33
import org .bukkit .block .Block ;
32
34
import org .bukkit .block .BlockFace ;
33
35
import org .bukkit .block .data .Levelled ;
34
- import org .bukkit .entity .*;
36
+ import org .bukkit .craftbukkit .v1_21_R2 .entity .CraftArmorStand ;
37
+ import org .bukkit .entity .ArmorStand ;
38
+ import org .bukkit .entity .Entity ;
39
+ import org .bukkit .entity .ItemFrame ;
40
+ import org .bukkit .entity .Player ;
35
41
import org .bukkit .inventory .EntityEquipment ;
36
42
import org .bukkit .inventory .ItemStack ;
37
43
import org .bukkit .inventory .meta .ItemMeta ;
@@ -81,7 +87,12 @@ public void buildPreset() {
81
87
boolean found = false ;
82
88
for (Entity e : world .getNearbyEntities (bd .getLocation (), 1.0d , 1.0d , 1.0d )) {
83
89
if (e instanceof ArmorStand a ) {
84
- stand = a ;
90
+ if (((CraftArmorStand ) a ).getHandle () instanceof TARDISArmourStand ) {
91
+ stand = a ;
92
+ } else {
93
+ stand = (ArmorStand ) VehicleUtility .spawnStand (bd .getLocation ()).getBukkitEntity ();
94
+ a .remove ();
95
+ }
85
96
found = true ;
86
97
break ;
87
98
}
@@ -100,49 +111,10 @@ public void buildPreset() {
100
111
block .setBlockData (TARDISConstants .AIR );
101
112
TARDISBlockSetters .setUnderDoorBlock (world , under .getX (), under .getY (), under .getZ (), bd .getTardisID (), false );
102
113
// spawn armour stand
103
- stand = (ArmorStand ) world . spawnEntity (bd .getLocation (). clone (). add ( 0.5d , 0 , 0.5d ), EntityType . ARMOR_STAND );
114
+ stand = (ArmorStand ) VehicleUtility . spawnStand (bd .getLocation ()). getBukkitEntity ( );
104
115
}
105
116
stand .setRotation (bd .getDirection ().getYaw (), 0.0f );
106
- Material dye = TARDISBuilderUtility .getMaterialForArmourStand (preset , bd .getTardisID (), true );
107
- ItemStack is = new ItemStack (dye , 1 );
108
- ItemMeta im = is .getItemMeta ();
109
- im .setCustomModelData (1001 );
110
- if (bd .shouldAddSign ()) {
111
- String pb = "" ;
112
- switch (preset ) {
113
- case WEEPING_ANGEL -> pb = "Weeping Angel" ;
114
- case PANDORICA -> pb = "Pandorica" ;
115
- case ITEM -> {
116
- for (String k : plugin .getCustomModelConfig ().getConfigurationSection ("models" ).getKeys (false )) {
117
- if (plugin .getCustomModelConfig ().getString ("models." + k + ".item" ).equals (dye .toString ())) {
118
- pb = k ;
119
- break ;
120
- }
121
- }
122
- }
123
- default -> pb = "Police Box" ;
124
- }
125
- String name = bd .getPlayer ().getName () + "'s " + pb ;
126
- im .setDisplayName (name );
127
- stand .setCustomName (name );
128
- stand .setCustomNameVisible (true );
129
- }
130
- if (preset == ChameleonPreset .COLOURED ) {
131
- // get the colour
132
- ResultSetColour rsc = new ResultSetColour (plugin , bd .getTardisID ());
133
- if (rsc .resultSet ()) {
134
- LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta ) im ;
135
- leatherArmorMeta .setColor (Color .fromRGB (rsc .getRed (), rsc .getGreen (), rsc .getBlue ()));
136
- is .setItemMeta (leatherArmorMeta );
137
- }
138
- } else {
139
- is .setItemMeta (im );
140
- }
141
- EntityEquipment ee = stand .getEquipment ();
142
- ee .setHelmet (is , true );
143
- stand .setInvulnerable (true );
144
- stand .setInvisible (true );
145
- stand .setGravity (false );
117
+ TARDISBuilderUtility .setPoliceBoxHelmet (plugin , preset , bd , stand );
146
118
// set a light block
147
119
Levelled levelled = TARDISConstants .LIGHT ;
148
120
// set light level from exterior lamp control
@@ -151,4 +123,5 @@ public void buildPreset() {
151
123
// add an interaction entity
152
124
TARDISDisplayItemUtils .setInteraction (stand , bd .getTardisID ());
153
125
}
126
+
154
127
}
0 commit comments