// Path: src/main/java/com/nisovin/shopkeepers/compat/NMSManager.java
// public final class NMSManager {
// 
// 	private static NMSCallProvider provider;
// 
// 	public static NMSCallProvider getProvider() {
// 		return NMSManager.provider;
// 	}
// 
// 	public static void load(Plugin plugin) {
// 		final String packageName = plugin.getServer().getClass().getPackage().getName();
// 		String cbversion = packageName.substring(packageName.lastIndexOf('.') + 1);
// 		try {
// 			final Class<?> clazz = Class.forName("com.nisovin.shopkeepers.compat." + cbversion + ".NMSHandler");
// 			if (NMSCallProvider.class.isAssignableFrom(clazz)) {
// 				NMSManager.provider = (NMSCallProvider) clazz.getConstructor().newInstance();
// 			} else {
// 				throw new Exception("Nope");
// 			}
// 		} catch (final Exception e) {
// 			Log.severe("Potentially incompatible server version: " + cbversion);
// 			Log.severe("Shopkeepers is trying to run in 'compatibility mode'.");
// 			Log.info("Check for updates at: " + plugin.getDescription().getWebsite());
// 
// 			try {
// 				NMSManager.provider = new FailedHandler();
// 			} catch (Exception e_u) {
// 				// uncomment for debugging:
// 				// e_u.printStackTrace();
// 			}
// 		}
// 	}
// }


import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import com.nisovin.shopkeepers.compat.NMSManager;
package com.nisovin.shopkeepers;




class SignShopListener implements Listener {

	private final ShopkeepersPlugin plugin;

	private Location cancelNextBlockPhysicsLoc = null;

	SignShopListener(ShopkeepersPlugin plugin) {
		this.plugin = plugin;
	}

	void cancelNextBlockPhysics(Location location) {
		cancelNextBlockPhysicsLoc = location;
	}

	@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
	void onPlayerInteract(PlayerInteractEvent event) {
		Player player = event.getPlayer();
		Block block = event.getClickedBlock();

		// check for sign shop
		if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Utils.isSign(block.getType())) {
			Shopkeeper shopkeeper = plugin.getShopkeeperByBlock(block);
			if (shopkeeper != null) {
				// only trigger shopkeeper interaction for main-hand events:
// Path: src/main/java/com/nisovin/shopkeepers/compat/NMSManager.java
// public final class NMSManager {
// 
// 	private static NMSCallProvider provider;
// 
// 	public static NMSCallProvider getProvider() {
// 		return NMSManager.provider;
// 	}
// 
// 	public static void load(Plugin plugin) {
// 		final String packageName = plugin.getServer().getClass().getPackage().getName();
// 		String cbversion = packageName.substring(packageName.lastIndexOf('.') + 1);
// 		try {
// 			final Class<?> clazz = Class.forName("com.nisovin.shopkeepers.compat." + cbversion + ".NMSHandler");
// 			if (NMSCallProvider.class.isAssignableFrom(clazz)) {
// 				NMSManager.provider = (NMSCallProvider) clazz.getConstructor().newInstance();
// 			} else {
// 				throw new Exception("Nope");
// 			}
// 		} catch (final Exception e) {
// 			Log.severe("Potentially incompatible server version: " + cbversion);
// 			Log.severe("Shopkeepers is trying to run in 'compatibility mode'.");
// 			Log.info("Check for updates at: " + plugin.getDescription().getWebsite());
// 
// 			try {
// 				NMSManager.provider = new FailedHandler();
// 			} catch (Exception e_u) {
// 				// uncomment for debugging:
// 				// e_u.printStackTrace();
// 			}
// 		}
// 	}
// }


// Path: src/main/java/com/nisovin/shopkeepers/SignShopListener.java
import java.util.Iterator;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import com.nisovin.shopkeepers.compat.NMSManager;

package com.nisovin.shopkeepers;




class SignShopListener implements Listener {

	private final ShopkeepersPlugin plugin;

	private Location cancelNextBlockPhysicsLoc = null;

	SignShopListener(ShopkeepersPlugin plugin) {
		this.plugin = plugin;
	}

	void cancelNextBlockPhysics(Location location) {
		cancelNextBlockPhysicsLoc = location;
	}

	@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
	void onPlayerInteract(PlayerInteractEvent event) {
		Player player = event.getPlayer();
		Block block = event.getClickedBlock();

		// check for sign shop
		if (event.getAction() == Action.RIGHT_CLICK_BLOCK && Utils.isSign(block.getType())) {
			Shopkeeper shopkeeper = plugin.getShopkeeperByBlock(block);
			if (shopkeeper != null) {
				// only trigger shopkeeper interaction for main-hand events:
				if (NMSManager.getProvider().isMainHandInteraction(event)) {