@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onPlayerRightClickBlock(Event event) { final Location location = event.getLocation(); final BlockState blockState = location.getBlockState(); if (!(blockState instanceof Sign)) return; // We only want signs TrackedSign trackedSign = trackedSigns.get(location); if (trackedSign == null) return; // We only want tracked signs final Player player = event.getPlayer(); final Location eyeLocation = player.getEyeLocation(); final SignShape shape = new SignShape(location); final SignTraceResult trace = shape.trace(eyeLocation); final int index = trace.index; if (index < 0 || index >= 4) return; // We only want valid indexes if (!trackedSign.hasEntry(index)) return; // We only want indexes for which the sign has a tracked entry final SignSession session = getOrCreateSession(player); if (session.isSelected(trackedSign, index)) { session.close(); final String routeName = trackedSign.getEntry(index); try { plugin.travelAgency.addTravellerWithMount( routeName, player, MobType.ENDER_DRAGON, "travel.sign", plugin.config.travelSignMaxDistance); player.sendMessage("Travelling on route '" + routeName + "'."); } catch (CommandException e) { player.sendMessage(e.getMessage()); } } else { session.select(trackedSign, index); } }