@@ -145,7 +145,9 @@ public void onVaultPlace(BlockPlaceEvent e) {
145
145
continue ;
146
146
}
147
147
148
- if (blockLoc .getBlock ().getType () == Material .CHEST ) {
148
+ Material blockMaterial = blockLoc .getBlock ().getType ();
149
+
150
+ if (blockMaterial == Material .CHEST || (P .p .getConfig ().getBoolean ("fvault.No-Hoppers-near-vault" ) && blockMaterial == Material .HOPPER )) {
149
151
e .setCancelled (true );
150
152
fme .msg (TL .COMMAND_GETVAULT_CHESTNEAR );
151
153
return ;
@@ -161,6 +163,45 @@ public void onVaultPlace(BlockPlaceEvent e) {
161
163
}
162
164
}
163
165
166
+ @ EventHandler
167
+ public void onHopperPlace (BlockPlaceEvent e ) {
168
+
169
+ if (e .getItemInHand ().getType () != Material .HOPPER && !P .p .getConfig ().getBoolean ("fvault.No-Hoppers-near-vault" )) {
170
+ return ;
171
+ }
172
+
173
+ Faction factionAt = Board .getInstance ().getFactionAt (new FLocation (e .getBlockPlaced ().getLocation ()));
174
+
175
+ if (factionAt .isWilderness () || factionAt .getVault () == null ) {
176
+ return ;
177
+ }
178
+
179
+
180
+ FPlayer fme = FPlayers .getInstance ().getByPlayer (e .getPlayer ());
181
+
182
+ Block start = e .getBlockPlaced ();
183
+ int radius = 1 ;
184
+ for (double x = start .getLocation ().getX () - radius ; x <= start .getLocation ().getX () + radius ; x ++) {
185
+ for (double y = start .getLocation ().getY () - radius ; y <= start .getLocation ().getY () + radius ; y ++) {
186
+ for (double z = start .getLocation ().getZ () - radius ; z <= start .getLocation ().getZ () + radius ; z ++) {
187
+ Location blockLoc = new Location (e .getPlayer ().getWorld (), x , y , z );
188
+ if (blockLoc .getX () == start .getLocation ().getX () && blockLoc .getY () == start .getLocation ().getY () && blockLoc .getZ () == start .getLocation ().getZ ()) {
189
+ continue ;
190
+ }
191
+
192
+ if (blockLoc .getBlock ().getType () == Material .CHEST ) {
193
+ if (factionAt .getVault ().equals (blockLoc )) {
194
+ e .setCancelled (true );
195
+ fme .msg (TL .COMMAND_VAULT_NO_HOPPER );
196
+ return ;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+
203
+ }
204
+
164
205
@ EventHandler (priority = EventPriority .NORMAL , ignoreCancelled = true )
165
206
public void onBlockPistonRetract (BlockPistonRetractEvent event ) {
166
207
// if not a sticky piston, retraction should be fine
0 commit comments