mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-11-03 18:53:43 +01:00 
			
		
		
		
	Fix players being able to place boats, armorstands etc using offhand
This commit is contained in:
		@@ -1886,23 +1886,29 @@ import java.util.regex.Pattern;
 | 
				
			|||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                ItemStack hand = player.getInventory().getItemInMainHand();
 | 
					                ItemStack hand = player.getInventory().getItemInMainHand();
 | 
				
			||||||
 | 
					                ItemStack offHand = player.getInventory().getItemInOffHand();
 | 
				
			||||||
                Material type = (hand == null) ? null : hand.getType();
 | 
					                Material type = (hand == null) ? null : hand.getType();
 | 
				
			||||||
                if (type == Material.AIR) {
 | 
					                Material offType = (offHand == null) ? null : offHand.getType();
 | 
				
			||||||
 | 
					                if ((type == Material.AIR && offType != Material.AIR && !player.isSneaking()
 | 
				
			||||||
 | 
					                    && blockType.isInteractable()) || (type == Material.AIR
 | 
				
			||||||
 | 
					                    && offType == Material.AIR)) {
 | 
				
			||||||
                    eventType = PlayerBlockEventType.INTERACT_BLOCK;
 | 
					                    eventType = PlayerBlockEventType.INTERACT_BLOCK;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					                if (!(type != null && type.equals(offType))) {
 | 
				
			||||||
 | 
					                    type = offType;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
                if (type == null || type.isBlock()) {
 | 
					                if (type == null || type.isBlock()) {
 | 
				
			||||||
                    location = BukkitUtil
 | 
					                    location = BukkitUtil
 | 
				
			||||||
                        .getLocation(block.getRelative(event.getBlockFace()).getLocation());
 | 
					                        .getLocation(block.getRelative(event.getBlockFace()).getLocation());
 | 
				
			||||||
                    eventType = PlayerBlockEventType.PLACE_BLOCK;
 | 
					                    eventType = PlayerBlockEventType.PLACE_BLOCK;
 | 
				
			||||||
                    break;
 | 
					                    break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                Material handType = hand.getType();
 | 
					                lb = new BukkitLazyBlock(PlotBlock.get(type.toString()));
 | 
				
			||||||
                lb = new BukkitLazyBlock(PlotBlock.get(handType.toString()));
 | 
					                if (type.toString().endsWith("egg")) {
 | 
				
			||||||
                if (handType.toString().endsWith("egg")) {
 | 
					 | 
				
			||||||
                    eventType = PlayerBlockEventType.SPAWN_MOB;
 | 
					                    eventType = PlayerBlockEventType.SPAWN_MOB;
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    switch (handType) {
 | 
					                    switch (type) {
 | 
				
			||||||
                        case FIREWORK_ROCKET:
 | 
					                        case FIREWORK_ROCKET:
 | 
				
			||||||
                        case FIREWORK_STAR:
 | 
					                        case FIREWORK_STAR:
 | 
				
			||||||
                            eventType = PlayerBlockEventType.SPAWN_MOB;
 | 
					                            eventType = PlayerBlockEventType.SPAWN_MOB;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user