11package vg .civcraft .mc .citadel ;
22
33import java .util .Objects ;
4+
45import org .bukkit .Bukkit ;
56import org .bukkit .Location ;
67import org .bukkit .block .Block ;
78import org .bukkit .block .BlockFace ;
89import org .bukkit .block .data .type .Bed ;
910import org .bukkit .block .data .type .Chest ;
11+ import org .bukkit .block .data .type .CoralWallFan ;
1012import org .bukkit .entity .Entity ;
1113import org .bukkit .entity .Player ;
1214import org .bukkit .inventory .InventoryHolder ;
@@ -25,7 +27,7 @@ private ReinforcementLogic() {
2527 /**
2628 * Inserts a new reinforcements into the cache, queues it for persistence and
2729 * plays particle effects for creation
28- *
30+ *
2931 * @param rein Reinforcement just created
3032 */
3133 public static void createReinforcement (Reinforcement rein ) {
@@ -36,7 +38,7 @@ public static void createReinforcement(Reinforcement rein) {
3638 }
3739
3840 public static Reinforcement callReinforcementCreationEvent (Player player , Block block , ReinforcementType type ,
39- Group group ) {
41+ Group group ) {
4042 Reinforcement rein = new Reinforcement (block .getLocation (), type , group );
4143 ReinforcementCreationEvent event = new ReinforcementCreationEvent (player , rein );
4244 Bukkit .getPluginManager ().callEvent (event );
@@ -98,38 +100,38 @@ public static Reinforcement getReinforcementProtecting(Block block) {
98100 return reinforcement ;
99101 }
100102 switch (block .getType ()) {
101- // Chests are awkward since you can place both sides of a double chest
102- // independently, which isn't true for
103- // beds, plants, or doors, so this needs to be accounted for and
104- // "getResponsibleBlock()" isn't appropriate
105- // for the following logic: that both sides protect each other; that if either
106- // block is reinforced, then
107- // the chest as a whole remains protected.
108- case CHEST :
109- case TRAPPED_CHEST : {
110- Chest chest = (Chest ) block .getBlockData ();
111- BlockFace facing = chest .getFacing ();
112- switch (chest .getType ()) {
113- case LEFT : {
114- BlockFace face = BlockAPI .turnClockwise (facing );
115- return getReinforcementAt (block .getLocation ().add (face .getDirection ()));
116- }
117- case RIGHT : {
118- BlockFace face = BlockAPI .turnAntiClockwise (facing );
119- return getReinforcementAt (block .getLocation ().add (face .getDirection ()));
103+ // Chests are awkward since you can place both sides of a double chest
104+ // independently, which isn't true for
105+ // beds, plants, or doors, so this needs to be accounted for and
106+ // "getResponsibleBlock()" isn't appropriate
107+ // for the following logic: that both sides protect each other; that if either
108+ // block is reinforced, then
109+ // the chest as a whole remains protected.
110+ case CHEST :
111+ case TRAPPED_CHEST : {
112+ Chest chest = (Chest ) block .getBlockData ();
113+ BlockFace facing = chest .getFacing ();
114+ switch (chest .getType ()) {
115+ case LEFT : {
116+ BlockFace face = BlockAPI .turnClockwise (facing );
117+ return getReinforcementAt (block .getLocation ().add (face .getDirection ()));
118+ }
119+ case RIGHT : {
120+ BlockFace face = BlockAPI .turnAntiClockwise (facing );
121+ return getReinforcementAt (block .getLocation ().add (face .getDirection ()));
122+ }
123+ default : {
124+ return null ;
125+ }
126+ }
120127 }
121128 default : {
122- return null ;
123- }
124- }
125- }
126- default : {
127- Block responsible = getResponsibleBlock (block );
128- if (Objects .equals (block , responsible )) {
129- return null ;
129+ Block responsible = getResponsibleBlock (block );
130+ if (Objects .equals (block , responsible )) {
131+ return null ;
132+ }
133+ return getReinforcementAt (responsible .getLocation ());
130134 }
131- return getReinforcementAt (responsible .getLocation ());
132- }
133135 }
134136 }
135137
@@ -143,7 +145,7 @@ public static Reinforcement getReinforcementProtecting(Block block) {
143145 * @param block Block to get responsible block for
144146 * @return Block which reinforcement would protect the given block
145147 */
146-
148+
147149 public static Block getResponsibleBlock (Block block ) {
148150 // Do not put [double] chests in here.
149151 switch (block .getType ()) {
@@ -171,6 +173,7 @@ public static Block getResponsibleBlock(Block block) {
171173 case CARROTS :
172174 case POTATOES :
173175 case BEETROOTS :
176+ case SWEET_BERRY_BUSH :
174177 case MELON_STEM :
175178 case PUMPKIN_STEM :
176179 case ATTACHED_MELON_STEM :
@@ -300,7 +303,7 @@ public static Block getResponsibleBlock(Block block) {
300303 * @param player the player attempting to access stuff
301304 * @param block Block to check for
302305 * @return True if the player can not do something like placing an adjacent
303- * chest or comparator, false otherwise
306+ * chest or comparator, false otherwise
304307 */
305308 public static boolean isPreventingBlockAccess (Player player , Block block ) {
306309 if (block == null ) {
0 commit comments