├── .checkstyle └── checkstyle.xml ├── .editorconfig_ ├── .gitignore ├── README.md ├── build.gradle.kts ├── docs ├── banner.png ├── directed_edges.png ├── editmode_01.png ├── groups.png ├── labloop.gif ├── path_01.png └── path_02.png ├── examples ├── README.md ├── images │ ├── example_color_transition.gif │ ├── example_ghosts.gif │ ├── example_rainbow.gif │ └── example_simple.gif ├── pathfinder$example_color_transition.yml ├── pathfinder$example_ghosts.yml ├── pathfinder$example_rainbow.yml └── pathfinder$example_simple.yml ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── pathfinder-api ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ ├── Changes.java │ ├── ExtensionsRegistry.java │ ├── PathFinder.java │ ├── PathFinderConfig.java │ ├── PathFinderExtension.java │ ├── PathFinderProvider.java │ ├── dump │ ├── DumpWriter.java │ └── DumpWriterProvider.java │ ├── editor │ ├── GraphEditor.java │ ├── GraphEditorFactory.java │ └── GraphRenderer.java │ ├── event │ ├── EventCancelledException.java │ ├── EventDispatcher.java │ ├── Listener.java │ ├── NodeCreateEvent.java │ ├── NodeDeleteEvent.java │ ├── NodeEvent.java │ ├── NodeGroupCreateEvent.java │ ├── NodeGroupDeleteEvent.java │ ├── NodeGroupEvent.java │ ├── NodeGroupSaveEvent.java │ ├── NodeSaveEvent.java │ ├── PathCancelledEvent.java │ ├── PathEvent.java │ ├── PathFinderEvent.java │ ├── PathFinderReloadEvent.java │ ├── PathStartEvent.java │ ├── PathStoppedEvent.java │ ├── PathTargetReachedEvent.java │ ├── PlayerDiscoverLocationEvent.java │ ├── PlayerDiscoverProgressEvent.java │ └── PlayerForgetLocationEvent.java │ ├── group │ ├── CurveLengthModifier.java │ ├── DiscoverProgressModifier.java │ ├── DiscoverableModifier.java │ ├── FindDistanceModifier.java │ ├── Modified.java │ ├── Modifier.java │ ├── ModifierRegistry.java │ ├── ModifierType.java │ ├── NavigableModifier.java │ ├── NodeGroup.java │ ├── PermissionModifier.java │ └── VisualizerModifier.java │ ├── misc │ ├── Keyed.java │ ├── KeyedRegistry.java │ ├── Location.java │ ├── Nameable.java │ ├── Named.java │ ├── NamespacedKey.java │ ├── Pagination.java │ ├── PathPlayer.java │ ├── PathPlayerProvider.java │ ├── PermissionHolder.java │ ├── Range.java │ ├── Task.java │ ├── Vector.java │ └── World.java │ ├── navigation │ ├── Navigation.java │ ├── NavigationConstraint.java │ ├── NavigationLocation.java │ ├── NavigationLocationImpl.java │ ├── NavigationModule.java │ ├── NavigationModuleProvider.java │ ├── Navigator.java │ ├── Route.java │ ├── RouteImpl.java │ ├── SingletonRoute.java │ └── UpdatingPath.java │ ├── node │ ├── Edge.java │ ├── GroupedNode.java │ ├── Node.java │ ├── NodeSelection.java │ ├── NodeSelectionProvider.java │ ├── NodeType.java │ └── NodeTypeRegistry.java │ ├── storage │ ├── CacheLayer.java │ ├── DatabaseType.java │ ├── DiscoverInfo.java │ ├── NodeStorageImplementation.java │ ├── StorageAdapter.java │ ├── StorageImplementation.java │ ├── VisualizerStorageImplementation.java │ ├── WorldLoader.java │ └── cache │ │ ├── DiscoverInfoCache.java │ │ ├── GroupCache.java │ │ ├── NodeCache.java │ │ ├── NodeTypeCache.java │ │ ├── StorageCache.java │ │ ├── VisualizerCache.java │ │ └── VisualizerTypeCache.java │ └── visualizer │ ├── PathView.java │ ├── PathVisualizer.java │ ├── VisualizerPath.java │ ├── VisualizerType.java │ ├── VisualizerTypeRegistry.java │ └── query │ ├── SearchQueryAttribute.java │ ├── SearchTerm.java │ └── SearchTermHolder.java ├── pathfinder-bukkit ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── de │ │ └── cubbossa │ │ └── pathfinder │ │ ├── BStatsLoader.java │ │ ├── BukkitPathFinder.java │ │ ├── BukkitPathPlayer.java │ │ ├── BukkitPathSender.java │ │ ├── CommandRegistry.java │ │ ├── PathFinderPlugin.java │ │ ├── command │ │ ├── Arguments.java │ │ ├── CancelPathCommand.java │ │ ├── CommandArgument.java │ │ ├── CustomLiteralArgument.java │ │ ├── DiscoveriesCommand.java │ │ ├── FindCommand.java │ │ ├── FindLocationCommand.java │ │ ├── FindPlayerManager.java │ │ ├── PathFinderCommand.java │ │ ├── PathFinderSubCommand.java │ │ ├── impl │ │ │ ├── CreateGroupCmd.java │ │ │ ├── CreateNodeCmd.java │ │ │ ├── CreateVisualizerCmd.java │ │ │ ├── DeleteGroupCmd.java │ │ │ ├── DeleteNodesCmd.java │ │ │ ├── DeleteVisualizerCmd.java │ │ │ ├── GroupCmd.java │ │ │ ├── ImportVisualizerCmd.java │ │ │ ├── ListGroupsCmd.java │ │ │ ├── ListNodesCmd.java │ │ │ ├── ListVisualizersCmd.java │ │ │ ├── NavigateCmd.java │ │ │ ├── NodesCmd.java │ │ │ ├── ReloadCmd.java │ │ │ └── VisualizerCmd.java │ │ └── util │ │ │ ├── CommandHelpBuilder.java │ │ │ ├── CommandHelpGenerator.java │ │ │ └── CommandUtils.java │ │ ├── discovery │ │ └── BukkitDiscoveryModule.java │ │ ├── events │ │ ├── BukkitEventDispatcher.java │ │ ├── NodeFindEvent.java │ │ ├── NodeGroupFindEvent.java │ │ ├── PathFinderReloadEventImpl.java │ │ ├── discovering │ │ │ ├── PlayerDiscoverEvent.java │ │ │ ├── PlayerDiscoverProgressEvent.java │ │ │ └── PlayerForgetEvent.java │ │ ├── node │ │ │ ├── EdgesCreateEvent.java │ │ │ ├── EdgesDeleteEvent.java │ │ │ ├── NodeCreateEvent.java │ │ │ ├── NodeCreatedEvent.java │ │ │ ├── NodeCurveLengthChangedEvent.java │ │ │ ├── NodeDeletedEvent.java │ │ │ ├── NodeLocationChangedEvent.java │ │ │ ├── NodeSavedEvent.java │ │ │ ├── NodeTeleportEvent.java │ │ │ └── NodesDeleteEvent.java │ │ ├── nodegroup │ │ │ ├── GroupCreatedEvent.java │ │ │ ├── GroupDeleteEvent.java │ │ │ ├── GroupSaveEvent.java │ │ │ ├── NodeGroupAssignEvent.java │ │ │ ├── NodeGroupAssignedEvent.java │ │ │ ├── NodeGroupFindDistanceChangedEvent.java │ │ │ ├── NodeGroupNameChangedEvent.java │ │ │ ├── NodeGroupNavigableChangedEvent.java │ │ │ ├── NodeGroupPermissionChangedEvent.java │ │ │ ├── NodeGroupRemoveEvent.java │ │ │ ├── NodeGroupRemovedEvent.java │ │ │ └── NodeGroupSearchTermsChangedEvent.java │ │ ├── path │ │ │ ├── PathCancelEvent.java │ │ │ ├── PathStartEvent.java │ │ │ ├── PathStopEvent.java │ │ │ └── PathTargetFoundEvent.java │ │ └── visualizer │ │ │ ├── CombinedVisualizerChangedEvent.java │ │ │ ├── VisualizerCreatedEvent.java │ │ │ ├── VisualizerNameChangedEvent.java │ │ │ ├── VisualizerPermissionChangedEvent.java │ │ │ └── VisualizerPropertyChangedEvent.java │ │ ├── listener │ │ ├── BukkitEffects.java │ │ └── PlayerListener.java │ │ ├── migration │ │ └── V5_0_0__Config.java │ │ ├── navigation │ │ └── BukkitNavigationModule.java │ │ ├── node │ │ └── selection │ │ │ ├── BukkitNodeSelectionParser.java │ │ │ └── attribute │ │ │ └── WorldSelectionAttribute.java │ │ ├── nodegroup │ │ └── modifier │ │ │ ├── CurveLengthModifierType.java │ │ │ ├── DiscoverableModifierType.java │ │ │ ├── DiscoveriesProgressModifierType.java │ │ │ ├── FindDistanceModifierType.java │ │ │ ├── NavigableModifierType.java │ │ │ ├── PermissionModifierType.java │ │ │ └── VisualizerModifierType.java │ │ ├── util │ │ ├── BukkitMainThreadExecutor.java │ │ ├── BukkitUtils.java │ │ ├── BukkitVectorUtils.java │ │ ├── LocalizedItem.java │ │ ├── NodeUtils.java │ │ └── WorldImpl.java │ │ └── visualizer │ │ ├── BukkitParticlePlayer.java │ │ └── impl │ │ ├── AdvancedParticleVisualizer.java │ │ ├── BezierPathVisualizer.java │ │ ├── BezierVisualizerType.java │ │ ├── BossBarVisualizer.java │ │ ├── BukkitVisualizer.java │ │ ├── CombinedVisualizerType.java │ │ ├── CompassVisualizer.java │ │ ├── CompassVisualizerType.java │ │ ├── EdgeBasedVisualizer.java │ │ ├── IntervalVisualizer.java │ │ ├── IntervalVisualizerType.java │ │ ├── ParticleVisualizer.java │ │ └── ParticleVisualizerType.java │ └── test │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ ├── util │ ├── BukkitVectorUtilsTest.java │ ├── CommandUtilsTest.java │ └── VectorUtilsTest.java │ └── visualizer │ ├── AbstractParticlePlayerTest.java │ ├── PlaceholderVisualizerTest.java │ └── VisualizerPathImplTest.java ├── pathfinder-citizens ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ └── citizens │ ├── CitizensPathVisualizer.java │ ├── NPCVisualizerGoalController.java │ └── PathFinderCitizensExtension.java ├── pathfinder-core ├── build.gradle.kts └── src │ ├── main │ ├── antlr │ │ └── de │ │ │ └── cubbossa │ │ │ └── pathfinder │ │ │ └── antlr │ │ │ ├── QueryLanguage.g4 │ │ │ ├── SelectionLanguage.g4 │ │ │ └── SelectionSuggestionLanguage.g4 │ ├── java │ │ └── de │ │ │ └── cubbossa │ │ │ └── pathfinder │ │ │ ├── AbstractPathFinder.java │ │ │ ├── ConfigFileLoader.java │ │ │ ├── ExtensionsRegistryImpl.java │ │ │ ├── PathFinderConfigImpl.java │ │ │ ├── PathFinderExtensionBase.java │ │ │ ├── PathPerms.java │ │ │ ├── Wiki.java │ │ │ ├── command │ │ │ ├── CmdTagResolver.java │ │ │ ├── CommandPlaceholderProcessor.java │ │ │ ├── CommandPlaceholderProcessorImpl.java │ │ │ ├── ModifierCommandExtension.java │ │ │ ├── VisualizerTypeCommandExtension.java │ │ │ └── VisualizerTypeMessageExtension.java │ │ │ ├── discovery │ │ │ └── AbstractDiscoveryModule.java │ │ │ ├── dump │ │ │ ├── DumpWriterDataProvider.java │ │ │ └── DumpWriterImpl.java │ │ │ ├── examples │ │ │ ├── ExamplesFileReader.java │ │ │ └── ExamplesLoader.java │ │ │ ├── messages │ │ │ ├── MessageFormatter.java │ │ │ └── Messages.java │ │ │ ├── migration │ │ │ └── Migrator.java │ │ │ ├── navigation │ │ │ ├── AbstractNavigationModule.java │ │ │ ├── NavigatorImpl.java │ │ │ └── query │ │ │ │ ├── FindQueryException.java │ │ │ │ ├── FindQueryParser.java │ │ │ │ ├── QueryLanguageVisitor.java │ │ │ │ ├── SearchQueryAttribute.java │ │ │ │ └── SearchTermImpl.java │ │ │ ├── node │ │ │ ├── AbstractNodeType.java │ │ │ ├── EdgeImpl.java │ │ │ ├── GraphEditorRegistry.java │ │ │ ├── GroupedNodeImpl.java │ │ │ ├── NavigateSelection.java │ │ │ ├── NodeSelectionImpl.java │ │ │ ├── NodeSelectionProviderImpl.java │ │ │ ├── NodeTypeRegistryImpl.java │ │ │ ├── WaypointType.java │ │ │ ├── implementation │ │ │ │ ├── EmptyNode.java │ │ │ │ ├── PlayerNode.java │ │ │ │ └── Waypoint.java │ │ │ └── selection │ │ │ │ ├── AbstractNodeSelectionParser.java │ │ │ │ ├── NodeSelectionAttribute.java │ │ │ │ ├── NumberRange.java │ │ │ │ ├── ParsedSelectionAttribute.java │ │ │ │ ├── SelectSuggestionVisitor.java │ │ │ │ ├── SelectionVisitor.java │ │ │ │ └── attribute │ │ │ │ ├── DistanceSelectionAttribute.java │ │ │ │ ├── GroupSelectionAttribute.java │ │ │ │ ├── IdSelectionAttribute.java │ │ │ │ ├── LimitSelectionAttribute.java │ │ │ │ ├── OffsetSelectionAttribute.java │ │ │ │ └── SortSelectionAttribute.java │ │ │ ├── nodegroup │ │ │ ├── ModifierRegistryImpl.java │ │ │ ├── NoImplGraphEditor.java │ │ │ ├── NodeGroupImpl.java │ │ │ └── modifier │ │ │ │ ├── CurveLengthModifierImpl.java │ │ │ │ ├── DiscoverProgressModifierImpl.java │ │ │ │ ├── DiscoverableModifierImpl.java │ │ │ │ ├── FindDistanceModifierImpl.java │ │ │ │ ├── NavigableModifierImpl.java │ │ │ │ ├── PermissionModifierImpl.java │ │ │ │ └── VisualizerModifierImpl.java │ │ │ ├── storage │ │ │ ├── DataStorageException.java │ │ │ ├── InternalVisualizerStorageImplementation.java │ │ │ ├── StorageAdapterImpl.java │ │ │ ├── StorageUtil.java │ │ │ ├── WaypointStorageImplementation.java │ │ │ ├── cache │ │ │ │ ├── CacheLayerImpl.java │ │ │ │ ├── DiscoverInfoCacheImpl.java │ │ │ │ ├── GroupCacheImpl.java │ │ │ │ ├── NodeCacheImpl.java │ │ │ │ ├── NodeTypeCacheImpl.java │ │ │ │ ├── VisualizerCacheImpl.java │ │ │ │ └── VisualizerTypeCacheImpl.java │ │ │ ├── implementation │ │ │ │ ├── AbstractStorage.java │ │ │ │ ├── DebugStorage.java │ │ │ │ ├── NodeStorageImplementationWrapper.java │ │ │ │ ├── RemoteSqlStorage.java │ │ │ │ ├── SqlStorage.java │ │ │ │ ├── SqliteStorage.java │ │ │ │ ├── VisualizerStorageImplementationWrapper.java │ │ │ │ └── YmlStorage.java │ │ │ └── misc │ │ │ │ ├── NamespacedKeyConverter.java │ │ │ │ └── UUIDConverter.java │ │ │ ├── util │ │ │ ├── CollectionUtils.java │ │ │ ├── EdgeBasedGraphEntrySolver.java │ │ │ ├── ExtensionPoint.java │ │ │ ├── FileUtils.java │ │ │ ├── FutureUtils.java │ │ │ ├── HashedRegistry.java │ │ │ ├── IntPair.java │ │ │ ├── LerpUtils.java │ │ │ ├── ModifiedHashMap.java │ │ │ ├── ModifiedHashSet.java │ │ │ ├── MultiMap.java │ │ │ ├── NodeGraphUtil.java │ │ │ ├── SelectionParser.java │ │ │ ├── StringCompass.java │ │ │ ├── StringUtils.java │ │ │ ├── VectorSplineLib.java │ │ │ ├── VectorUtils.java │ │ │ ├── Version.java │ │ │ └── YamlUtils.java │ │ │ └── visualizer │ │ │ ├── AbstractParticlePlayer.java │ │ │ ├── AbstractParticleTrailPlayer.java │ │ │ ├── AbstractVisualizer.java │ │ │ ├── AbstractVisualizerPath.java │ │ │ ├── AbstractVisualizerType.java │ │ │ ├── GroupedVisualizerPathImpl.java │ │ │ ├── SingleVisualizerPathImpl.java │ │ │ ├── VisualizerTypeRegistryImpl.java │ │ │ └── impl │ │ │ └── CombinedVisualizer.java │ └── resources │ │ ├── database_template.db │ │ └── lang │ │ └── styles.properties │ └── test │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ ├── AbstractNavigationModuleTest.java │ ├── command │ └── CommandPlaceholderProcessorImplTest.java │ ├── dump │ └── DumpWriterImplTest.java │ ├── module │ └── visualizing │ │ └── navigationquery │ │ └── FindQueryParserTest.java │ ├── navigation │ └── IntegrationRouteTest.java │ ├── nodeselection │ ├── NumberRangeTest.java │ ├── SelectionParserTest.java │ └── SelectionVisitorTest.java │ ├── storage │ ├── CacheLayerTest.java │ ├── H2StorageTest.java │ ├── SqliteStorageTest.java │ └── StorageTest.java │ └── util │ ├── CommandHelpGeneratorTest.java │ ├── FileUtilsTest.java │ ├── ModifiedHashMapTest.java │ ├── ModifiedHashSetTest.java │ ├── StringCompassTest.java │ ├── VectorUtilsTest.java │ └── VersionTest.java ├── pathfinder-editmode ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ └── editmode │ ├── DefaultGraphEditor.java │ ├── DefaultGraphEditorFactory.java │ ├── RoadMapEditorExtension.java │ ├── menu │ └── EditModeMenu.java │ ├── renderer │ ├── AbstractArmorstandRenderer.java │ ├── AbstractEntityRenderer.java │ ├── EdgeArmorStandRenderer.java │ ├── EdgeEntityRenderer.java │ ├── NodeArmorStandRenderer.java │ ├── NodeEntityRenderer.java │ ├── NodeGroupListRenderer.java │ └── ParticleEdgeRenderer.java │ └── utils │ ├── DataUtils.java │ └── ItemStackUtils.java ├── pathfinder-graph ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── de │ │ └── cubbossa │ │ └── pathfinder │ │ └── graph │ │ ├── AStarImpl.java │ │ ├── ContractionHierarchies.java │ │ ├── DynamicDijkstra.java │ │ ├── FibonacciHeap.java │ │ ├── GraphEntryNotEstablishedException.java │ │ ├── GraphEntrySolver.java │ │ ├── GraphUtils.java │ │ ├── NoPathFoundException.java │ │ ├── PathSolver.java │ │ ├── PathSolverResult.java │ │ ├── PathSolverResultImpl.java │ │ └── StaticDijkstra.java │ └── test │ └── java │ ├── com │ └── google │ │ └── common │ │ └── graph │ │ └── ValueGraphGen.java │ └── de │ └── cubbossa │ └── pathfinder │ └── graph │ ├── AStarImplTest.java │ ├── DynamicDijkstraTest.java │ ├── GraphUtilsTest.java │ ├── ShortestPathTest.java │ └── StaticDijkstraTest.java ├── pathfinder-papi ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ └── module │ └── papi │ ├── PlaceholderExtension.java │ ├── PlaceholderHook.java │ ├── PlaceholderVisualizer.java │ └── PlaceholderVisualizerType.java ├── pathfinder-quests-module ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ └── module │ └── quests │ ├── DiscoveryRequirement.java │ ├── DiscoveryReward.java │ └── PathFinderQuestsModule.java ├── pathfinder-scripted-visualizer ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ └── visualizer │ ├── ScriptLineParticleVisualizer.java │ ├── ScriptLineParticleVisualizerType.java │ └── ScriptedVisualizerPathfinderExtension.java ├── pathfinder-test-utils ├── build.gradle.kts └── src │ └── main │ └── java │ └── de │ └── cubbossa │ └── pathfinder │ ├── PathFinderTest.java │ ├── TestModifier.java │ ├── TestModifierType.java │ ├── TestNode.java │ ├── TestPlayer.java │ ├── TestVisualizer.java │ └── TestVisualizerType.java └── settings.gradle.kts /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | idea 3 | java 4 | eclipse 5 | } 6 | 7 | java { 8 | toolchain { 9 | languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | } 12 | 13 | group = "de.cubbossa" 14 | version = "5.4.2" 15 | 16 | subprojects { 17 | 18 | apply { 19 | plugin("java") 20 | } 21 | 22 | repositories { 23 | mavenCentral() 24 | maven("https://nexus.leonardbausenwein.de/repository/maven-public/") 25 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots") 26 | maven("https://nexus.leonardbausenwein.de/repository/maven-public/") 27 | } 28 | 29 | dependencies { 30 | implementation("org.pf4j:pf4j:3.11.0") 31 | annotationProcessor("org.pf4j:pf4j:3.11.0") 32 | testImplementation("org.pf4j:pf4j:3.11.0") 33 | 34 | testAnnotationProcessor("org.pf4j:pf4j:3.11.0") 35 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2") 36 | testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2") 37 | // testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2") 38 | 39 | testImplementation("com.pholser:junit-quickcheck-core:1.0") 40 | testImplementation("com.pholser:junit-quickcheck-generators:1.0") 41 | } 42 | 43 | tasks { 44 | test { 45 | useJUnitPlatform() 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /docs/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/banner.png -------------------------------------------------------------------------------- /docs/directed_edges.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/directed_edges.png -------------------------------------------------------------------------------- /docs/editmode_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/editmode_01.png -------------------------------------------------------------------------------- /docs/groups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/groups.png -------------------------------------------------------------------------------- /docs/labloop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/labloop.gif -------------------------------------------------------------------------------- /docs/path_01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/path_01.png -------------------------------------------------------------------------------- /docs/path_02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/docs/path_02.png -------------------------------------------------------------------------------- /examples/images/example_color_transition.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/examples/images/example_color_transition.gif -------------------------------------------------------------------------------- /examples/images/example_ghosts.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/examples/images/example_ghosts.gif -------------------------------------------------------------------------------- /examples/images/example_rainbow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/examples/images/example_rainbow.gif -------------------------------------------------------------------------------- /examples/images/example_simple.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/examples/images/example_simple.gif -------------------------------------------------------------------------------- /examples/pathfinder$example_color_transition.yml: -------------------------------------------------------------------------------- 1 | type: pathfinder:particle 2 | display-name: (Example) Color Transition 3 | particle-steps: 50 4 | interval: 1 5 | particle: DUST_COLOR_TRANSITION 6 | particle-data: 7 | ==: de.cubbossa.pathfinder.util.YamlUtils$DustTransitionWrapper 8 | from: 9 | ==: Color 10 | RED: 255 11 | BLUE: 0 12 | GREEN: 0 13 | to: 14 | ==: Color 15 | RED: 0 16 | BLUE: 0 17 | GREEN: 0 18 | size: 1.0 19 | speed: 1.0 20 | amount: 1 21 | offset: 22 | ==: Vector 23 | x: 0.001 24 | y: 0.001 25 | z: 0.001 26 | sample-rate: 16 27 | point-distance: 0.2 28 | -------------------------------------------------------------------------------- /examples/pathfinder$example_ghosts.yml: -------------------------------------------------------------------------------- 1 | type: pathfinder:particle 2 | display-name: (Example) <#7B42F5>Ghosts 3 | particle-steps: 50 4 | particle: SCULK_SOUL 5 | speed: 0.01 6 | amount: 1 7 | offset: 8 | ==: Vector 9 | x: 0.001 10 | y: 0.001 11 | z: 0.001 12 | sample-rate: 16 13 | point-distance: 0.2 14 | -------------------------------------------------------------------------------- /examples/pathfinder$example_rainbow.yml: -------------------------------------------------------------------------------- 1 | type: pathfinder:scriptline 2 | display-name: (Example) Rainbow 3 | particle-steps: 5 4 | interval: 2 5 | particle: REDSTONE 6 | particle-data: var DustOptions = Java.type('org.bukkit.Particle$DustOptions'); new 7 | DustOptions(Java.type('org.bukkit.Color').fromRGB((Java.type('java.awt.Color').getHSBColor((interval+index 8 | % 100) / 100, 1, 1).getRGB() & 0xffffff)), 1) 9 | speed: '0.0001' 10 | amount: '1' 11 | offset-x: '0' 12 | offset-y: '0.0001' 13 | offset-z: '0.0001' 14 | path-x: 'Math.cos(index/5)*Math.cos(index/11)*Math.cos(index/3)*.5' 15 | path-y: 'Math.sin(index/5)*Math.sin(index/11)*Math.cos(index/3)*.3' 16 | path-z: '0' 17 | sample-rate: 16 18 | point-distance: 0.2 19 | -------------------------------------------------------------------------------- /examples/pathfinder$example_simple.yml: -------------------------------------------------------------------------------- 1 | type: pathfinder:particle 2 | display-name: (Example) <#7B42F5>Simple 3 | particle-steps: 50 4 | particle: SCRAPE 5 | speed: 0.5 6 | amount: 1 7 | offset: 8 | ==: Vector 9 | x: 0.001 10 | y: 0.001 11 | z: 0.001 12 | sample-rate: 16 13 | point-distance: 0.2 14 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | minecraft_version=1.21 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /pathfinder-api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | id("io.freefair.lombok") version "6.6.2" 4 | } 5 | 6 | group = "de.cubbossa" 7 | 8 | repositories { 9 | mavenCentral() 10 | maven("https://nexus.leonardbausenwein.de/repository/maven-public/") 11 | } 12 | 13 | dependencies { 14 | api(project(":pathfinder-graph")) 15 | api("de.cubbossa:disposables-api:1.3") 16 | implementation("org.jetbrains:annotations:24.0.1") 17 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2") 18 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2") 19 | 20 | // Adventure 21 | api("net.kyori:adventure-api:4.13.0") 22 | api("net.kyori:adventure-platform-bukkit:4.3.0") 23 | api("net.kyori:adventure-text-minimessage:4.13.0") 24 | api("net.kyori:adventure-text-serializer-plain:4.13.0") 25 | } 26 | 27 | tasks.getByName("test") { 28 | useJUnitPlatform() 29 | } -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/Changes.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import java.util.Collection; 4 | import java.util.concurrent.ConcurrentHashMap; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public final class Changes { 9 | private final Collection addList; 10 | private final Collection removeList; 11 | 12 | public Changes() { 13 | addList = ConcurrentHashMap.newKeySet(16); 14 | removeList = ConcurrentHashMap.newKeySet(16); 15 | } 16 | 17 | public void flush() { 18 | addList.clear(); 19 | removeList.clear(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/ExtensionsRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import java.util.Collection; 5 | 6 | /** 7 | * Handles all extensions of one PathFinder application. 8 | * Extensions are different applications that rely on PathFinders life cycle hooks. 9 | */ 10 | public interface ExtensionsRegistry extends Disposable { 11 | 12 | Collection getExtensions(); 13 | 14 | /** 15 | * Loads all registered extensions with the current PathFinder application as parameter. 16 | * 17 | * @see PathFinderExtension#onLoad(PathFinder) 18 | */ 19 | void loadExtensions(); 20 | 21 | /** 22 | * Enables all registered extensions with the current PathFinder application as parameter. 23 | * 24 | * @see PathFinderExtension#onEnable(PathFinder) 25 | */ 26 | void enableExtensions(); 27 | 28 | /** 29 | * Disables all registered extensions with the current PathFinder application as parameter. 30 | * 31 | * @see PathFinderExtension#onDisable(PathFinder) 32 | */ 33 | void disableExtensions(); 34 | } 35 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/PathFinderProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import org.jetbrains.annotations.ApiStatus; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public final class PathFinderProvider { 7 | 8 | private static PathFinder instance = null; 9 | 10 | public static @NotNull PathFinder get() { 11 | return instance; 12 | } 13 | 14 | @ApiStatus.Internal 15 | public static void setPathFinder(PathFinder pathFinder) { 16 | instance = pathFinder; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/dump/DumpWriter.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.dump; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import java.io.File; 5 | import java.io.IOException; 6 | import java.util.function.Supplier; 7 | 8 | /** 9 | * The DumpWriter interface creates a full report of the plugin, configuration, environment and data, to 10 | * achieve smooth data conversions between different major versions or to make error detection simpler. 11 | */ 12 | public interface DumpWriter extends Disposable { 13 | 14 | void addProperty(String name, Object data); 15 | 16 | void addProperty(String name, Supplier data); 17 | 18 | boolean removeProperty(String name); 19 | 20 | String toString(); 21 | 22 | void save(File file) throws IOException; 23 | } 24 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/dump/DumpWriterProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.dump; 2 | 3 | import org.jetbrains.annotations.ApiStatus; 4 | import org.jetbrains.annotations.NotNull; 5 | 6 | public class DumpWriterProvider { 7 | 8 | private static DumpWriter instance; 9 | 10 | @ApiStatus.Internal 11 | public static void set(DumpWriter instance) { 12 | DumpWriterProvider.instance = instance; 13 | } 14 | 15 | public static @NotNull DumpWriter get() { 16 | return instance; 17 | } 18 | } -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/editor/GraphEditor.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.editor; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | 7 | /** 8 | * An editor that handles the rendering and the editing of a graph. 9 | * The graph is being reduced to a NodeGroup, which might also be the global NodeGroup. 10 | * 11 | * @param The Player object type. 12 | */ 13 | public interface GraphEditor extends Disposable { 14 | 15 | /** 16 | * @return The namespaced key of the group that is being edited. 17 | */ 18 | NamespacedKey getGroupKey(); 19 | 20 | /** 21 | * @return true if there is any active editor at the moment. Otherwise false. 22 | */ 23 | boolean isEdited(); 24 | 25 | /** 26 | * Toggles the edit mode for a player. 27 | * 28 | * @param player The player object to toggle the editor for. 29 | * @return the new state of editing. 30 | */ 31 | boolean toggleEditMode(PathPlayer player); 32 | 33 | /** 34 | * Cancels the editing session for all players. 35 | */ 36 | void cancelEditModes(); 37 | 38 | /** 39 | * Sets a player into edit mode for the graph section. 40 | * 41 | * @param player the player to set the edit mode for 42 | * @param activate activate or deactivate edit mode 43 | */ 44 | void setEditMode(PathPlayer player, boolean activate); 45 | 46 | /** 47 | * @param player The player to check the editing state for 48 | * @return true if the player is currently editing via this editor. 49 | */ 50 | boolean isEditing(PathPlayer player); 51 | } 52 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/editor/GraphEditorFactory.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.editor; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import org.pf4j.ExtensionPoint; 5 | 6 | /** 7 | * ExtensionPoint that allows to introduce a custom editor for the graph. 8 | */ 9 | public interface GraphEditorFactory extends ExtensionPoint { 10 | 11 | /** 12 | * Create a new GraphEditor instance. 13 | * @param scope The NodeGroup to edit with the provided editor. 14 | * @return The GraphEditor instance. 15 | */ 16 | GraphEditor createGraphEditor(NodeGroup scope); 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/EventCancelledException.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public class EventCancelledException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/Listener.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import java.util.UUID; 5 | import java.util.function.Consumer; 6 | 7 | public record Listener(UUID id, Class eventType, 8 | Consumer handler) implements Disposable { 9 | } 10 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeCreateEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface NodeCreateEvent extends NodeEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | 5 | public interface NodeDeleteEvent extends PathFinderEvent { 6 | Node getNode(); 7 | } 8 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | 5 | public interface NodeEvent extends PathFinderEvent { 6 | Node getNode(); 7 | } 8 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeGroupCreateEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface NodeGroupCreateEvent extends NodeGroupEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeGroupDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface NodeGroupDeleteEvent extends NodeGroupEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeGroupEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | 5 | public interface NodeGroupEvent extends PathFinderEvent { 6 | NodeGroup getGroup(); 7 | } 8 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeGroupSaveEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface NodeGroupSaveEvent extends NodeGroupEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/NodeSaveEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface NodeSaveEvent extends NodeEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathCancelledEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface PathCancelledEvent extends PathEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 4 | 5 | public interface PathEvent extends PathFinderEvent { 6 | 7 | VisualizerPath getPath(); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathFinderEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface PathFinderEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathFinderReloadEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface PathFinderReloadEvent extends PathFinderEvent { 4 | 5 | boolean reloadsConfig(); 6 | 7 | boolean reloadsLocale(); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathStartEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.misc.PathPlayer; 4 | 5 | public interface PathStartEvent extends PathEvent { 6 | 7 | PathPlayer getPlayer(); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathStoppedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.misc.PathPlayer; 4 | 5 | public interface PathStoppedEvent extends PathEvent { 6 | 7 | PathPlayer getPlayer(); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PathTargetReachedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | public interface PathTargetReachedEvent extends PathEvent { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PlayerDiscoverLocationEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.group.DiscoverableModifier; 4 | import de.cubbossa.pathfinder.group.NodeGroup; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import java.time.LocalDateTime; 7 | 8 | public interface PlayerDiscoverLocationEvent extends PathFinderEvent { 9 | 10 | PathPlayer getPlayer(); 11 | 12 | NodeGroup getGroup(); 13 | 14 | DiscoverableModifier getModifier(); 15 | 16 | LocalDateTime getTimeStamp(); 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PlayerDiscoverProgressEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | 6 | public interface PlayerDiscoverProgressEvent extends PathFinderEvent { 7 | 8 | PathPlayer getPlayer(); 9 | 10 | NodeGroup getFoundGroup(); 11 | 12 | NodeGroup getProgressObserverGroup(); 13 | } 14 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/event/PlayerForgetLocationEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.event; 2 | 3 | import de.cubbossa.pathfinder.group.DiscoverableModifier; 4 | import de.cubbossa.pathfinder.group.NodeGroup; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | 7 | public interface PlayerForgetLocationEvent extends PathFinderEvent { 8 | 9 | PathPlayer getPlayer(); 10 | 11 | NodeGroup getGroup(); 12 | 13 | DiscoverableModifier getModifier(); 14 | } 15 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/CurveLengthModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | 5 | public interface CurveLengthModifier extends Modifier { 6 | 7 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:curve-length"); 8 | 9 | @Override 10 | default NamespacedKey getKey() { 11 | return KEY; 12 | } 13 | 14 | double curveLength(); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/DiscoverProgressModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.Named; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.util.UUID; 6 | import java.util.concurrent.CompletableFuture; 7 | 8 | public interface DiscoverProgressModifier extends Modifier, Named { 9 | 10 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:discover-progress"); 11 | 12 | @Override 13 | default NamespacedKey getKey() { 14 | return KEY; 15 | } 16 | 17 | NamespacedKey getOwningGroup(); 18 | 19 | CompletableFuture calculateProgress(UUID playerId); 20 | } 21 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/DiscoverableModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.Nameable; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | 6 | public interface DiscoverableModifier extends Modifier, Nameable { 7 | 8 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:discoverable"); 9 | 10 | @Override 11 | default NamespacedKey getKey() { 12 | return KEY; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/FindDistanceModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | 5 | public interface FindDistanceModifier extends Modifier { 6 | 7 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:find-distance"); 8 | 9 | @Override 10 | default NamespacedKey getKey() { 11 | return KEY; 12 | } 13 | 14 | double distance(); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/Modified.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import java.util.Collection; 5 | import java.util.Optional; 6 | 7 | public interface Modified { 8 | 9 | Collection getModifiers(); 10 | 11 | boolean hasModifier(Class modifierClass); 12 | 13 | boolean hasModifier(NamespacedKey modifierType); 14 | 15 | default void addModifier(M modifier) { 16 | addModifier(modifier.getKey(), modifier); 17 | } 18 | 19 | void addModifier(NamespacedKey key, Modifier modifier); 20 | 21 | Optional getModifier(NamespacedKey key); 22 | 23 | void removeModifier(Class modifierClass); 24 | 25 | void removeModifier(M modifier); 26 | 27 | void removeModifier(NamespacedKey key); 28 | 29 | void clearModifiers(); 30 | } 31 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/Modifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.Keyed; 4 | 5 | public interface Modifier extends Keyed { 6 | } 7 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/ModifierRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.util.Collection; 6 | import java.util.Optional; 7 | 8 | public interface ModifierRegistry extends Disposable { 9 | 10 | void registerModifierType(ModifierType modifierType); 11 | 12 | Collection> getTypes(); 13 | 14 | Optional> getType(NamespacedKey key); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/ModifierType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.Keyed; 4 | import java.io.IOException; 5 | import java.util.Map; 6 | import org.pf4j.ExtensionPoint; 7 | 8 | public interface ModifierType extends Keyed, ExtensionPoint { 9 | 10 | default String getSubCommandLiteral() { 11 | return getKey().getKey(); 12 | } 13 | 14 | Map serialize(M modifier); 15 | 16 | M deserialize(Map values) throws IOException; 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/NavigableModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.query.SearchTermHolder; 5 | import java.util.Collection; 6 | 7 | public interface NavigableModifier extends Modifier, SearchTermHolder { 8 | 9 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:navigable"); 10 | 11 | @Override 12 | default NamespacedKey getKey() { 13 | return KEY; 14 | } 15 | 16 | Collection getSearchTermStrings(); 17 | 18 | void removeSearchTermStrings(Collection terms); 19 | 20 | void addSearchTermStrings(Collection terms); 21 | 22 | void clearSearchTermStrings(); 23 | } 24 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/PermissionModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | 5 | public interface PermissionModifier extends Modifier { 6 | 7 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:permission"); 8 | 9 | @Override 10 | default NamespacedKey getKey() { 11 | return KEY; 12 | } 13 | 14 | String permission(); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/group/VisualizerModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.group; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 5 | import java.util.Optional; 6 | import java.util.concurrent.CompletableFuture; 7 | 8 | public interface VisualizerModifier extends Modifier { 9 | 10 | NamespacedKey KEY = NamespacedKey.fromString("pathfinder:visualizer"); 11 | 12 | @Override 13 | default NamespacedKey getKey() { 14 | return KEY; 15 | } 16 | 17 | NamespacedKey getVisualizerKey(); 18 | 19 | CompletableFuture>> getVisualizer(); 20 | } 21 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Keyed.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | public interface Keyed { 4 | 5 | NamespacedKey getKey(); 6 | } 7 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/KeyedRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import java.util.Map; 4 | 5 | public interface KeyedRegistry extends Map, Iterable { 6 | 7 | T put(T value); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Nameable.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | /** 4 | * A {@link Named} that can also be renamed. 5 | */ 6 | public interface Nameable extends Named { 7 | 8 | /** 9 | * Sets the display name. The call if this method must also refresh the display name component if stored locally. 10 | * 11 | * @param name The display name formatted in the MiniMessage style. 12 | * @see "https://docs.adventure.kyori.net/minimessage/format.html" 13 | */ 14 | void setNameFormat(String name); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Named.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import net.kyori.adventure.text.Component; 4 | 5 | /** 6 | * An object that can be represented as Component. 7 | */ 8 | public interface Named { 9 | 10 | /** 11 | * @return The display name formatted in the MiniMessage style. 12 | * @see "https://docs.adventure.kyori.net/minimessage/format.html" 13 | */ 14 | String getNameFormat(); 15 | 16 | /** 17 | * @return The display name as kyori Component. Must be the parsed version of the name format string and 18 | * may be cached. 19 | */ 20 | Component getDisplayName(); 21 | } 22 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/NamespacedKey.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import java.util.Objects; 4 | import java.util.function.Predicate; 5 | import java.util.regex.Pattern; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | public final class NamespacedKey { 10 | 11 | private static final Pattern PATTERN = Pattern.compile("[a-z0-9_-]+:[a-z0-9_-]+"); 12 | private static final Predicate PATTERN_TEST = PATTERN.asMatchPredicate(); 13 | private static final char SEPARATOR = ':'; 14 | private final String namespace; 15 | private final String key; 16 | 17 | public NamespacedKey(String namespace, String key) { 18 | this.namespace = namespace; 19 | this.key = key; 20 | } 21 | 22 | public static NamespacedKey fromString(String value) { 23 | if (!PATTERN_TEST.test(value)) { 24 | throw new IllegalArgumentException("NamespacedKey must match pattern '" + PATTERN.pattern() + "'. Input: '" + value + "'."); 25 | } 26 | String[] splits = value.split(":"); 27 | return new NamespacedKey(splits[0], splits[1]); 28 | } 29 | 30 | @Override 31 | public String toString() { 32 | return namespace + SEPARATOR + key; 33 | } 34 | 35 | @Override 36 | public boolean equals(Object o) { 37 | if (this == o) { 38 | return true; 39 | } 40 | if (o == null || getClass() != o.getClass()) { 41 | return false; 42 | } 43 | NamespacedKey that = (NamespacedKey) o; 44 | return Objects.equals(namespace, that.namespace) && Objects.equals(key, that.key); 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | return toString().hashCode(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Pagination.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public final class Pagination extends Range { 7 | 8 | private final int page; 9 | private final int size; 10 | 11 | public static Pagination page(int page, int size) { 12 | return new Pagination(page, size); 13 | } 14 | 15 | Pagination(int page, int size) { 16 | super(page * size, size); 17 | this.page = page; 18 | this.size = size; 19 | } 20 | 21 | public int getPageCount(int elements) { 22 | return (int) Math.ceil(elements / (float) size); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/PathPlayer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import java.util.UUID; 5 | import net.kyori.adventure.text.Component; 6 | import net.kyori.adventure.text.ComponentLike; 7 | 8 | public interface PathPlayer

extends Disposable { 9 | 10 | static

PathPlayer

wrap(P player) { 11 | return (PathPlayer

) PathPlayerProvider.

get().wrap(player); 12 | } 13 | 14 | static

PathPlayer

wrap(UUID uuid) { 15 | return (PathPlayer

) PathPlayerProvider.

get().wrap(uuid); 16 | } 17 | 18 | static

PathPlayer

consoleSender() { 19 | return (PathPlayer

) PathPlayerProvider.

get().consoleSender(); 20 | } 21 | 22 | UUID getUniqueId(); 23 | 24 | Class

getPlayerClass(); 25 | 26 | String getName(); 27 | 28 | Component getDisplayName(); 29 | 30 | Location getLocation(); 31 | 32 | boolean hasPermission(String permission); 33 | 34 | P unwrap(); 35 | 36 | void sendMessage(ComponentLike message); 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/PathPlayerProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import java.util.UUID; 4 | 5 | public abstract class PathPlayerProvider

{ 6 | 7 | private static PathPlayerProvider instance; 8 | 9 | public static

PathPlayerProvider

get() { 10 | return (PathPlayerProvider

) instance; 11 | } 12 | 13 | public static void set(PathPlayerProvider provider) { 14 | instance = provider; 15 | } 16 | 17 | public abstract PathPlayer wrap(P player); 18 | 19 | public abstract PathPlayer wrap(UUID uuid); 20 | 21 | public abstract PathPlayer consoleSender(); 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/PermissionHolder.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | /** 6 | * Represents an object that stores a permission node. 7 | * The permission node is used to provide and prevent access to features of the plugin. 8 | */ 9 | public interface PermissionHolder { 10 | 11 | /** 12 | * @return null, if no permission is set. Null will by default be interpreted as "access". 13 | */ 14 | @Nullable 15 | String getPermission(); 16 | 17 | /** 18 | * @param permission The permission node to restrict this object or null, if unrestricted access. 19 | */ 20 | void setPermission(@Nullable String permission); 21 | } 22 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Range.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import lombok.AccessLevel; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | 7 | @Getter 8 | @RequiredArgsConstructor(access = AccessLevel.PACKAGE) 9 | public class Range { 10 | 11 | private final int offset; 12 | private final int limit; 13 | 14 | public static Range range(int offset, int limit) { 15 | return new Range(offset, limit); 16 | } 17 | 18 | public int getStart() { 19 | return offset; 20 | } 21 | 22 | public int getEndExclusive() { 23 | return offset + limit; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return "Pagination{" + 29 | "offset=" + offset + 30 | ", limit=" + limit + 31 | '}'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/Task.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | public interface Task { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/misc/World.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.misc; 2 | 3 | import java.util.UUID; 4 | 5 | public interface World { 6 | 7 | UUID getUniqueId(); 8 | 9 | String getName(); 10 | } 11 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/Navigation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.Location; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 7 | import java.util.List; 8 | 9 | public interface Navigation extends Disposable { 10 | 11 | PathPlayer viewer(); 12 | 13 | VisualizerPath renderer(); 14 | 15 | NavigationLocation startLocation(); 16 | 17 | NavigationLocation endLocation(); 18 | 19 | List pathControlPoints(); 20 | 21 | void complete(); 22 | 23 | void cancel(); 24 | 25 | Navigation persist(); 26 | 27 | Navigation cancelWhenTargetInRange(); 28 | 29 | Navigation cancelWhenTargetInRange(double range); 30 | 31 | void onEnd(Runnable runnable); 32 | 33 | void onComplete(Runnable runnable); 34 | 35 | void onCancel(Runnable runnable); 36 | } 37 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/NavigationConstraint.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import java.util.Collection; 5 | import java.util.UUID; 6 | 7 | /** 8 | * Navigation filters allow to filter the required targets of the navigation. 9 | * This might be used to filter nodes that have certain {@link de.cubbossa.pathfinder.group.Modifier}s applied. 10 | * If the result is empty, navigation will be cancelled. 11 | */ 12 | public interface NavigationConstraint { 13 | 14 | /** 15 | * Filters the requested target locations, for some might not be supposed to navigate to in certain contexts. 16 | * @param playerId The UUID of the player that requested the navigation. 17 | * @param scope The target nodes the player requests to navigate to. 18 | * @return The filtered scope that has been provided. 19 | */ 20 | Collection filterTargetNodes(UUID playerId, Collection scope); 21 | } 22 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/NavigationLocation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | 5 | public interface NavigationLocation { 6 | 7 | static NavigationLocation fixedGraphNode(Node node) { 8 | return new NavigationLocationImpl(node, true, false); 9 | } 10 | 11 | static NavigationLocation fixedExternalNode(Node node) { 12 | return new NavigationLocationImpl(node, true, true); 13 | } 14 | 15 | static NavigationLocation movingGraphNode(Node node) { 16 | return new NavigationLocationImpl(node, false, false); 17 | } 18 | 19 | static NavigationLocation movingExternalNode(Node node) { 20 | return new NavigationLocationImpl(node, false, true); 21 | } 22 | 23 | Node getNode(); 24 | 25 | void setNode(Node node); 26 | 27 | boolean isFixedPosition(); 28 | 29 | boolean isExternal(); 30 | } 31 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/NavigationLocationImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import com.google.common.base.Preconditions; 4 | import de.cubbossa.pathfinder.graph.GraphEntrySolver; 5 | import de.cubbossa.pathfinder.node.Node; 6 | import lombok.Getter; 7 | 8 | public class NavigationLocationImpl implements NavigationLocation { 9 | 10 | @Getter 11 | private Node node; 12 | private final boolean fixed; 13 | private final boolean external; 14 | 15 | NavigationLocationImpl(Node node, boolean fixed, boolean external) { 16 | Preconditions.checkNotNull(node); 17 | 18 | this.node = node; 19 | this.fixed = fixed; 20 | this.external = external; 21 | } 22 | 23 | @Override 24 | public void setNode(Node node) { 25 | this.node = node; 26 | } 27 | 28 | @Override 29 | public boolean isFixedPosition() { 30 | return fixed; 31 | } 32 | 33 | @Override 34 | public boolean isExternal() { 35 | return external; 36 | } 37 | 38 | @Override 39 | public String toString() { 40 | return "NavigationLocation{node=" + node.toString() + "}"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/NavigationModuleProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | public class NavigationModuleProvider { 4 | 5 | private static NavigationModule module; 6 | 7 | public static NavigationModule get() { 8 | if (module == null) { 9 | throw new IllegalStateException("Accessing NavigationModule before initialization."); 10 | } 11 | return (NavigationModule) module; 12 | } 13 | 14 | public static void set(NavigationModule instance) { 15 | module = instance; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/Navigator.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.graph.NoPathFoundException; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import de.cubbossa.pathfinder.node.Node; 7 | import de.cubbossa.pathfinder.visualizer.PathView; 8 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 9 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 10 | import java.util.List; 11 | 12 | public interface Navigator extends Disposable { 13 | 14 | List createPath(Route route) throws NoPathFoundException; 15 | 16 | VisualizerPath createRenderer( 17 | PathPlayer viewer, Route route 18 | ) throws NoPathFoundException; 19 | 20 | > VisualizerPath createRenderer( 21 | PathPlayer viewer, Route route, PathVisualizer renderer 22 | ) throws NoPathFoundException; 23 | } 24 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/navigation/UpdatingPath.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation; 2 | 3 | import de.cubbossa.pathfinder.graph.NoPathFoundException; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import java.util.List; 6 | 7 | public interface UpdatingPath { 8 | 9 | List getNodes() throws NoPathFoundException; 10 | } 11 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/node/Edge.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * An edge that connects one node to another. 8 | * Edges are always directed, to create an undirected edge, create two edges instead. 9 | */ 10 | public interface Edge { 11 | 12 | /** 13 | * @return The uuid of the start node of this edge 14 | */ 15 | UUID getStart(); 16 | 17 | /** 18 | * @return The uuid of the end node of this edge 19 | */ 20 | UUID getEnd(); 21 | 22 | /** 23 | * @return The relative cost of this edge additionally to the actual edge length. The edge length is NOT 24 | * part of weight. 25 | */ 26 | float getWeight(); 27 | 28 | /** 29 | * @return The start node of this edge as CompletableFuture. 30 | */ 31 | CompletableFuture resolveStart(); 32 | 33 | /** 34 | * @return The end node of this edge as CompletableFuture. 35 | */ 36 | CompletableFuture resolveEnd(); 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/node/GroupedNode.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import java.util.Collection; 5 | 6 | public interface GroupedNode extends Node { 7 | 8 | Node node(); 9 | 10 | Collection groups(); 11 | 12 | GroupedNode merge(GroupedNode other); 13 | } 14 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/node/NodeSelectionProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | public abstract class NodeSelectionProvider { 4 | 5 | protected static NodeSelectionProvider provider; 6 | 7 | protected abstract NodeSelection of(String selection); 8 | 9 | protected abstract NodeSelection of(String selection, Iterable scope); 10 | 11 | protected abstract NodeSelection of(Iterable scope); 12 | 13 | protected abstract NodeSelection ofSender(String selection, Object sender); 14 | 15 | protected abstract NodeSelection ofSender(String selection, Iterable scope, Object sender); 16 | } 17 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/node/NodeTypeRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.util.Collection; 6 | 7 | public interface NodeTypeRegistry extends Disposable { 8 | NodeType getType(NamespacedKey key); 9 | 10 | Collection getTypeKeys(); 11 | 12 | Collection> getTypes(); 13 | 14 | void register(NodeType type); 15 | 16 | void unregister(NodeType type); 17 | 18 | void unregister(NamespacedKey key); 19 | } 20 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/CacheLayer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.storage.cache.DiscoverInfoCache; 4 | import de.cubbossa.pathfinder.storage.cache.GroupCache; 5 | import de.cubbossa.pathfinder.storage.cache.NodeCache; 6 | import de.cubbossa.pathfinder.storage.cache.NodeTypeCache; 7 | import de.cubbossa.pathfinder.storage.cache.StorageCache; 8 | import de.cubbossa.pathfinder.storage.cache.VisualizerCache; 9 | import de.cubbossa.pathfinder.storage.cache.VisualizerTypeCache; 10 | 11 | public interface CacheLayer extends Iterable> { 12 | 13 | NodeTypeCache getNodeTypeCache(); 14 | 15 | NodeCache getNodeCache(); 16 | 17 | GroupCache getGroupCache(); 18 | 19 | VisualizerTypeCache getVisualizerTypeCache(); 20 | 21 | VisualizerCache getVisualizerCache(); 22 | 23 | DiscoverInfoCache getDiscoverInfoCache(); 24 | } 25 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/DatabaseType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | public enum DatabaseType { 4 | 5 | IN_MEMORY, 6 | REMOTE_SQL, 7 | SQLITE, 8 | YML 9 | } 10 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/DiscoverInfo.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import java.time.LocalDateTime; 5 | import java.util.UUID; 6 | 7 | public record DiscoverInfo( 8 | UUID playerId, 9 | NamespacedKey discoverable, 10 | LocalDateTime foundDate 11 | ) { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/NodeStorageImplementation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import java.util.Collection; 5 | import java.util.Optional; 6 | import java.util.UUID; 7 | 8 | public interface NodeStorageImplementation { 9 | 10 | Optional loadNode(UUID uuid); 11 | 12 | Collection loadNodes(Collection ids); 13 | 14 | Collection loadAllNodes(); 15 | 16 | void saveNode(N node); 17 | 18 | void deleteNodes(Collection node); 19 | } 20 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/VisualizerStorageImplementation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 5 | import java.util.Map; 6 | import java.util.Optional; 7 | 8 | public interface VisualizerStorageImplementation> { 9 | 10 | Map loadVisualizers(); 11 | 12 | Optional loadVisualizer(NamespacedKey key); 13 | 14 | void saveVisualizer(VisualizerT visualizer); 15 | 16 | void deleteVisualizer(VisualizerT visualizer); 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/WorldLoader.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.misc.World; 4 | import java.util.UUID; 5 | 6 | @FunctionalInterface 7 | public interface WorldLoader { 8 | 9 | World loadWorld(UUID uuid); 10 | } 11 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/DiscoverInfoCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.storage.DiscoverInfo; 5 | import java.util.Collection; 6 | import java.util.Optional; 7 | import java.util.UUID; 8 | 9 | public interface DiscoverInfoCache extends StorageCache { 10 | 11 | Optional getDiscovery(UUID player, NamespacedKey key); 12 | 13 | Optional> getDiscovery(UUID player); 14 | 15 | void invalidate(UUID player); 16 | } 17 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/GroupCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import de.cubbossa.pathfinder.misc.Range; 6 | import java.util.Collection; 7 | import java.util.Optional; 8 | import java.util.UUID; 9 | 10 | public interface GroupCache extends StorageCache { 11 | 12 | Optional getGroup(NamespacedKey key); 13 | 14 | Optional> getGroups(NamespacedKey modifier); 15 | 16 | CacheCollection getGroups(Collection keys); 17 | 18 | Optional> getGroups(); 19 | 20 | Optional> getGroups(UUID node); 21 | 22 | Optional> getGroups(Range range); 23 | 24 | void write(UUID node, Collection groups); 25 | 26 | void write(NamespacedKey modifier, Collection groups); 27 | 28 | void writeAll(Collection groups); 29 | 30 | void invalidate(UUID node); 31 | 32 | void invalidate(NamespacedKey modifier); 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/NodeCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import java.util.Collection; 6 | import java.util.Optional; 7 | import java.util.UUID; 8 | 9 | public interface NodeCache extends StorageCache { 10 | 11 | Optional getNode(UUID uuid); 12 | 13 | Optional> getAllNodes(); 14 | 15 | CacheCollection getNodes(Collection ids); 16 | 17 | void writeAll(Collection nodes); 18 | 19 | void write(NodeGroup group); 20 | 21 | void invalidate(UUID uuid); 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/NodeTypeCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import de.cubbossa.pathfinder.node.NodeType; 5 | import java.util.Collection; 6 | import java.util.Optional; 7 | import java.util.UUID; 8 | 9 | public interface NodeTypeCache extends StorageCache { 10 | 11 | Optional> getType(UUID uuid); 12 | 13 | CacheMap> getTypes(Collection uuids); 14 | 15 | void write(UUID uuid, NodeType type); 16 | } 17 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/StorageCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import com.google.common.base.Preconditions; 4 | import java.util.Collection; 5 | import java.util.HashMap; 6 | import java.util.HashSet; 7 | import java.util.Map; 8 | 9 | public interface StorageCache { 10 | 11 | void write(E e); 12 | 13 | void invalidate(E e); 14 | 15 | void invalidateAll(); 16 | 17 | record CacheCollection(Collection present, Collection absent) { 18 | 19 | public static CacheCollection empty(Collection absent) { 20 | Preconditions.checkNotNull(absent); 21 | return new CacheCollection<>(new HashSet<>(), absent); 22 | } 23 | } 24 | 25 | record CacheMap(Map present, Collection absent) { 26 | 27 | public static CacheMap empty(Collection absent) { 28 | Preconditions.checkNotNull(absent); 29 | return new CacheMap<>(new HashMap<>(), absent); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/VisualizerCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 5 | import de.cubbossa.pathfinder.visualizer.VisualizerType; 6 | import java.util.Collection; 7 | import java.util.Optional; 8 | 9 | public interface VisualizerCache extends StorageCache> { 10 | 11 | > Optional getVisualizer(NamespacedKey key); 12 | 13 | Optional>> getVisualizers(); 14 | 15 | > Optional> getVisualizers(VisualizerType type); 16 | 17 | > void writeAll(VisualizerType type, Collection v); 18 | 19 | void writeAll(Collection> visualizers); 20 | } 21 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/storage/cache/VisualizerTypeCache.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 5 | import de.cubbossa.pathfinder.visualizer.VisualizerType; 6 | import java.util.Collection; 7 | import java.util.Map; 8 | import java.util.Optional; 9 | 10 | public interface VisualizerTypeCache extends StorageCache>> { 11 | 12 | CacheMap> getTypes(Collection key); 13 | 14 | > Optional> getType(NamespacedKey key); 15 | 16 | > void write(NamespacedKey key, VisualizerType type); 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/PathView.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.graph.NoPathFoundException; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import de.cubbossa.pathfinder.node.Node; 7 | import java.util.Collection; 8 | import java.util.List; 9 | 10 | public interface PathView extends Disposable { 11 | 12 | List getPath(); 13 | 14 | PathPlayer getTargetViewer(); 15 | 16 | void setTargetViewer(PathPlayer player); 17 | 18 | void addViewer(PathPlayer player); 19 | 20 | void removeViewer(PathPlayer player); 21 | 22 | void removeAllViewers(); 23 | 24 | Collection> getViewers(); 25 | 26 | void update() throws NoPathFoundException; 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/PathVisualizer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.Keyed; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import de.cubbossa.pathfinder.misc.PermissionHolder; 7 | import de.cubbossa.pathfinder.navigation.UpdatingPath; 8 | 9 | public interface PathVisualizer, PlayerT> extends Keyed, PermissionHolder, Disposable { 10 | 11 | Class getTargetType(); 12 | 13 | ViewT createView(UpdatingPath nodes, PathPlayer player); 14 | } 15 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/VisualizerPath.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.pathfinder.misc.PathPlayer; 4 | 5 | /** 6 | * A VisualizerPath resembles one visualization across a path of nodes. 7 | * Each node will be resolved to all its applied visualizers and all visualizers render as smaller sub paths. 8 | *

9 | * If, for example, a path consists of three nodes a, b and c and a and b have visualizer X applied, 10 | * while b and c have visualizer Y applied, there must be a sub path rendering for visualizer X(a, b) 11 | * and Y(b, c). 12 | *

13 | *

14 |  * X    X
15 |  *      Y    Y
16 |  * a -- b -- c
17 |  * 
18 | * 19 | * @param The type of the player object. 20 | */ 21 | public interface VisualizerPath extends PathView { 22 | 23 | /** 24 | * Check if this path is rendered for any player. 25 | * 26 | * @return True as long as {@link #isActive(PathPlayer)} is true for any player. 27 | */ 28 | boolean isActive(); 29 | 30 | /** 31 | * Check if this path is being rendered for the given player. 32 | * 33 | * @param player The player to check for. 34 | * @return True, if the path is currently being rendered for the given player. 35 | */ 36 | boolean isActive(PathPlayer player); 37 | 38 | void startUpdater(int interval); 39 | 40 | void stopUpdater(); 41 | } 42 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/VisualizerTypeRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import de.cubbossa.pathfinder.misc.KeyedRegistry; 5 | import de.cubbossa.pathfinder.misc.NamespacedKey; 6 | import java.util.Optional; 7 | 8 | public interface VisualizerTypeRegistry extends Disposable { 9 | 10 | > VisualizerType getDefaultType(); 11 | 12 | > void setDefaultType(VisualizerType type); 13 | 14 | > Optional> getType(NamespacedKey typeKey); 15 | 16 | > void registerVisualizerType(VisualizerType type); 17 | 18 | void unregisterVisualizerType(VisualizerType> type); 19 | 20 | KeyedRegistry>> getTypes(); 21 | } 22 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/query/SearchQueryAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.query; 2 | 3 | public interface SearchQueryAttribute { 4 | 5 | String identifier(); 6 | 7 | Comparator comparator(); 8 | 9 | Object value(); 10 | 11 | enum Comparator { 12 | EQUALS, NOT_EQUALS, GREATER, LESS, GREATER_THAN, LESS_THAN; 13 | 14 | public static Comparator fromString(String value) { 15 | return switch (value) { 16 | case "!=" -> NOT_EQUALS; 17 | case "<" -> LESS; 18 | case "<=" -> LESS_THAN; 19 | case ">=" -> GREATER_THAN; 20 | case ">" -> GREATER; 21 | default -> EQUALS; 22 | }; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/query/SearchTerm.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.query; 2 | 3 | import java.util.Collection; 4 | 5 | public interface SearchTerm { 6 | 7 | String getIdentifier(); 8 | 9 | boolean matches(Collection attributes); 10 | } 11 | -------------------------------------------------------------------------------- /pathfinder-api/src/main/java/de/cubbossa/pathfinder/visualizer/query/SearchTermHolder.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.query; 2 | 3 | import java.util.Collection; 4 | 5 | public interface SearchTermHolder { 6 | 7 | Collection getSearchTerms(); 8 | 9 | void addSearchTerms(Collection searchTerms); 10 | 11 | void removeSearchTerms(Collection searchTerms); 12 | 13 | void clearSearchTerms(); 14 | 15 | boolean matches(SearchTerm searchTerm); 16 | 17 | boolean matches(SearchTerm searchTerm, Collection attributes); 18 | 19 | boolean matches(String term); 20 | 21 | boolean matches(String term, Collection attributes); 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/PathFinderPlugin.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.dump.DumpWriter; 4 | import de.cubbossa.pathfinder.dump.DumpWriterProvider; 5 | import java.util.Arrays; 6 | import java.util.TreeMap; 7 | import java.util.TreeSet; 8 | import java.util.stream.Collectors; 9 | import lombok.Getter; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.World; 12 | import org.bukkit.plugin.Plugin; 13 | import org.bukkit.plugin.java.JavaPlugin; 14 | 15 | public class PathFinderPlugin extends JavaPlugin { 16 | 17 | @Getter 18 | private static PathFinderPlugin instance; 19 | 20 | private final BukkitPathFinder pathFinder; 21 | 22 | public PathFinderPlugin() { 23 | instance = this; 24 | pathFinder = new BukkitPathFinder(this); 25 | } 26 | 27 | @Override 28 | public void onLoad() { 29 | pathFinder.onLoad(); 30 | 31 | DumpWriter dumpWriter = DumpWriterProvider.get(); 32 | dumpWriter.addProperty("mc-version", () -> getServer().getVersion()); 33 | dumpWriter.addProperty("bukkit-version", () -> getServer().getBukkitVersion()); 34 | dumpWriter.addProperty("active-plugins", () -> Arrays.stream(getServer().getPluginManager().getPlugins()) 35 | .map(Plugin::getName).collect(Collectors.toCollection(TreeSet::new))); 36 | dumpWriter.addProperty("worlds", () -> Bukkit.getWorlds().stream() 37 | .collect(Collectors.toMap(World::getUID, World::getName, (s, s2) -> s, TreeMap::new))); 38 | } 39 | 40 | @Override 41 | public void onEnable() { 42 | pathFinder.onEnable(); 43 | } 44 | 45 | @Override 46 | public void onDisable() { 47 | pathFinder.onDisable(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/CancelPathCommand.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import de.cubbossa.pathfinder.PathPerms; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.navigation.NavigationModule; 6 | import dev.jorel.commandapi.CommandAPI; 7 | import dev.jorel.commandapi.CommandTree; 8 | import org.bukkit.entity.Player; 9 | 10 | public class CancelPathCommand extends CommandTree { 11 | 12 | public CancelPathCommand() { 13 | super("cancelpath"); 14 | NavigationModule module = NavigationModule.get(); 15 | 16 | withPermission(PathPerms.PERM_CMD_CANCELPATH); 17 | withRequirement(sender -> sender instanceof Player player 18 | && module.getActiveFindCommandPath(PathPlayer.wrap(player)) != null); 19 | 20 | executesPlayer((player, args) -> { 21 | var nav = module.getActiveFindCommandPath(PathPlayer.wrap(player)); 22 | if (nav != null) { 23 | nav.cancel(); 24 | } 25 | }); 26 | } 27 | 28 | public void refresh(PathPlayer player) { 29 | CommandAPI.updateRequirements(player.unwrap()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/PathFinderSubCommand.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import dev.jorel.commandapi.arguments.LiteralArgument; 5 | 6 | public class PathFinderSubCommand extends LiteralArgument { 7 | 8 | private PathFinder pathFinder; 9 | 10 | public PathFinderSubCommand(PathFinder pathFinder, String commandName) { 11 | super(commandName); 12 | this.pathFinder = pathFinder; 13 | } 14 | 15 | public PathFinderSubCommand withGeneratedHelp() { 16 | executes((sender, args) -> { 17 | //CommandUtils.sendHelp(sender, this); 18 | }); 19 | return this; 20 | } 21 | 22 | public PathFinderSubCommand withGeneratedHelp(int depth) { 23 | executes((sender, args) -> { 24 | //CommandUtils.sendHelp(sender, this, depth); 25 | }); 26 | return this; 27 | } 28 | 29 | public PathFinder getPathfinder() { 30 | return pathFinder; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/impl/DeleteGroupCmd.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command.impl; 2 | 3 | import de.cubbossa.pathfinder.AbstractPathFinder; 4 | import de.cubbossa.pathfinder.PathFinder; 5 | import de.cubbossa.pathfinder.PathPerms; 6 | import de.cubbossa.pathfinder.command.Arguments; 7 | import de.cubbossa.pathfinder.command.PathFinderSubCommand; 8 | import de.cubbossa.pathfinder.group.NodeGroup; 9 | import de.cubbossa.pathfinder.messages.Messages; 10 | import de.cubbossa.pathfinder.misc.PathPlayer; 11 | import de.cubbossa.pathfinder.util.BukkitUtils; 12 | import org.bukkit.command.CommandSender; 13 | 14 | public class DeleteGroupCmd extends PathFinderSubCommand { 15 | public DeleteGroupCmd(PathFinder pathFinder) { 16 | super(pathFinder, "deletegroup"); 17 | 18 | withGeneratedHelp(); 19 | withPermission(PathPerms.PERM_CMD_NG_DELETE); 20 | then(Arguments.nodeGroupArgument("group") 21 | .executes((sender, args) -> { 22 | deleteGroup(sender, args.getUnchecked(0)); 23 | })); 24 | } 25 | 26 | private void deleteGroup(CommandSender sender, NodeGroup group) { 27 | PathPlayer p = BukkitUtils.wrap(sender); 28 | if (group.getKey().equals(AbstractPathFinder.globalGroupKey())) { 29 | p.sendMessage(Messages.CMD_NG_DELETE_GLOBAL); 30 | return; 31 | } 32 | getPathfinder().getStorage().deleteGroup(group).thenRun(() -> { 33 | p.sendMessage(Messages.CMD_NG_DELETE.formatted( 34 | Messages.formatter().namespacedKey("key", group.getKey()) 35 | )); 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/impl/DeleteNodesCmd.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command.impl; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathPerms; 5 | import de.cubbossa.pathfinder.command.Arguments; 6 | import de.cubbossa.pathfinder.command.PathFinderSubCommand; 7 | import de.cubbossa.pathfinder.messages.Messages; 8 | import de.cubbossa.pathfinder.node.NodeSelectionImpl; 9 | import de.cubbossa.pathfinder.util.BukkitUtils; 10 | import org.bukkit.command.CommandSender; 11 | 12 | public class DeleteNodesCmd extends PathFinderSubCommand { 13 | public DeleteNodesCmd(PathFinder pathFinder) { 14 | super(pathFinder, "deletenodes"); 15 | 16 | withPermission(PathPerms.PERM_CMD_WP_DELETE); 17 | then(Arguments.nodeSelectionArgument("nodes") 18 | .executesPlayer((player, args) -> { 19 | deleteNode(player, args.getUnchecked(0)); 20 | }) 21 | ); 22 | } 23 | 24 | private void deleteNode(CommandSender sender, NodeSelectionImpl nodes) { 25 | getPathfinder().getStorage().deleteNodes(nodes.getIds()).thenRun(() -> { 26 | BukkitUtils.wrap(sender).sendMessage(Messages.CMD_N_DELETE.formatted( 27 | Messages.formatter().nodeSelection("selection", () -> nodes) 28 | )); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/impl/DeleteVisualizerCmd.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command.impl; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathPerms; 5 | import de.cubbossa.pathfinder.command.Arguments; 6 | import de.cubbossa.pathfinder.command.PathFinderSubCommand; 7 | import de.cubbossa.pathfinder.messages.Messages; 8 | import de.cubbossa.pathfinder.util.BukkitUtils; 9 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 10 | import java.util.logging.Level; 11 | import org.bukkit.command.CommandSender; 12 | 13 | public class DeleteVisualizerCmd extends PathFinderSubCommand { 14 | public DeleteVisualizerCmd(PathFinder pathFinder) { 15 | super(pathFinder, "deletevisualizer"); 16 | 17 | withGeneratedHelp(); 18 | withPermission(PathPerms.PERM_CMD_PV_DELETE); 19 | then(Arguments.pathVisualizerArgument("visualizer") 20 | .executes((commandSender, objects) -> { 21 | onDelete(commandSender, objects.getUnchecked(0)); 22 | }) 23 | ); 24 | } 25 | 26 | public void onDelete(CommandSender sender, PathVisualizer visualizer) { 27 | getPathfinder().getStorage().deleteVisualizer(visualizer).thenRun(() -> { 28 | BukkitUtils.wrap(sender).sendMessage(Messages.CMD_VIS_DELETE_SUCCESS.formatted( 29 | Messages.formatter().namespacedKey("key", visualizer.getKey()) 30 | )); 31 | }).exceptionally(throwable -> { 32 | BukkitUtils.wrap(sender).sendMessage(Messages.CMD_VIS_DELETE_ERROR); 33 | getPathfinder().getLogger().log(Level.WARNING, "Could not delete visualizer", throwable); 34 | return null; 35 | }); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/command/impl/ListNodesCmd.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command.impl; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathPerms; 5 | import de.cubbossa.pathfinder.command.Arguments; 6 | import de.cubbossa.pathfinder.command.PathFinderSubCommand; 7 | import de.cubbossa.pathfinder.misc.Pagination; 8 | import de.cubbossa.pathfinder.node.NodeSelection; 9 | import de.cubbossa.pathfinder.node.NodeSelectionImpl; 10 | import de.cubbossa.pathfinder.util.NodeUtils; 11 | 12 | public class ListNodesCmd extends PathFinderSubCommand { 13 | public ListNodesCmd(PathFinder pathFinder) { 14 | super(pathFinder, "listnodes"); 15 | 16 | withPermission(PathPerms.PERM_CMD_WP_LIST); 17 | executesPlayer((sender, args) -> { 18 | NodeSelection selection = NodeSelection.ofSender("@n", sender); 19 | NodeUtils.onList(sender, new NodeSelectionImpl(selection), Pagination.page(0, 10)); 20 | }); 21 | then(Arguments.nodeSelectionArgument("nodes") 22 | .executesPlayer((player, args) -> { 23 | NodeUtils.onList(player, args.getUnchecked(0), Pagination.page(0, 10)); 24 | }) 25 | .then(Arguments.pagination(10) 26 | .executesPlayer((player, args) -> { 27 | NodeUtils.onList(player, args.getUnchecked(0), args.getUnchecked(1)); 28 | }) 29 | )); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/NodeFindEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events; 2 | 3 | import de.cubbossa.pathfinder.node.implementation.Waypoint; 4 | import java.util.Date; 5 | import java.util.UUID; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.bukkit.event.Cancellable; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | 12 | public class NodeFindEvent extends Event implements Cancellable { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | 16 | @Getter 17 | private final UUID playerId; 18 | @Getter 19 | @Setter 20 | private Waypoint findable; 21 | @Getter 22 | @Setter 23 | private Date date; 24 | @Getter 25 | @Setter 26 | private boolean cancelled; 27 | 28 | public NodeFindEvent(UUID playerId, Waypoint findable, Date date) { 29 | this.playerId = playerId; 30 | this.findable = findable; 31 | this.date = date; 32 | } 33 | 34 | public static HandlerList getHandlerList() { 35 | return handlers; 36 | } 37 | 38 | public HandlerList getHandlers() { 39 | return handlers; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/NodeGroupFindEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events; 2 | 3 | import de.cubbossa.pathfinder.node.implementation.Waypoint; 4 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 5 | import java.util.Date; 6 | import java.util.UUID; 7 | import javax.annotation.Nullable; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | import org.bukkit.event.Cancellable; 11 | import org.bukkit.event.Event; 12 | import org.bukkit.event.HandlerList; 13 | 14 | public class NodeGroupFindEvent extends Event implements Cancellable { 15 | 16 | private static final HandlerList handlers = new HandlerList(); 17 | 18 | @Getter 19 | private final UUID playerId; 20 | @Getter 21 | private final Waypoint triggeringFindable; 22 | @Getter 23 | @Setter 24 | private @Nullable 25 | NodeGroupImpl group; 26 | @Getter 27 | @Setter 28 | private Date date; 29 | @Getter 30 | @Setter 31 | private boolean cancelled; 32 | 33 | public NodeGroupFindEvent(UUID playerId, NodeGroupImpl group, Waypoint triggeringFindable, 34 | Date date) { 35 | this.playerId = playerId; 36 | this.group = group; 37 | this.triggeringFindable = triggeringFindable; 38 | this.date = date; 39 | } 40 | 41 | public static HandlerList getHandlerList() { 42 | return handlers; 43 | } 44 | 45 | public HandlerList getHandlers() { 46 | return handlers; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/PathFinderReloadEventImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events; 2 | 3 | import de.cubbossa.pathfinder.event.PathFinderReloadEvent; 4 | import lombok.RequiredArgsConstructor; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | 8 | 9 | @RequiredArgsConstructor 10 | public class PathFinderReloadEventImpl extends Event implements PathFinderReloadEvent { 11 | 12 | private static final HandlerList handlers = new HandlerList(); 13 | private final boolean config; 14 | private final boolean locale; 15 | 16 | public static HandlerList getHandlerList() { 17 | return handlers; 18 | } 19 | 20 | public HandlerList getHandlers() { 21 | return handlers; 22 | } 23 | 24 | @Override 25 | public boolean reloadsConfig() { 26 | return config; 27 | } 28 | 29 | @Override 30 | public boolean reloadsLocale() { 31 | return locale; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/discovering/PlayerDiscoverEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.discovering; 2 | 3 | import de.cubbossa.pathfinder.event.PlayerDiscoverLocationEvent; 4 | import de.cubbossa.pathfinder.group.DiscoverableModifier; 5 | import de.cubbossa.pathfinder.group.NodeGroup; 6 | import de.cubbossa.pathfinder.misc.PathPlayer; 7 | import java.time.LocalDateTime; 8 | import lombok.Getter; 9 | import lombok.RequiredArgsConstructor; 10 | import lombok.Setter; 11 | import org.bukkit.entity.Player; 12 | import org.bukkit.event.Cancellable; 13 | import org.bukkit.event.Event; 14 | import org.bukkit.event.HandlerList; 15 | 16 | @Getter 17 | @Setter 18 | @RequiredArgsConstructor 19 | public class PlayerDiscoverEvent extends Event implements Cancellable, PlayerDiscoverLocationEvent { 20 | 21 | private static final HandlerList handlers = new HandlerList(); 22 | private final PathPlayer player; 23 | private final NodeGroup group; 24 | private final DiscoverableModifier modifier; 25 | private final LocalDateTime timeStamp; 26 | private boolean cancelled; 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlers; 30 | } 31 | 32 | public HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/discovering/PlayerDiscoverProgressEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.discovering; 2 | 3 | import de.cubbossa.pathfinder.group.NodeGroup; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import lombok.Getter; 6 | import lombok.RequiredArgsConstructor; 7 | import lombok.Setter; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | 12 | @Getter 13 | @Setter 14 | @RequiredArgsConstructor 15 | public class PlayerDiscoverProgressEvent extends Event implements de.cubbossa.pathfinder.event.PlayerDiscoverProgressEvent { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | private final PathPlayer player; 19 | private final NodeGroup foundGroup; 20 | private final NodeGroup progressObserverGroup; 21 | 22 | public static HandlerList getHandlerList() { 23 | return handlers; 24 | } 25 | 26 | public HandlerList getHandlers() { 27 | return handlers; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/discovering/PlayerForgetEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.discovering; 2 | 3 | import de.cubbossa.pathfinder.event.PlayerForgetLocationEvent; 4 | import de.cubbossa.pathfinder.group.DiscoverableModifier; 5 | import de.cubbossa.pathfinder.group.NodeGroup; 6 | import de.cubbossa.pathfinder.misc.PathPlayer; 7 | import lombok.Getter; 8 | import lombok.RequiredArgsConstructor; 9 | import lombok.Setter; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.Cancellable; 12 | import org.bukkit.event.Event; 13 | import org.bukkit.event.HandlerList; 14 | 15 | @Getter 16 | @Setter 17 | @RequiredArgsConstructor 18 | public class PlayerForgetEvent extends Event implements Cancellable, PlayerForgetLocationEvent { 19 | 20 | private static final HandlerList handlers = new HandlerList(); 21 | private final PathPlayer player; 22 | private final NodeGroup group; 23 | private final DiscoverableModifier modifier; 24 | private boolean cancelled; 25 | 26 | public static HandlerList getHandlerList() { 27 | return handlers; 28 | } 29 | 30 | public HandlerList getHandlers() { 31 | return handlers; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/EdgesCreateEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.Edge; 4 | import de.cubbossa.pathfinder.node.NodeSelection; 5 | import java.util.Collection; 6 | import java.util.HashSet; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | import org.bukkit.event.Cancellable; 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | public class EdgesCreateEvent { 14 | 15 | private EdgesCreateEvent() { 16 | } 17 | 18 | @Getter 19 | public static class Pre extends Event implements Cancellable { 20 | private static final HandlerList handlers = new HandlerList(); 21 | 22 | private final NodeSelection from; 23 | private final NodeSelection to; 24 | @Setter 25 | private boolean cancelled = false; 26 | 27 | public Pre(NodeSelection from, NodeSelection to) { 28 | this.from = from; 29 | this.to = to; 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlers; 34 | } 35 | 36 | public HandlerList getHandlers() { 37 | return handlers; 38 | } 39 | } 40 | 41 | @Getter 42 | public static class Post extends Event { 43 | private static final HandlerList handlers = new HandlerList(); 44 | 45 | private final Collection edges; 46 | 47 | public Post(Collection edges) { 48 | this.edges = new HashSet<>(edges); 49 | } 50 | 51 | public static HandlerList getHandlerList() { 52 | return handlers; 53 | } 54 | 55 | public HandlerList getHandlers() { 56 | return handlers; 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/EdgesDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.EdgeImpl; 4 | import de.cubbossa.pathfinder.node.NodeSelection; 5 | import java.util.Collection; 6 | import lombok.Getter; 7 | import lombok.RequiredArgsConstructor; 8 | import lombok.Setter; 9 | import org.bukkit.event.Cancellable; 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | public class EdgesDeleteEvent { 14 | 15 | private EdgesDeleteEvent() { 16 | } 17 | 18 | @Getter 19 | @RequiredArgsConstructor 20 | public static class Pre extends Event implements Cancellable { 21 | private static final HandlerList handlers = new HandlerList(); 22 | 23 | private final NodeSelection from; 24 | private final NodeSelection to; 25 | @Setter 26 | private boolean cancelled = false; 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlers; 30 | } 31 | 32 | public HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | } 36 | 37 | @Getter 38 | @RequiredArgsConstructor 39 | public static class Post extends Event { 40 | private static final HandlerList handlers = new HandlerList(); 41 | 42 | private final Collection edges; 43 | 44 | public static HandlerList getHandlerList() { 45 | return handlers; 46 | } 47 | 48 | public HandlerList getHandlers() { 49 | return handlers; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeCreateEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import de.cubbossa.pathfinder.node.NodeType; 5 | import lombok.Getter; 6 | import lombok.RequiredArgsConstructor; 7 | import lombok.Setter; 8 | import org.bukkit.Location; 9 | import org.bukkit.event.Cancellable; 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | @Getter 14 | @Setter 15 | @RequiredArgsConstructor 16 | public class NodeCreateEvent extends Event implements Cancellable { 17 | 18 | private static final HandlerList handlers = new HandlerList(); 19 | private final NodeType nodeType; 20 | private Location location; 21 | private boolean cancelled; 22 | 23 | public NodeCreateEvent(NodeType type, Location location) { 24 | this.nodeType = type; 25 | this.location = location; 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlers; 30 | } 31 | 32 | public HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.event.NodeCreateEvent; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | public class NodeCreatedEvent extends Event implements NodeCreateEvent { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | private final N node; 16 | 17 | public NodeCreatedEvent(N node) { 18 | this.node = node; 19 | } 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | public HandlerList getHandlers() { 26 | return handlers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeCurveLengthChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.NodeSelection; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | @RequiredArgsConstructor 13 | public class NodeCurveLengthChangedEvent extends Event { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final NodeSelection nodes; 18 | private final Double curveLength; 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public HandlerList getHandlers() { 25 | return handlers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeDeletedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.event.NodeDeleteEvent; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import lombok.Getter; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @Getter 10 | public class NodeDeletedEvent extends Event implements NodeDeleteEvent { 11 | 12 | private static final HandlerList handlers = new HandlerList(); 13 | 14 | private final Node node; 15 | 16 | public NodeDeletedEvent(Node node) { 17 | this.node = node; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public HandlerList getHandlers() { 25 | return handlers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeLocationChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.NodeSelection; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import org.bukkit.Location; 8 | import org.bukkit.event.Event; 9 | import org.bukkit.event.HandlerList; 10 | 11 | @Getter 12 | @Setter 13 | @RequiredArgsConstructor 14 | public class NodeLocationChangedEvent extends Event { 15 | 16 | private static final HandlerList handlers = new HandlerList(); 17 | 18 | private final NodeSelection nodes; 19 | private final Location location; 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | public HandlerList getHandlers() { 26 | return handlers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeSavedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.event.NodeSaveEvent; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import lombok.Getter; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @Getter 10 | public class NodeSavedEvent extends Event implements NodeSaveEvent { 11 | 12 | private static final HandlerList handlers = new HandlerList(); 13 | 14 | private final Node node; 15 | 16 | public NodeSavedEvent(Node node) { 17 | this.node = node; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public HandlerList getHandlers() { 25 | return handlers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodeTeleportEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.NodeSelection; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.bukkit.Location; 7 | import org.bukkit.event.Cancellable; 8 | import org.bukkit.event.Event; 9 | import org.bukkit.event.HandlerList; 10 | 11 | @Getter 12 | @Setter 13 | public class NodeTeleportEvent extends Event implements Cancellable { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final NodeSelection nodes; 18 | private final Location newPosition; 19 | private Location newPositionModified; 20 | private boolean cancelled = false; 21 | 22 | public NodeTeleportEvent(NodeSelection nodes, Location newPosition) { 23 | this.nodes = nodes; 24 | this.newPosition = newPosition; 25 | this.newPositionModified = newPosition; 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlers; 30 | } 31 | 32 | public HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/node/NodesDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.node; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import java.util.Collection; 5 | import java.util.List; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.bukkit.event.Cancellable; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | 12 | @Getter 13 | public class NodesDeleteEvent extends Event implements Cancellable { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final Collection nodes; 18 | @Setter 19 | private boolean cancelled; 20 | 21 | public NodesDeleteEvent(Collection nodes) { 22 | this.nodes = nodes; 23 | } 24 | 25 | public NodesDeleteEvent(Node node) { 26 | this.nodes = List.of(node); 27 | } 28 | 29 | public static HandlerList getHandlerList() { 30 | return handlers; 31 | } 32 | 33 | public HandlerList getHandlers() { 34 | return handlers; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/GroupCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.event.NodeGroupCreateEvent; 4 | import de.cubbossa.pathfinder.group.NodeGroup; 5 | import lombok.Getter; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | public class GroupCreatedEvent extends Event implements NodeGroupCreateEvent { 10 | 11 | private static final HandlerList handlers = new HandlerList(); 12 | 13 | @Getter 14 | private final NodeGroup group; 15 | 16 | public GroupCreatedEvent(NodeGroup group) { 17 | this.group = group; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public HandlerList getHandlers() { 25 | return handlers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/GroupDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.event.NodeGroupDeleteEvent; 4 | import de.cubbossa.pathfinder.group.NodeGroup; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import org.bukkit.event.Cancellable; 8 | import org.bukkit.event.Event; 9 | import org.bukkit.event.HandlerList; 10 | 11 | @Getter 12 | public class GroupDeleteEvent extends Event implements NodeGroupDeleteEvent, Cancellable { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | 16 | private final NodeGroup group; 17 | @Setter 18 | private boolean cancelled = false; 19 | 20 | public GroupDeleteEvent(NodeGroup group) { 21 | this.group = group; 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return handlers; 26 | } 27 | 28 | public HandlerList getHandlers() { 29 | return handlers; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/GroupSaveEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.event.NodeGroupSaveEvent; 4 | import de.cubbossa.pathfinder.group.NodeGroup; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @AllArgsConstructor 12 | public class GroupSaveEvent extends Event implements NodeGroupSaveEvent { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | 16 | private final NodeGroup group; 17 | 18 | public static HandlerList getHandlerList() { 19 | return handlers; 20 | } 21 | 22 | public HandlerList getHandlers() { 23 | return handlers; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupAssignEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import com.google.common.collect.Lists; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.util.ArrayList; 6 | import java.util.Collection; 7 | import java.util.Collections; 8 | import java.util.List; 9 | import java.util.UUID; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | import org.bukkit.event.Cancellable; 13 | import org.bukkit.event.Event; 14 | import org.bukkit.event.HandlerList; 15 | 16 | @Getter 17 | @Setter 18 | public class NodeGroupAssignEvent extends Event implements Cancellable { 19 | 20 | private static final HandlerList handlers = new HandlerList(); 21 | 22 | private final Collection groupables; 23 | private final Collection groups; 24 | private Collection modifiedGroupables; 25 | private Collection modifiedGroups; 26 | private boolean cancelled; 27 | 28 | public NodeGroupAssignEvent(UUID groupable, NamespacedKey groups) { 29 | this(Lists.newArrayList(groupable), List.of(groups)); 30 | } 31 | 32 | public NodeGroupAssignEvent(Collection groupables, Collection groups) { 33 | this.groupables = Collections.unmodifiableCollection(groupables); 34 | this.groups = Collections.unmodifiableCollection(groups); 35 | this.modifiedGroupables = new ArrayList<>(groupables); 36 | this.modifiedGroups = new ArrayList<>(groups); 37 | } 38 | 39 | public static HandlerList getHandlerList() { 40 | return handlers; 41 | } 42 | 43 | public HandlerList getHandlers() { 44 | return handlers; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupAssignedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import com.google.common.collect.Lists; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.util.Collection; 6 | import java.util.Collections; 7 | import java.util.List; 8 | import java.util.UUID; 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | import org.bukkit.event.Event; 12 | import org.bukkit.event.HandlerList; 13 | 14 | @Getter 15 | @Setter 16 | public class NodeGroupAssignedEvent extends Event { 17 | 18 | private static final HandlerList handlers = new HandlerList(); 19 | 20 | private final Collection groupables; 21 | private final Collection groups; 22 | 23 | public NodeGroupAssignedEvent(UUID groupables, NamespacedKey groups) { 24 | this(Lists.newArrayList(groupables), List.of(groups)); 25 | } 26 | 27 | public NodeGroupAssignedEvent(Collection groupables, Collection groups) { 28 | this.groupables = Collections.unmodifiableCollection(groupables); 29 | this.groups = Collections.unmodifiableCollection(groups); 30 | } 31 | 32 | public static HandlerList getHandlerList() { 33 | return handlers; 34 | } 35 | 36 | public HandlerList getHandlers() { 37 | return handlers; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return "NodeGroupAssignedEvent{" + 43 | "groupables=" + groupables + 44 | ", groups=" + groups + 45 | '}'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupFindDistanceChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | @AllArgsConstructor 13 | public class NodeGroupFindDistanceChangedEvent extends Event { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final NodeGroupImpl group; 18 | private final float value; 19 | 20 | public static HandlerList getHandlerList() { 21 | return handlers; 22 | } 23 | 24 | public HandlerList getHandlers() { 25 | return handlers; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupNameChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @Getter 10 | @AllArgsConstructor 11 | public class NodeGroupNameChangedEvent extends Event { 12 | 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | private final NodeGroupImpl group; 16 | private final String nameFormat; 17 | 18 | public static HandlerList getHandlerList() { 19 | return handlers; 20 | } 21 | 22 | public HandlerList getHandlers() { 23 | return handlers; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupNavigableChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @Getter 10 | @AllArgsConstructor 11 | public class NodeGroupNavigableChangedEvent extends Event { 12 | 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | private final NodeGroupImpl group; 16 | private final boolean newValue; 17 | 18 | public static HandlerList getHandlerList() { 19 | return handlers; 20 | } 21 | 22 | public HandlerList getHandlers() { 23 | return handlers; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupPermissionChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 4 | import javax.annotation.Nullable; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.bukkit.event.Event; 9 | import org.bukkit.event.HandlerList; 10 | 11 | @Getter 12 | @Setter 13 | @AllArgsConstructor 14 | public class NodeGroupPermissionChangedEvent extends Event { 15 | 16 | private static final HandlerList handlers = new HandlerList(); 17 | 18 | private final NodeGroupImpl group; 19 | private final @Nullable 20 | String permission; 21 | 22 | public static HandlerList getHandlerList() { 23 | return handlers; 24 | } 25 | 26 | public HandlerList getHandlers() { 27 | return handlers; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupRemoveEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import com.google.common.collect.Lists; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.List; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | import org.bukkit.event.Cancellable; 13 | import org.bukkit.event.Event; 14 | import org.bukkit.event.HandlerList; 15 | 16 | @Getter 17 | @Setter 18 | public class NodeGroupRemoveEvent extends Event implements Cancellable { 19 | 20 | private static final HandlerList handlers = new HandlerList(); 21 | 22 | private final Collection groupables; 23 | private final Collection groups; 24 | private Collection modifiedGroupables; 25 | private Collection modifiedGroups; 26 | private boolean cancelled; 27 | 28 | public NodeGroupRemoveEvent(Node groupables, NodeGroupImpl groups) { 29 | this(Lists.newArrayList(groupables), List.of(groups)); 30 | } 31 | 32 | public NodeGroupRemoveEvent(Collection groupables, 33 | Collection groups) { 34 | this.groupables = Collections.unmodifiableCollection(groupables); 35 | this.groups = Collections.unmodifiableCollection(groups); 36 | this.modifiedGroupables = new ArrayList<>(groupables); 37 | this.modifiedGroups = new ArrayList<>(groups); 38 | } 39 | 40 | public static HandlerList getHandlerList() { 41 | return handlers; 42 | } 43 | 44 | public HandlerList getHandlers() { 45 | return handlers; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupRemovedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import com.google.common.collect.Lists; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 6 | import java.util.Collection; 7 | import java.util.Collections; 8 | import java.util.List; 9 | import lombok.Getter; 10 | import lombok.Setter; 11 | import org.bukkit.event.Event; 12 | import org.bukkit.event.HandlerList; 13 | 14 | @Getter 15 | @Setter 16 | public class NodeGroupRemovedEvent extends Event { 17 | 18 | private static final HandlerList handlers = new HandlerList(); 19 | 20 | private final Collection groupables; 21 | private final Collection groups; 22 | 23 | public NodeGroupRemovedEvent(Node groupables, NodeGroupImpl groups) { 24 | this(Lists.newArrayList(groupables), List.of(groups)); 25 | } 26 | 27 | public NodeGroupRemovedEvent(Collection groupables, 28 | Collection groups) { 29 | this.groupables = Collections.unmodifiableCollection(groupables); 30 | this.groups = Collections.unmodifiableCollection(groups); 31 | } 32 | 33 | public static HandlerList getHandlerList() { 34 | return handlers; 35 | } 36 | 37 | public HandlerList getHandlers() { 38 | return handlers; 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "NodeGroupRemovedEvent{" + 44 | "groupables=" + groupables + 45 | ", groups=" + groups + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/nodegroup/NodeGroupSearchTermsChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.nodegroup.NodeGroupImpl; 4 | import java.util.ArrayList; 5 | import java.util.Collection; 6 | import lombok.Getter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | 12 | public class NodeGroupSearchTermsChangedEvent extends Event { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | private final NodeGroupImpl group; 16 | private final Action action; 17 | private final Collection changedTerms; 18 | 19 | public NodeGroupSearchTermsChangedEvent(NodeGroupImpl group, Action action, 20 | Collection terms) { 21 | this.group = group; 22 | this.action = action; 23 | this.changedTerms = new ArrayList<>(terms); 24 | } 25 | 26 | public static HandlerList getHandlerList() { 27 | return handlers; 28 | } 29 | 30 | public HandlerList getHandlers() { 31 | return handlers; 32 | } 33 | 34 | public enum Action { 35 | ADD, 36 | REMOVE, 37 | CLEAR 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/path/PathCancelEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.path; 2 | 3 | import de.cubbossa.pathfinder.event.PathCancelledEvent; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.bukkit.entity.Player; 9 | import org.bukkit.event.Cancellable; 10 | import org.bukkit.event.Event; 11 | import org.bukkit.event.HandlerList; 12 | 13 | @Getter 14 | @Setter 15 | public class PathCancelEvent extends Event implements Cancellable, PathCancelledEvent { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | 19 | private final PathPlayer player; 20 | private final VisualizerPath path; 21 | private boolean cancelled = false; 22 | 23 | public PathCancelEvent(PathPlayer player, VisualizerPath path) { 24 | this.player = player; 25 | this.path = path; 26 | } 27 | 28 | public static HandlerList getHandlerList() { 29 | return handlers; 30 | } 31 | 32 | public HandlerList getHandlers() { 33 | return handlers; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/path/PathStartEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.path; 2 | 3 | import de.cubbossa.pathfinder.misc.PathPlayer; 4 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.Cancellable; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | 12 | @Getter 13 | @Setter 14 | public class PathStartEvent extends Event implements Cancellable, de.cubbossa.pathfinder.event.PathStartEvent { 15 | 16 | private static final HandlerList handlers = new HandlerList(); 17 | 18 | private final PathPlayer player; 19 | private final VisualizerPath path; 20 | private boolean cancelled = false; 21 | 22 | public PathStartEvent(PathPlayer player, VisualizerPath path) { 23 | this.player = player; 24 | this.path = path; 25 | } 26 | 27 | public static HandlerList getHandlerList() { 28 | return handlers; 29 | } 30 | 31 | public HandlerList getHandlers() { 32 | return handlers; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/path/PathStopEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.path; 2 | 3 | import de.cubbossa.pathfinder.BukkitPathPlayer; 4 | import de.cubbossa.pathfinder.event.PathStoppedEvent; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import de.cubbossa.pathfinder.visualizer.GroupedVisualizerPathImpl; 7 | import java.util.UUID; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.Cancellable; 12 | import org.bukkit.event.Event; 13 | import org.bukkit.event.HandlerList; 14 | 15 | @Getter 16 | @Setter 17 | public class PathStopEvent extends Event implements Cancellable, PathStoppedEvent { 18 | 19 | private static final HandlerList handlers = new HandlerList(); 20 | 21 | private final PathPlayer player; 22 | private final GroupedVisualizerPathImpl path; 23 | private boolean cancelled = false; 24 | 25 | public PathStopEvent(UUID playerId, GroupedVisualizerPathImpl path) { 26 | this.player = new BukkitPathPlayer(playerId); 27 | this.path = path; 28 | } 29 | 30 | public static HandlerList getHandlerList() { 31 | return handlers; 32 | } 33 | 34 | public HandlerList getHandlers() { 35 | return handlers; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/path/PathTargetFoundEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.path; 2 | 3 | import de.cubbossa.pathfinder.event.PathTargetReachedEvent; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.visualizer.VisualizerPath; 6 | import lombok.Getter; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.Event; 9 | import org.bukkit.event.HandlerList; 10 | 11 | @Getter 12 | public class PathTargetFoundEvent extends Event implements PathTargetReachedEvent { 13 | 14 | private static final HandlerList handlers = new HandlerList(); 15 | 16 | private final PathPlayer player; 17 | private final VisualizerPath path; 18 | 19 | public PathTargetFoundEvent(PathPlayer player, VisualizerPath path) { 20 | this.player = player; 21 | this.path = path; 22 | } 23 | 24 | public static HandlerList getHandlerList() { 25 | return handlers; 26 | } 27 | 28 | public HandlerList getHandlers() { 29 | return handlers; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/visualizer/CombinedVisualizerChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.visualizer; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import de.cubbossa.pathfinder.visualizer.impl.CombinedVisualizer; 5 | import java.util.Collection; 6 | import lombok.Getter; 7 | import lombok.RequiredArgsConstructor; 8 | import lombok.Setter; 9 | import org.bukkit.event.Event; 10 | import org.bukkit.event.HandlerList; 11 | 12 | @Getter 13 | @Setter 14 | @RequiredArgsConstructor 15 | public class CombinedVisualizerChangedEvent extends Event { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | private final CombinedVisualizer visualizer; 19 | private final Action action; 20 | private final Collection> targets; 21 | 22 | public static HandlerList getHandlerList() { 23 | return handlers; 24 | } 25 | 26 | public HandlerList getHandlers() { 27 | return handlers; 28 | } 29 | 30 | public enum Action {ADD, REMOVE, CLEAR} 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/visualizer/VisualizerCreatedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.visualizer; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | @RequiredArgsConstructor 13 | public class VisualizerCreatedEvent extends Event { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final PathVisualizer visualizer; 18 | 19 | public static HandlerList getHandlerList() { 20 | return handlers; 21 | } 22 | 23 | public HandlerList getHandlers() { 24 | return handlers; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/visualizer/VisualizerNameChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.visualizer; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | @RequiredArgsConstructor 13 | public class VisualizerNameChangedEvent extends Event { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final PathVisualizer visualizer; 18 | private final String oldNameFormat; 19 | private final String newNameFormat; 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | public HandlerList getHandlers() { 26 | return handlers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/visualizer/VisualizerPermissionChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.visualizer; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import lombok.Setter; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | @Getter 11 | @Setter 12 | @RequiredArgsConstructor 13 | public class VisualizerPermissionChangedEvent extends Event { 14 | 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final PathVisualizer visualizer; 18 | private final String oldPermission; 19 | private final String newPermission; 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | public HandlerList getHandlers() { 26 | return handlers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/events/visualizer/VisualizerPropertyChangedEvent.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.events.visualizer; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import lombok.Getter; 5 | import lombok.RequiredArgsConstructor; 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @RequiredArgsConstructor 10 | @Getter 11 | public class VisualizerPropertyChangedEvent extends Event { 12 | 13 | private static final HandlerList handlers = new HandlerList(); 14 | 15 | private final PathVisualizer visualizer; 16 | private final String field; 17 | private final boolean visual; 18 | private final T oldValue; 19 | private final T newValue; 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | public HandlerList getHandlers() { 26 | return handlers; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/listener/PlayerListener.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.listener; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.node.GraphEditorRegistry; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.player.PlayerQuitEvent; 10 | 11 | public class PlayerListener implements Listener { 12 | 13 | @EventHandler 14 | public void onQuit(PlayerQuitEvent event) { 15 | PathPlayer player = PathPlayer.wrap(event.getPlayer()); 16 | 17 | NamespacedKey currentlyEdited = GraphEditorRegistry.getInstance().getEdited(player); 18 | if (currentlyEdited != null) { 19 | GraphEditorRegistry.getInstance().getNodeGroupEditor(currentlyEdited) 20 | .thenAccept(e -> e.setEditMode(player, false)); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/migration/V5_0_0__Config.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.migration; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import java.io.File; 5 | import org.bukkit.configuration.file.YamlConfiguration; 6 | import org.flywaydb.core.api.migration.BaseJavaMigration; 7 | import org.flywaydb.core.api.migration.Context; 8 | 9 | public class V5_0_0__Config extends BaseJavaMigration { 10 | 11 | @Override 12 | public void migrate(Context context) throws Exception { 13 | 14 | PathFinder pathFinder = PathFinder.get(); 15 | 16 | File config = new File(pathFinder.getDataFolder(), "config.yml"); 17 | if (!config.exists()) { 18 | return; 19 | } 20 | YamlConfiguration yml = YamlConfiguration.loadConfiguration(config); 21 | yml.set("version", null); 22 | yml.save(config); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/util/BukkitMainThreadExecutor.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import java.util.Queue; 4 | import java.util.concurrent.ConcurrentLinkedQueue; 5 | import java.util.concurrent.Executor; 6 | import org.bukkit.plugin.java.JavaPlugin; 7 | import org.jetbrains.annotations.NotNull; 8 | 9 | public class BukkitMainThreadExecutor implements Executor { 10 | 11 | private final double MAX_MILLIS_PER_TICK; 12 | private final int MAX_NANOS_PER_TICK; 13 | 14 | private final Queue tasks = new ConcurrentLinkedQueue<>(); 15 | 16 | public BukkitMainThreadExecutor(JavaPlugin plugin) { 17 | this(plugin, 50); 18 | } 19 | 20 | public BukkitMainThreadExecutor(JavaPlugin plugin, double maxMillis) { 21 | this.MAX_MILLIS_PER_TICK = maxMillis; 22 | this.MAX_NANOS_PER_TICK = (int) (MAX_MILLIS_PER_TICK * 1E6); 23 | plugin.getServer().getScheduler().runTaskTimer(plugin, this::runTasks, 1, 1); 24 | } 25 | 26 | @Override 27 | public void execute(@NotNull Runnable command) { 28 | tasks.offer(command); 29 | } 30 | 31 | public void runTasks() { 32 | long stopTime = System.nanoTime() + MAX_NANOS_PER_TICK; 33 | Runnable task; 34 | while (System.nanoTime() < stopTime && (task = tasks.poll()) != null) { 35 | task.run(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/util/BukkitUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | 4 | import de.cubbossa.pathfinder.BukkitPathPlayer; 5 | import de.cubbossa.pathfinder.BukkitPathSender; 6 | import de.cubbossa.pathfinder.misc.PathPlayer; 7 | import java.util.Objects; 8 | import java.util.UUID; 9 | import org.bukkit.Location; 10 | import org.bukkit.command.CommandSender; 11 | import org.bukkit.command.ConsoleCommandSender; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.util.Vector; 14 | 15 | public class BukkitUtils { 16 | 17 | private static final UUID console = new UUID(0, 0); 18 | 19 | public static PathPlayer wrap(PlayerT sender) { 20 | if (sender instanceof Player player) { 21 | return (PathPlayer) new BukkitPathPlayer(player.getUniqueId()); 22 | } else if (sender instanceof ConsoleCommandSender) { 23 | return (PathPlayer) new BukkitPathSender(); 24 | } 25 | throw new IllegalArgumentException("No implementation for type " + sender.getClass().getSimpleName()); 26 | } 27 | 28 | public static Location lerp(Location a, Location b, double percent) { 29 | if (!Objects.equals(a.getWorld(), b.getWorld())) { 30 | throw new IllegalArgumentException("Both locations must be in the same world to be lerped."); 31 | } 32 | return lerp(a.toVector(), b.toVector(), percent).toLocation(a.getWorld()); 33 | } 34 | 35 | public static Vector lerp(Vector a, Vector b, double percent) { 36 | return a.clone().add(b.clone().subtract(a).multiply(percent)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/util/WorldImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.pathfinder.misc.World; 4 | import java.util.Objects; 5 | import java.util.Optional; 6 | import java.util.UUID; 7 | import org.bukkit.Bukkit; 8 | 9 | public class WorldImpl implements World { 10 | 11 | private final UUID uuid; 12 | private org.bukkit.World world; 13 | 14 | public WorldImpl(UUID worldId) { 15 | this.uuid = worldId; 16 | } 17 | 18 | @Override 19 | public UUID getUniqueId() { 20 | return uuid; 21 | } 22 | 23 | @Override 24 | public String getName() { 25 | return resolve().map(org.bukkit.World::getName).orElse("-Unknown World-"); 26 | } 27 | 28 | private Optional resolve() { 29 | if (world == null) { 30 | world = Bukkit.getWorld(uuid); 31 | } 32 | return Optional.ofNullable(world); 33 | } 34 | 35 | @Override 36 | public int hashCode() { 37 | return uuid.hashCode(); 38 | } 39 | 40 | @Override 41 | public boolean equals(Object o) { 42 | if (this == o) { 43 | return true; 44 | } 45 | if (o == null || getClass() != o.getClass()) { 46 | return false; 47 | } 48 | WorldImpl world = (WorldImpl) o; 49 | return Objects.equals(uuid, world.uuid); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/visualizer/impl/BezierVisualizerType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.impl; 2 | 3 | import de.cubbossa.pathfinder.command.VisualizerTypeCommandExtension; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import dev.jorel.commandapi.arguments.Argument; 6 | import dev.jorel.commandapi.arguments.DoubleArgument; 7 | import dev.jorel.commandapi.arguments.IntegerArgument; 8 | 9 | public abstract class BezierVisualizerType 10 | extends IntervalVisualizerType 11 | implements VisualizerTypeCommandExtension { 12 | 13 | public BezierVisualizerType(NamespacedKey key) { 14 | super(key); 15 | } 16 | 17 | @Override 18 | public Argument appendEditCommand(Argument tree, int visualizerIndex, int argumentOffset) { 19 | tree = super.appendEditCommand(tree, visualizerIndex, argumentOffset); 20 | return tree 21 | .then(subCommand("point-distance", new DoubleArgument("distance", 0.02, 100), BezierPathVisualizer.PROP_POINT_DIST)) 22 | .then(subCommand("sample-rate", new IntegerArgument("distance", 1, 64), BezierPathVisualizer.PROP_SAMPLE_RATE)); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/visualizer/impl/BukkitVisualizer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.impl; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.navigation.UpdatingPath; 6 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizer; 7 | import org.bukkit.entity.Player; 8 | 9 | public abstract class BukkitVisualizer.BukkitView> 10 | extends AbstractVisualizer { 11 | 12 | public BukkitVisualizer(NamespacedKey key) { 13 | super(key); 14 | } 15 | 16 | @Override 17 | public Class getTargetType() { 18 | return Player.class; 19 | } 20 | 21 | public abstract class BukkitView extends AbstractVisualizer.AbstractView { 22 | public BukkitView(PathPlayer targetViewer, UpdatingPath path) { 23 | super(targetViewer, path); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/main/java/de/cubbossa/pathfinder/visualizer/impl/IntervalVisualizerType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer.impl; 2 | 3 | import de.cubbossa.pathfinder.PathPerms; 4 | import de.cubbossa.pathfinder.command.Arguments; 5 | import de.cubbossa.pathfinder.command.VisualizerTypeCommandExtension; 6 | import de.cubbossa.pathfinder.misc.NamespacedKey; 7 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizerType; 8 | import dev.jorel.commandapi.arguments.Argument; 9 | import java.util.Map; 10 | 11 | public abstract class IntervalVisualizerType> 12 | extends AbstractVisualizerType 13 | implements VisualizerTypeCommandExtension { 14 | 15 | 16 | public IntervalVisualizerType(NamespacedKey key) { 17 | super(key); 18 | } 19 | 20 | @Override 21 | public Argument appendEditCommand(Argument tree, int visualizerIndex, int argumentOffset) { 22 | return tree.then(subCommand("interval", Arguments.integer("ticks", 1), IntervalVisualizer.PROP_INTERVAL) 23 | .withPermission(PathPerms.PERM_CMD_PV_INTERVAL) 24 | ); 25 | } 26 | 27 | @Override 28 | public Map serialize(T visualizer) { 29 | Map map = super.serialize(visualizer); 30 | map.put("interval", visualizer.getInterval()); 31 | return map; 32 | } 33 | 34 | @Override 35 | public void deserialize(T visualizer, Map values) { 36 | super.deserialize(visualizer, values); 37 | loadProperty(values, visualizer, IntervalVisualizer.PROP_INTERVAL); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pathfinder-bukkit/src/test/java/de/cubbossa/pathfinder/visualizer/PlaceholderVisualizerTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import de.cubbossa.pathfinder.messages.Messages; 5 | import net.kyori.adventure.text.minimessage.MiniMessage; 6 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 7 | import org.junit.jupiter.api.Test; 8 | 9 | class PlaceholderVisualizerTest { 10 | 11 | @Test 12 | void resolveDistance() { 13 | 14 | MiniMessage resolver = MiniMessage.builder().tags(TagResolver.empty()).build(); 15 | 16 | assertEquals("1.2Test", resolver.serialize( 17 | resolver.deserialize("Test", Messages.formatter().number("number", 1.23d)))); 18 | assertEquals("Test", 19 | resolver.serialize(resolver.deserialize("Test")).replace("\\<", "<")); 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /pathfinder-citizens/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | id("io.freefair.lombok") version "6.6.2" 4 | } 5 | 6 | val minecraftVersion = project.property("minecraft_version") as String 7 | 8 | repositories { 9 | mavenCentral() 10 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 11 | maven("https://maven.citizensnpcs.co/repo") 12 | maven("https://libraries.minecraft.net") 13 | maven("https://repo.minebench.de/") 14 | } 15 | 16 | dependencies { 17 | 18 | compileOnly(project(":pathfinder-bukkit")) 19 | testImplementation(project(":pathfinder-bukkit")) 20 | implementation("de.cubbossa:disposables-api:1.3") 21 | 22 | // Spigot 23 | implementation("org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT") 24 | // Citizens 25 | implementation("net.citizensnpcs:citizens-main:2.0.33-SNAPSHOT") 26 | } 27 | 28 | tasks { 29 | test { 30 | useJUnitPlatform() 31 | } 32 | withType { 33 | options.encoding = "UTF-8" 34 | } 35 | } -------------------------------------------------------------------------------- /pathfinder-citizens/src/main/java/de/cubbossa/pathfinder/citizens/CitizensPathVisualizer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.citizens; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.navigation.UpdatingPath; 6 | import de.cubbossa.pathfinder.visualizer.impl.EdgeBasedVisualizer; 7 | import net.citizensnpcs.api.npc.NPC; 8 | import org.bukkit.Location; 9 | import org.bukkit.entity.Player; 10 | 11 | public class CitizensPathVisualizer extends EdgeBasedVisualizer { 12 | 13 | private NPC copyableNpc; 14 | 15 | public CitizensPathVisualizer(NamespacedKey key) { 16 | super(key); 17 | } 18 | 19 | @Override 20 | public View createView(UpdatingPath nodes, PathPlayer player) { 21 | return new View(player, nodes); 22 | } 23 | 24 | public class View extends EdgeBasedVisualizer.EdgeBasedView { 25 | 26 | private NPC npc; 27 | 28 | public View(PathPlayer player, UpdatingPath nodes) { 29 | super(player, nodes); 30 | } 31 | 32 | @Override 33 | public void play(Location nearestPoint, Location leadPoint, Edge nearestEdge) { 34 | if (!npc.isSpawned()) { 35 | npc.spawn(nearestPoint); 36 | } 37 | } 38 | 39 | @Override 40 | public void dispose() { 41 | npc.destroy(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pathfinder-citizens/src/main/java/de/cubbossa/pathfinder/citizens/NPCVisualizerGoalController.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.citizens; 2 | 3 | import net.citizensnpcs.api.ai.tree.Behavior; 4 | import net.citizensnpcs.api.ai.tree.BehaviorStatus; 5 | 6 | public class NPCVisualizerGoalController implements Behavior { 7 | 8 | @Override 9 | public void reset() { 10 | 11 | } 12 | 13 | @Override 14 | public BehaviorStatus run() { 15 | return null; 16 | } 17 | 18 | @Override 19 | public boolean shouldExecute() { 20 | return false; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-citizens/src/main/java/de/cubbossa/pathfinder/citizens/PathFinderCitizensExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.citizens; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathFinderExtensionBase; 5 | import de.cubbossa.pathfinder.misc.NamespacedKey; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.plugin.Plugin; 8 | 9 | public final class PathFinderCitizensExtension extends PathFinderExtensionBase { 10 | 11 | private static final NamespacedKey KEY = NamespacedKey.fromString("pathfinder:citizens"); 12 | 13 | @Override 14 | public NamespacedKey getKey() { 15 | return KEY; 16 | } 17 | 18 | @Override 19 | public void onEnable(PathFinder pathFinder) { 20 | Plugin citizens = Bukkit.getPluginManager().getPlugin("Citizens"); 21 | if (citizens == null) { 22 | disable(); 23 | } 24 | } 25 | 26 | @Override 27 | public void onDisable(PathFinder pathFinder) { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/antlr/de/cubbossa/pathfinder/antlr/SelectionLanguage.g4: -------------------------------------------------------------------------------- 1 | grammar SelectionLanguage; 2 | 3 | @header { 4 | package de.cubbossa.pathfinder.antlr; 5 | } 6 | 7 | program 8 | : expression EOF 9 | ; 10 | 11 | expression 12 | : sel=selector 13 | | sel=selector conditions 14 | ; 15 | 16 | selector 17 | : AT IDENTIFIER 18 | ; 19 | 20 | conditions 21 | : COND_OPEN COND_CLOSE 22 | | COND_OPEN attributelist COND_CLOSE 23 | ; 24 | 25 | attributelist 26 | : attributelist COND_DELIMIT attribute 27 | | attribute 28 | ; 29 | 30 | attribute 31 | : IDENTIFIER COND_EQUALS value 32 | ; 33 | 34 | value 35 | : expression 36 | | QUOTE 37 | | (IDENTIFIER | STRING)+ 38 | ; 39 | 40 | AT: '@'; 41 | COND_OPEN: '['; 42 | COND_CLOSE: ']'; 43 | COND_DELIMIT: ','; 44 | COND_EQUALS: '='; 45 | 46 | QUOTE : '"' ( /* ESC_SEQ | */~('\\'|'"') )* '"' ; 47 | IDENTIFIER: [a-zA-Z][a-zA-Z0-9_:-]*; 48 | STRING: (~[,=\]])+?; 49 | // 50 | //fragment 51 | //HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; 52 | // 53 | //fragment 54 | //ESC_SEQ 55 | // : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\') 56 | // | UNICODE_ESC 57 | // | OCTAL_ESC 58 | // ; 59 | // 60 | //fragment 61 | //OCTAL_ESC 62 | // : '\\' ('0'..'3') ('0'..'7') ('0'..'7') 63 | // | '\\' ('0'..'7') ('0'..'7') 64 | // | '\\' ('0'..'7') 65 | // ; 66 | //fragment 67 | //UNICODE_ESC 68 | // : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT 69 | // ; 70 | // 71 | //WHITESPACE: [ \r\n\t]+ -> skip; 72 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/antlr/de/cubbossa/pathfinder/antlr/SelectionSuggestionLanguage.g4: -------------------------------------------------------------------------------- 1 | grammar SelectionSuggestionLanguage; 2 | 3 | @header { 4 | package de.cubbossa.pathfinder.antlr; 5 | } 6 | 7 | program 8 | : expression EOF 9 | ; 10 | 11 | expression 12 | : AT 13 | | AT IDENTIFIER 14 | | AT IDENTIFIER conditions 15 | ; 16 | 17 | conditions 18 | : COND_OPEN 19 | | COND_OPEN attributelist 20 | | COND_OPEN COND_CLOSE 21 | | COND_OPEN attributelist COND_CLOSE 22 | ; 23 | 24 | attributelist 25 | : attributelist COND_DELIMIT 26 | | attributelist COND_DELIMIT attribute 27 | | attribute 28 | ; 29 | 30 | attribute 31 | : IDENTIFIER 32 | | IDENTIFIER COND_EQUALS 33 | | IDENTIFIER COND_EQUALS value 34 | ; 35 | 36 | value 37 | : expression 38 | | QUOTE 39 | | IDENTIFIER 40 | | STRING+ 41 | ; 42 | 43 | AT: '@'; 44 | COND_OPEN: '['; 45 | COND_CLOSE: ']'; 46 | COND_DELIMIT: ','; 47 | COND_EQUALS: '='; 48 | 49 | QUOTE : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ; 50 | IDENTIFIER: [a-zA-Z][a-zA-Z0-9_-]*; 51 | STRING: (~[,=])+?; 52 | 53 | fragment 54 | HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ; 55 | 56 | fragment 57 | ESC_SEQ 58 | : '\\' ('b'|'t'|'n'|'f'|'r'|'"'|'\''|'\\') 59 | | UNICODE_ESC 60 | | OCTAL_ESC 61 | ; 62 | 63 | fragment 64 | OCTAL_ESC 65 | : '\\' ('0'..'3') ('0'..'7') ('0'..'7') 66 | | '\\' ('0'..'7') ('0'..'7') 67 | | '\\' ('0'..'7') 68 | ; 69 | fragment 70 | UNICODE_ESC 71 | : '\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT 72 | ; 73 | 74 | WHITESPACE: [ \r\n\t]+ -> skip; 75 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/PathFinderExtensionBase.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Setter 7 | @Getter 8 | public abstract class PathFinderExtensionBase implements PathFinderExtension { 9 | 10 | private boolean disabled = false; 11 | 12 | @Override 13 | public void disable() { 14 | disabled = true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/Wiki.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | public class Wiki { 4 | 5 | private static final String URL = "https://docs.leonardbausenwein.de"; 6 | 7 | public static final String RM_INFO = URL + "/commands/roadmap.html#show-roadmap-infos"; 8 | public static final String RM_CREATE = URL + "/commands/roadmap.html#create-a-roadmap"; 9 | public static final String RM_DELETE = URL + "/commands/roadmap.html#delete-a-roadmap"; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/command/CmdTagResolver.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import java.util.Queue; 4 | import java.util.function.Function; 5 | 6 | public interface CmdTagResolver { 7 | 8 | String getKey(); 9 | 10 | String resolve(Queue argumentQueue); 11 | 12 | static CmdTagResolver tag(String key, Function, String> resolver) { 13 | return new CmdTagResolver() { 14 | @Override 15 | public String getKey() { 16 | return key; 17 | } 18 | 19 | @Override 20 | public String resolve(Queue argumentQueue) { 21 | return resolver.apply(argumentQueue); 22 | } 23 | }; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/command/CommandPlaceholderProcessor.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | public interface CommandPlaceholderProcessor { 4 | 5 | void addResolver(CmdTagResolver resolver); 6 | 7 | String process(String command, CmdTagResolver... resolvers); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/command/ModifierCommandExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import de.cubbossa.pathfinder.group.Modifier; 4 | import dev.jorel.commandapi.arguments.Argument; 5 | import dev.jorel.commandapi.executors.CommandExecutor; 6 | import net.kyori.adventure.text.ComponentLike; 7 | 8 | import java.util.function.Function; 9 | 10 | public interface ModifierCommandExtension { 11 | 12 | Argument registerAddCommand(Argument tree, Function consumer); 13 | 14 | ComponentLike toComponents(M modifier); 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/command/VisualizerTypeCommandExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import dev.jorel.commandapi.arguments.Argument; 4 | 5 | public interface VisualizerTypeCommandExtension { 6 | 7 | Argument appendEditCommand(Argument tree, int visualizerIndex, int argumentOffset); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/command/VisualizerTypeMessageExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 4 | import de.cubbossa.translations.Message; 5 | 6 | public interface VisualizerTypeMessageExtension> { 7 | 8 | Message getInfoMessage(VisualizerT element); 9 | } 10 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/dump/DumpWriterDataProvider.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.dump; 2 | 3 | public interface DumpWriterDataProvider { 4 | 5 | String getDumpKey(); 6 | 7 | Object getDumpData(); 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/navigation/query/FindQueryException.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation.query; 2 | 3 | public class FindQueryException extends RuntimeException { 4 | 5 | public FindQueryException(String message) { 6 | super(message); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/navigation/query/SearchQueryAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation.query; 2 | 3 | public record SearchQueryAttribute(String identifier, Comparator comparator, Object value) 4 | implements 5 | de.cubbossa.pathfinder.visualizer.query.SearchQueryAttribute { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/navigation/query/SearchTermImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.navigation.query; 2 | 3 | import de.cubbossa.pathfinder.visualizer.query.SearchQueryAttribute; 4 | import de.cubbossa.pathfinder.visualizer.query.SearchTerm; 5 | import java.util.Collection; 6 | import lombok.Getter; 7 | import lombok.RequiredArgsConstructor; 8 | 9 | @Getter 10 | @RequiredArgsConstructor 11 | public class SearchTermImpl implements SearchTerm { 12 | 13 | private final String identifier; 14 | 15 | @Override 16 | public boolean matches(Collection attributes) { 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/NavigateSelection.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | import lombok.Getter; 6 | import lombok.RequiredArgsConstructor; 7 | 8 | @RequiredArgsConstructor 9 | @Getter 10 | public class NavigateSelection extends HashSet { 11 | 12 | public NavigateSelection(Collection collection) { 13 | super(collection); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/WaypointType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import de.cubbossa.pathfinder.node.implementation.Waypoint; 6 | import de.cubbossa.pathfinder.storage.NodeStorageImplementation; 7 | import de.cubbossa.pathfinder.storage.implementation.NodeStorageImplementationWrapper; 8 | import org.pf4j.Extension; 9 | 10 | @Extension(points = NodeType.class) 11 | public class WaypointType extends AbstractNodeType { 12 | 13 | public WaypointType() { 14 | super(NamespacedKey.fromString("pathfinder:waypoint"), null); 15 | } 16 | 17 | @Override 18 | public Waypoint createNodeInstance(Context context) { 19 | Waypoint waypoint = new Waypoint(context.id()); 20 | waypoint.setLocation(context.location()); 21 | return waypoint; 22 | } 23 | 24 | @Override 25 | public NodeStorageImplementation getStorage() { 26 | if (storage == null && PathFinder.get() != null) { 27 | storage = new NodeStorageImplementationWrapper(PathFinder.get().getStorage()); 28 | } 29 | return storage; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/AbstractNodeSelectionParser.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection; 2 | 3 | import com.mojang.brigadier.arguments.ArgumentType; 4 | import de.cubbossa.pathfinder.node.Node; 5 | import de.cubbossa.pathfinder.util.SelectionParser; 6 | import java.util.List; 7 | 8 | public abstract class AbstractNodeSelectionParser> extends SelectionParser { 9 | public AbstractNodeSelectionParser(String identifier, String... alias) { 10 | super(identifier, alias); 11 | } 12 | 13 | public void addResolver(NodeSelectionArgument argument) { 14 | super.addResolver((Argument) argument); 15 | } 16 | 17 | public static abstract class NodeArgumentContext extends ArgumentContext { 18 | 19 | public NodeArgumentContext(ValueT value, List scope) { 20 | super(value, scope); 21 | } 22 | } 23 | 24 | public static abstract class NodeSelectionArgument extends Argument, NodeSelectionArgument> { 25 | 26 | public NodeSelectionArgument(ArgumentType type) { 27 | super(type); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/NodeSelectionAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection; 2 | 3 | import com.mojang.brigadier.arguments.ArgumentType; 4 | import com.mojang.brigadier.suggestion.Suggestion; 5 | import de.cubbossa.pathfinder.node.Node; 6 | import de.cubbossa.pathfinder.util.SelectionParser; 7 | import java.util.Collection; 8 | import java.util.Collections; 9 | import java.util.List; 10 | import org.pf4j.ExtensionPoint; 11 | 12 | public interface NodeSelectionAttribute extends ExtensionPoint { 13 | 14 | String getKey(); 15 | 16 | ArgumentType getValueType(); 17 | 18 | Type getAttributeType(); 19 | 20 | default Collection executeAfter() { 21 | return Collections.emptyList(); 22 | } 23 | 24 | List execute(AbstractNodeSelectionParser.NodeArgumentContext context); 25 | 26 | default List getSuggestions(SelectionParser.SuggestionContext context) { 27 | return Collections.emptyList(); 28 | } 29 | 30 | default List getStringSuggestions(SelectionParser.SuggestionContext context) { 31 | return Collections.emptyList(); 32 | } 33 | 34 | enum Type { 35 | SORT, 36 | FILTER, 37 | PEEK 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/ParsedSelectionAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection; 2 | 3 | public record ParsedSelectionAttribute(String identifier, String value) { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/attribute/IdSelectionAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection.attribute; 2 | 3 | import com.mojang.brigadier.arguments.ArgumentType; 4 | import de.cubbossa.pathfinder.PathFinder; 5 | import de.cubbossa.pathfinder.node.Node; 6 | import de.cubbossa.pathfinder.node.selection.AbstractNodeSelectionParser; 7 | import de.cubbossa.pathfinder.node.selection.NodeSelectionAttribute; 8 | import de.cubbossa.pathfinder.util.SelectionParser; 9 | import java.util.List; 10 | import java.util.UUID; 11 | import java.util.stream.Collectors; 12 | import lombok.Getter; 13 | import org.pf4j.Extension; 14 | 15 | @Getter 16 | @Extension(points = NodeSelectionAttribute.class) 17 | public class IdSelectionAttribute implements NodeSelectionAttribute { 18 | 19 | private final String key = "id"; 20 | 21 | @Override 22 | public ArgumentType getValueType() { 23 | return r -> UUID.fromString(r.getRemaining()); 24 | } 25 | 26 | @Override 27 | public Type getAttributeType() { 28 | return Type.FILTER; 29 | } 30 | 31 | @Override 32 | public List execute(AbstractNodeSelectionParser.NodeArgumentContext context) { 33 | return context.getScope().stream() 34 | .filter(n -> context.getValue().equals(n.getNodeId())) 35 | .collect(Collectors.toList()); 36 | } 37 | 38 | @Override 39 | public List getStringSuggestions(SelectionParser.SuggestionContext context) { 40 | return PathFinder.get().getStorage().loadNodes().join().stream() 41 | .map(Node::getNodeId) 42 | .map(integer -> integer + "") 43 | .collect(Collectors.toList()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/attribute/LimitSelectionAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection.attribute; 2 | 3 | import com.mojang.brigadier.arguments.ArgumentType; 4 | import com.mojang.brigadier.arguments.IntegerArgumentType; 5 | import de.cubbossa.pathfinder.misc.Range; 6 | import de.cubbossa.pathfinder.node.Node; 7 | import de.cubbossa.pathfinder.node.selection.AbstractNodeSelectionParser; 8 | import de.cubbossa.pathfinder.node.selection.NodeSelectionAttribute; 9 | import de.cubbossa.pathfinder.util.CollectionUtils; 10 | import java.util.List; 11 | import lombok.Getter; 12 | import org.pf4j.Extension; 13 | 14 | @Getter 15 | @Extension(points = NodeSelectionAttribute.class) 16 | public class LimitSelectionAttribute implements NodeSelectionAttribute { 17 | 18 | private final String key = "limit"; 19 | private final List executeAfter = List.of("offset"); 20 | 21 | @Override 22 | public ArgumentType getValueType() { 23 | return IntegerArgumentType.integer(0); 24 | } 25 | 26 | @Override 27 | public Type getAttributeType() { 28 | return Type.FILTER; 29 | } 30 | 31 | @Override 32 | public List execute(AbstractNodeSelectionParser.NodeArgumentContext context) { 33 | return CollectionUtils.subList(context.getScope(), Range.range(0, context.getValue())); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/node/selection/attribute/OffsetSelectionAttribute.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.node.selection.attribute; 2 | 3 | import com.mojang.brigadier.arguments.ArgumentType; 4 | import com.mojang.brigadier.arguments.IntegerArgumentType; 5 | import de.cubbossa.pathfinder.node.Node; 6 | import de.cubbossa.pathfinder.node.selection.AbstractNodeSelectionParser; 7 | import de.cubbossa.pathfinder.node.selection.NodeSelectionAttribute; 8 | import de.cubbossa.pathfinder.util.CollectionUtils; 9 | import java.util.List; 10 | import lombok.Getter; 11 | import org.pf4j.Extension; 12 | 13 | @Getter 14 | @Extension(points = NodeSelectionAttribute.class) 15 | public class OffsetSelectionAttribute implements NodeSelectionAttribute { 16 | 17 | private final String key = "offset"; 18 | 19 | @Override 20 | public ArgumentType getValueType() { 21 | return IntegerArgumentType.integer(0); 22 | } 23 | 24 | @Override 25 | public Type getAttributeType() { 26 | return Type.FILTER; 27 | } 28 | 29 | @Override 30 | public List execute(AbstractNodeSelectionParser.NodeArgumentContext context) { 31 | return CollectionUtils.subList(context.getScope(), context.getValue()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/NoImplGraphEditor.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup; 2 | 3 | import de.cubbossa.pathfinder.editor.GraphEditor; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import de.cubbossa.pathfinder.misc.PathPlayer; 6 | import lombok.Getter; 7 | import lombok.RequiredArgsConstructor; 8 | 9 | @RequiredArgsConstructor 10 | public class NoImplGraphEditor implements GraphEditor { 11 | 12 | @Getter 13 | private final NamespacedKey groupKey; 14 | 15 | @Override 16 | public void dispose() { 17 | 18 | } 19 | 20 | @Override 21 | public boolean isEdited() { 22 | return false; 23 | } 24 | 25 | @Override 26 | public boolean toggleEditMode(PathPlayer player) { 27 | throw new IllegalStateException( 28 | "Cannot use roadmap editor: no editor type registered. Are you using an API version of PathFinder?"); 29 | } 30 | 31 | @Override 32 | public void cancelEditModes() { 33 | 34 | } 35 | 36 | @Override 37 | public void setEditMode(PathPlayer player, boolean activate) { 38 | throw new IllegalStateException( 39 | "Cannot use roadmap editor: no editor type registered. Are you using an API version of PathFinder?"); 40 | } 41 | 42 | @Override 43 | public boolean isEditing(PathPlayer player) { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/modifier/CurveLengthModifierImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup.modifier; 2 | 3 | import de.cubbossa.pathfinder.group.CurveLengthModifier; 4 | import de.cubbossa.pathfinder.group.Modifier; 5 | 6 | public record CurveLengthModifierImpl(double curveLength) implements CurveLengthModifier { 7 | 8 | @Override 9 | public boolean equals(Object obj) { 10 | return !(obj instanceof Modifier mod) || getKey().equals(mod.getKey()); 11 | } 12 | 13 | @Override 14 | public int hashCode() { 15 | return getKey().hashCode(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/modifier/DiscoverableModifierImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup.modifier; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.group.DiscoverableModifier; 5 | import de.cubbossa.pathfinder.group.Modifier; 6 | import lombok.Getter; 7 | import net.kyori.adventure.text.Component; 8 | 9 | @Getter 10 | public class DiscoverableModifierImpl implements DiscoverableModifier { 11 | 12 | private String nameFormat; 13 | private Component displayName; 14 | 15 | public DiscoverableModifierImpl(String nameFormat) { 16 | setNameFormat(nameFormat); 17 | } 18 | 19 | @Override 20 | public void setNameFormat(String name) { 21 | this.nameFormat = name; 22 | this.displayName = PathFinder.get().getMiniMessage().deserialize(nameFormat); 23 | } 24 | 25 | @Override 26 | public boolean equals(Object obj) { 27 | return !(obj instanceof Modifier mod) || getKey().equals(mod.getKey()); 28 | } 29 | 30 | @Override 31 | public int hashCode() { 32 | return getKey().hashCode(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/modifier/FindDistanceModifierImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup.modifier; 2 | 3 | import de.cubbossa.pathfinder.group.FindDistanceModifier; 4 | import de.cubbossa.pathfinder.group.Modifier; 5 | 6 | public record FindDistanceModifierImpl(double distance) implements Modifier, FindDistanceModifier { 7 | 8 | @Override 9 | public boolean equals(Object obj) { 10 | return !(obj instanceof Modifier mod) || getKey().equals(mod.getKey()); 11 | } 12 | 13 | @Override 14 | public int hashCode() { 15 | return getKey().hashCode(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/modifier/PermissionModifierImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup.modifier; 2 | 3 | import de.cubbossa.pathfinder.group.Modifier; 4 | import de.cubbossa.pathfinder.group.PermissionModifier; 5 | 6 | public record PermissionModifierImpl(String permission) implements PermissionModifier { 7 | 8 | @Override 9 | public boolean equals(Object obj) { 10 | return !(obj instanceof Modifier mod) || getKey().equals(mod.getKey()); 11 | } 12 | 13 | @Override 14 | public int hashCode() { 15 | return getKey().hashCode(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/nodegroup/modifier/VisualizerModifierImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodegroup.modifier; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.group.Modifier; 5 | import de.cubbossa.pathfinder.group.VisualizerModifier; 6 | import de.cubbossa.pathfinder.misc.NamespacedKey; 7 | import de.cubbossa.pathfinder.visualizer.PathVisualizer; 8 | import java.util.Optional; 9 | import java.util.concurrent.CompletableFuture; 10 | 11 | public class VisualizerModifierImpl implements Modifier, VisualizerModifier { 12 | 13 | private final NamespacedKey visualizerKey; 14 | 15 | public VisualizerModifierImpl(NamespacedKey visualizerKey) { 16 | this.visualizerKey = visualizerKey; 17 | } 18 | 19 | @Override 20 | public boolean equals(Object obj) { 21 | return !(obj instanceof Modifier mod) || getKey().equals(mod.getKey()); 22 | } 23 | 24 | @Override 25 | public int hashCode() { 26 | return getKey().hashCode(); 27 | } 28 | 29 | public NamespacedKey getVisualizerKey() { 30 | return visualizerKey; 31 | } 32 | 33 | @Override 34 | public CompletableFuture>> getVisualizer() { 35 | return PathFinder.get().getStorage().loadVisualizer(visualizerKey); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/DataStorageException.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | public class DataStorageException extends RuntimeException { 4 | 5 | public DataStorageException(String message) { 6 | super(message); 7 | } 8 | 9 | public DataStorageException(String message, Throwable cause) { 10 | super(message, cause); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/InternalVisualizerStorageImplementation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizer; 5 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizerType; 6 | import java.util.Map; 7 | import java.util.Optional; 8 | 9 | public interface InternalVisualizerStorageImplementation { 10 | 11 | > Optional loadInternalVisualizer(AbstractVisualizerType type, NamespacedKey key); 12 | 13 | > Map loadInternalVisualizers(AbstractVisualizerType type); 14 | 15 | > void saveInternalVisualizer(AbstractVisualizerType type, VisualizerT visualizer); 16 | 17 | > void deleteInternalVisualizer(AbstractVisualizerType type, VisualizerT visualizer); 18 | } 19 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/WaypointStorageImplementation.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.node.implementation.Waypoint; 4 | import java.util.Collection; 5 | import java.util.Optional; 6 | import java.util.UUID; 7 | 8 | public interface WaypointStorageImplementation { 9 | 10 | Optional loadWaypoint(UUID uuid); 11 | 12 | Collection loadWaypoints(Collection ids); 13 | 14 | Collection loadAllWaypoints(); 15 | 16 | void saveWaypoint(Waypoint node); 17 | 18 | void deleteWaypoints(Collection waypoints); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/cache/NodeTypeCacheImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.cache; 2 | 3 | import de.cubbossa.pathfinder.node.Node; 4 | import de.cubbossa.pathfinder.node.NodeType; 5 | import java.util.Collection; 6 | import java.util.HashMap; 7 | import java.util.HashSet; 8 | import java.util.Map; 9 | import java.util.Optional; 10 | import java.util.UUID; 11 | 12 | public class NodeTypeCacheImpl implements NodeTypeCache { 13 | 14 | private final Map> types = new HashMap<>(); 15 | 16 | @Override 17 | public Optional> getType(UUID uuid) { 18 | return Optional.ofNullable((NodeType) types.get(uuid)); 19 | } 20 | 21 | @Override 22 | public CacheMap> getTypes(Collection uuids) { 23 | HashMap> present = new HashMap<>(); 24 | Collection absent = new HashSet<>(); 25 | for (UUID uuid : uuids) { 26 | if (types.containsKey(uuid)) { 27 | present.put(uuid, types.get(uuid)); 28 | } else { 29 | absent.add(uuid); 30 | } 31 | } 32 | return new CacheMap<>(present, absent); 33 | } 34 | 35 | @Override 36 | public void write(UUID uuid, NodeType type) { 37 | types.put(uuid, type); 38 | } 39 | 40 | @Override 41 | public void write(UUID uuid) { 42 | throw new IllegalStateException("Please call 'write(UUID, NodeType) instead"); 43 | } 44 | 45 | @Override 46 | public void invalidate(UUID uuid) { 47 | types.remove(uuid); 48 | } 49 | 50 | @Override 51 | public void invalidateAll() { 52 | types.clear(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/implementation/AbstractStorage.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.implementation; 2 | 3 | import de.cubbossa.pathfinder.group.ModifierRegistry; 4 | import de.cubbossa.pathfinder.node.NodeTypeRegistry; 5 | import de.cubbossa.pathfinder.storage.InternalVisualizerStorageImplementation; 6 | import de.cubbossa.pathfinder.storage.StorageImplementation; 7 | import de.cubbossa.pathfinder.storage.WaypointStorageImplementation; 8 | import de.cubbossa.pathfinder.storage.WorldLoader; 9 | import de.cubbossa.pathfinder.visualizer.VisualizerTypeRegistry; 10 | import java.util.logging.Logger; 11 | import javax.annotation.Nullable; 12 | import lombok.Getter; 13 | import lombok.Setter; 14 | 15 | public abstract class AbstractStorage implements StorageImplementation, WaypointStorageImplementation, InternalVisualizerStorageImplementation { 16 | 17 | final NodeTypeRegistry nodeTypeRegistry; 18 | final VisualizerTypeRegistry visualizerTypeRegistry; 19 | final ModifierRegistry modifierRegistry; 20 | 21 | @Getter 22 | @Setter 23 | WorldLoader worldLoader = uuid -> { 24 | throw new IllegalStateException("No WorldLoader registered for storage " + getClass().getSimpleName()); 25 | }; 26 | @Getter 27 | @Setter 28 | private @Nullable Logger logger; 29 | 30 | public AbstractStorage(NodeTypeRegistry nodeTypeRegistry, VisualizerTypeRegistry visualizerTypeRegistry, ModifierRegistry modifierRegistry) { 31 | this.nodeTypeRegistry = nodeTypeRegistry; 32 | this.visualizerTypeRegistry = visualizerTypeRegistry; 33 | this.modifierRegistry = modifierRegistry; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/implementation/NodeStorageImplementationWrapper.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.implementation; 2 | 3 | import de.cubbossa.pathfinder.node.implementation.Waypoint; 4 | import de.cubbossa.pathfinder.storage.NodeStorageImplementation; 5 | import de.cubbossa.pathfinder.storage.StorageAdapter; 6 | import de.cubbossa.pathfinder.storage.WaypointStorageImplementation; 7 | import java.util.Collection; 8 | import java.util.Optional; 9 | import java.util.UUID; 10 | 11 | public class NodeStorageImplementationWrapper implements NodeStorageImplementation { 12 | 13 | private final WaypointStorageImplementation implementation; 14 | 15 | public NodeStorageImplementationWrapper(StorageAdapter storage) { 16 | if (storage.getImplementation() instanceof WaypointStorageImplementation wp) { 17 | implementation = wp; 18 | } else { 19 | throw new IllegalArgumentException( 20 | "StorageAdapter implementation must also include waypoint methods."); 21 | } 22 | } 23 | 24 | @Override 25 | public Optional loadNode(UUID uuid) { 26 | return implementation.loadWaypoint(uuid); 27 | } 28 | 29 | @Override 30 | public Collection loadNodes(Collection ids) { 31 | return implementation.loadWaypoints(ids); 32 | } 33 | 34 | @Override 35 | public Collection loadAllNodes() { 36 | return implementation.loadAllWaypoints(); 37 | } 38 | 39 | @Override 40 | public void saveNode(Waypoint node) { 41 | implementation.saveWaypoint(node); 42 | } 43 | 44 | @Override 45 | public void deleteNodes(Collection nodes) { 46 | implementation.deleteWaypoints(nodes); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/implementation/RemoteSqlStorage.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.implementation; 2 | 3 | import com.zaxxer.hikari.HikariConfig; 4 | import com.zaxxer.hikari.HikariDataSource; 5 | import de.cubbossa.pathfinder.PathFinderConfig; 6 | import de.cubbossa.pathfinder.group.ModifierRegistry; 7 | import de.cubbossa.pathfinder.node.NodeTypeRegistry; 8 | import de.cubbossa.pathfinder.visualizer.VisualizerTypeRegistry; 9 | import javax.sql.DataSource; 10 | import org.jooq.SQLDialect; 11 | 12 | public class RemoteSqlStorage extends SqlStorage { 13 | 14 | private final HikariDataSource dataSource; 15 | 16 | public RemoteSqlStorage(PathFinderConfig.SqlStorageConfig configuration, 17 | NodeTypeRegistry nodeTypeRegistry, 18 | ModifierRegistry modifierRegistry, 19 | VisualizerTypeRegistry visualizerTypeRegistry) { 20 | super(SQLDialect.valueOf(configuration.getDialect()), nodeTypeRegistry, modifierRegistry, visualizerTypeRegistry); 21 | 22 | HikariConfig config = new HikariConfig(); 23 | config.setUsername(configuration.getUsername()); 24 | config.setPassword(configuration.getPassword()); 25 | config.setAutoCommit(false); 26 | config.setJdbcUrl(configuration.getJdbcUrl()); 27 | config.setMaximumPoolSize(2); 28 | config.setMinimumIdle(1); 29 | dataSource = new HikariDataSource(config); 30 | } 31 | 32 | @Override 33 | public void shutdown() { 34 | dataSource.close(); 35 | } 36 | 37 | @Override 38 | public DataSource getDataSource() { 39 | return dataSource; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/implementation/VisualizerStorageImplementationWrapper.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.implementation; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.storage.InternalVisualizerStorageImplementation; 5 | import de.cubbossa.pathfinder.storage.VisualizerStorageImplementation; 6 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizer; 7 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizerType; 8 | import java.util.Map; 9 | import java.util.Optional; 10 | import lombok.RequiredArgsConstructor; 11 | 12 | @RequiredArgsConstructor 13 | public class VisualizerStorageImplementationWrapper> 14 | implements VisualizerStorageImplementation { 15 | 16 | private final AbstractVisualizerType type; 17 | private final InternalVisualizerStorageImplementation storage; 18 | 19 | @Override 20 | public Map loadVisualizers() { 21 | return storage.loadInternalVisualizers(type); 22 | } 23 | 24 | @Override 25 | public Optional loadVisualizer(NamespacedKey key) { 26 | return storage.loadInternalVisualizer(type, key); 27 | } 28 | 29 | @Override 30 | public void saveVisualizer(T visualizer) { 31 | storage.saveInternalVisualizer(type, visualizer); 32 | } 33 | 34 | @Override 35 | public void deleteVisualizer(T visualizer) { 36 | storage.deleteInternalVisualizer(type, visualizer); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/misc/NamespacedKeyConverter.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.misc; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import org.jetbrains.annotations.NotNull; 5 | import org.jooq.Converter; 6 | 7 | public class NamespacedKeyConverter implements Converter { 8 | @Override 9 | public NamespacedKey from(String databaseObject) { 10 | return NamespacedKey.fromString(databaseObject); 11 | } 12 | 13 | @Override 14 | public String to(NamespacedKey userObject) { 15 | return userObject.toString(); 16 | } 17 | 18 | @Override 19 | public @NotNull Class fromType() { 20 | return String.class; 21 | } 22 | 23 | @Override 24 | public @NotNull Class toType() { 25 | return NamespacedKey.class; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/storage/misc/UUIDConverter.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage.misc; 2 | 3 | import java.util.UUID; 4 | import org.jooq.Converter; 5 | 6 | public class UUIDConverter implements Converter { 7 | 8 | @Override 9 | public final UUID from(String t) { 10 | return UUID.fromString(t); 11 | } 12 | 13 | @Override 14 | public final String to(UUID u) { 15 | return u.toString(); 16 | } 17 | 18 | @Override 19 | public Class fromType() { 20 | return String.class; 21 | } 22 | 23 | @Override 24 | public Class toType() { 25 | return UUID.class; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/ExtensionPoint.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.disposables.Disposable; 4 | import java.util.Collection; 5 | import java.util.Optional; 6 | import lombok.Getter; 7 | import org.jetbrains.annotations.NotNull; 8 | import org.pf4j.DefaultPluginManager; 9 | import org.pf4j.PluginManager; 10 | 11 | @Getter 12 | public class ExtensionPoint implements Disposable { 13 | 14 | static PluginManager pluginManager; 15 | 16 | private final Class type; 17 | 18 | public ExtensionPoint(final @NotNull Class type) { 19 | this.type = type; 20 | if (pluginManager == null) { 21 | pluginManager = new DefaultPluginManager(); 22 | } 23 | } 24 | 25 | public final Collection getExtensions() { 26 | return pluginManager.getExtensions(type); 27 | } 28 | 29 | public final Optional getExtension() { 30 | return pluginManager.getExtensions(type).stream().findFirst(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import java.io.File; 4 | import java.nio.file.Files; 5 | import lombok.SneakyThrows; 6 | 7 | public class FileUtils { 8 | 9 | public static boolean renameTo(File file, File other) { 10 | copy(file, other); 11 | return deleteDir(file); 12 | } 13 | 14 | @SneakyThrows 15 | public static void copy(File file, File target) { 16 | File[] files = file.listFiles(); 17 | Files.copy(file.toPath(), target.toPath()); 18 | if (files != null) { //some JVMs return null for empty dirs 19 | for (File f : files) { 20 | copy(new File(file, f.getName()), new File(target, f.getName())); 21 | } 22 | } 23 | } 24 | 25 | public static boolean deleteDir(File file) { 26 | File[] files = file.listFiles(); 27 | if (files != null) { //some JVMs return null for empty dirs 28 | for (File f : files) { 29 | if (f.isDirectory()) { 30 | deleteDir(f); 31 | } else { 32 | if (!f.delete()) { 33 | return false; 34 | } 35 | } 36 | } 37 | } 38 | return file.delete(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/FutureUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.ExecutionException; 6 | 7 | public class FutureUtils { 8 | 9 | public static CompletableFuture> both(CompletableFuture a, CompletableFuture b) { 10 | return CompletableFuture.allOf(a, b).thenApply((u) -> { 11 | try { 12 | return Map.entry(a.get(), b.get()); 13 | } catch (ExecutionException | InterruptedException e) { 14 | throw new RuntimeException(e); 15 | } 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/HashedRegistry.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.pathfinder.misc.Keyed; 4 | import de.cubbossa.pathfinder.misc.KeyedRegistry; 5 | import de.cubbossa.pathfinder.misc.NamespacedKey; 6 | import java.util.HashMap; 7 | import java.util.Iterator; 8 | import java.util.Map; 9 | import org.jetbrains.annotations.NotNull; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | public class HashedRegistry extends HashMap 13 | implements KeyedRegistry { 14 | 15 | public HashedRegistry() { 16 | super(); 17 | } 18 | 19 | public HashedRegistry(Map map) { 20 | super(); 21 | this.putAll(map); 22 | } 23 | 24 | @Nullable 25 | public K get(@NotNull NamespacedKey namespacedKey) { 26 | return super.get(namespacedKey); 27 | } 28 | 29 | @NotNull 30 | public Iterator iterator() { 31 | return super.values().iterator(); 32 | } 33 | 34 | public K put(K value) { 35 | return super.put(value.getKey(), value); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/IntPair.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | public record IntPair(int x, int y) { 4 | 5 | @Override 6 | public boolean equals(Object obj) { 7 | if (obj == this) { 8 | return true; 9 | } 10 | return obj instanceof IntPair pair && pair.x == x && pair.y == y; 11 | } 12 | 13 | @Override 14 | public int hashCode() { 15 | return (x << 24) + y; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return String.format("(%d, %d)", x, y); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/LerpUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import java.awt.Color; 4 | 5 | public class LerpUtils { 6 | 7 | public static Color lerp(Color a, Color b, double percent) { 8 | percent = Double.max(0, Double.min(1, percent)); 9 | int red = lerp(a.getRed(), b.getRed(), percent); 10 | int blue = lerp(a.getBlue(), b.getBlue(), percent); 11 | int green = lerp(a.getGreen(), b.getGreen(), percent); 12 | return new Color(red, green, blue); 13 | } 14 | 15 | public static Color lerp(org.bukkit.Color a, org.bukkit.Color b, double percent) { 16 | percent = Double.max(0, Double.min(1, percent)); 17 | int red = lerp(a.getRed(), b.getRed(), percent); 18 | int blue = lerp(a.getBlue(), b.getBlue(), percent); 19 | int green = lerp(a.getGreen(), b.getGreen(), percent); 20 | return new Color(red, green, blue); 21 | } 22 | 23 | public static int lerp(int a, int b, double percent) { 24 | return (int) ((1 - percent) * a + percent * b); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/ModifiedHashMap.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.pathfinder.Changes; 4 | import lombok.Getter; 5 | 6 | import java.util.Collection; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | public class ModifiedHashMap extends HashMap { 11 | 12 | @Getter 13 | private final Changes changes; 14 | 15 | public ModifiedHashMap() { 16 | changes = new Changes<>(); 17 | } 18 | 19 | @Override 20 | public V put(K key, V value) { 21 | changes.getAddList().add(value); 22 | return super.put(key, value); 23 | } 24 | 25 | @Override 26 | public void putAll(Map m) { 27 | super.putAll(m); 28 | changes.getAddList().addAll(m.values()); 29 | } 30 | 31 | @Override 32 | public V remove(Object key) { 33 | V val = super.remove(key); 34 | if (val != null) { 35 | changes.getRemoveList().add(val); 36 | } 37 | return val; 38 | } 39 | 40 | @Override 41 | public boolean remove(Object key, Object value) { 42 | if (super.remove(key, value)) { 43 | changes.getRemoveList().add((V) value); 44 | return true; 45 | } 46 | return false; 47 | } 48 | 49 | @Override 50 | public V putIfAbsent(K key, V value) { 51 | V val = super.putIfAbsent(key, value); 52 | if (val == null) { 53 | changes.getAddList().add(value); 54 | } 55 | return val; 56 | } 57 | 58 | @Override 59 | public Collection values() { 60 | return new ModifiedHashSet<>(changes, super.values()); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/StringUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import java.awt.Color; 5 | import java.util.Random; 6 | import lombok.Setter; 7 | import net.kyori.adventure.text.Component; 8 | import net.kyori.adventure.text.minimessage.MiniMessage; 9 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 10 | 11 | public class StringUtils { 12 | 13 | @Setter 14 | private static MiniMessage miniMessage = MiniMessage.miniMessage(); 15 | 16 | public static String toDisplayNameFormat(NamespacedKey key) { 17 | return insertInRandomHexString(capizalize(key.getKey().toLowerCase())); 18 | } 19 | 20 | public static String insertInRandomHexString(String inner) { 21 | String hex = Integer.toHexString( 22 | Color.getHSBColor(new Random().nextInt(360) / 360.f, 73 / 100.f, 96 / 100.f).getRGB()) 23 | .substring(2); 24 | return "<#" + hex + ">" + inner + ""; 25 | } 26 | 27 | public static String capizalize(String in) { 28 | if (in.length() < 1) { 29 | throw new IllegalArgumentException("String must not be empty"); 30 | } 31 | return in.substring(0, 1).toUpperCase() + in.substring(1); 32 | } 33 | 34 | public static Component deserialize(String str) { 35 | return miniMessage.deserialize(str); 36 | } 37 | 38 | public static Component deserialize(String str, TagResolver resolver) { 39 | return miniMessage.deserialize(str, resolver); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/util/VectorSplineLib.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import de.cubbossa.pathfinder.misc.Vector; 4 | import de.cubbossa.splinelib.SplineLib; 5 | import de.cubbossa.splinelib.util.BezierVector; 6 | 7 | public class VectorSplineLib extends SplineLib { 8 | @Override 9 | public de.cubbossa.splinelib.util.Vector convertToVector(Vector vector) { 10 | return new de.cubbossa.splinelib.util.Vector(vector.getX(), vector.getY(), vector.getZ()); 11 | } 12 | 13 | @Override 14 | public Vector convertFromVector(de.cubbossa.splinelib.util.Vector vector) { 15 | return new Vector(vector.getX(), vector.getY(), vector.getZ()); 16 | } 17 | 18 | @Override 19 | public BezierVector convertToBezierVector(Vector vector) { 20 | return new BezierVector(vector.getX(), vector.getY(), vector.getZ(), null, null); 21 | } 22 | 23 | @Override 24 | public Vector convertFromBezierVector(BezierVector bezierVector) { 25 | return new Vector(bezierVector.getX(), bezierVector.getY(), bezierVector.getZ()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/java/de/cubbossa/pathfinder/visualizer/SingleVisualizerPathImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.pathfinder.graph.NoPathFoundException; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.navigation.UpdatingPath; 6 | 7 | public class SingleVisualizerPathImpl> extends AbstractVisualizerPath { 8 | 9 | private final ViewT view; 10 | 11 | public SingleVisualizerPathImpl(UpdatingPath route, PathVisualizer visualizer, PathPlayer targetViewer) throws NoPathFoundException { 12 | super(route); 13 | setTargetViewer(targetViewer); 14 | this.view = visualizer.createView(route, targetViewer); 15 | update(); 16 | } 17 | 18 | @Override 19 | public void addViewer(PathPlayer player) { 20 | super.addViewer(player); 21 | this.view.addViewer(player); 22 | } 23 | 24 | @Override 25 | public void removeViewer(PathPlayer player) { 26 | super.removeViewer(player); 27 | this.view.removeViewer(player); 28 | } 29 | 30 | @Override 31 | public void removeAllViewers() { 32 | super.removeAllViewers(); 33 | this.view.removeAllViewers(); 34 | } 35 | 36 | @Override 37 | public void setTargetViewer(PathPlayer targetViewer) { 38 | super.setTargetViewer(targetViewer); 39 | view.setTargetViewer(targetViewer); 40 | } 41 | 42 | @Override 43 | public void update() throws NoPathFoundException { 44 | super.update(); 45 | this.view.update(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pathfinder-core/src/main/resources/database_template.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CubBossa/PathFinder/add3e81c5ca0f95c7d7e2abf52cb5b199af9c1fe/pathfinder-core/src/main/resources/database_template.db -------------------------------------------------------------------------------- /pathfinder-core/src/main/resources/lang/styles.properties: -------------------------------------------------------------------------------- 1 | # brand colors (blue) 2 | c-brand="<#0c72c0>" 3 | c-brand-light="<#2c97e8>" 4 | c-brand-dark="<#3e4c5e>" 5 | # offset colors (orange) 6 | c-offset="<#ff8c42>" 7 | c-offset-light="<#ffa266>" 8 | c-offset-dark="<#f26419>" 9 | # accent colors (greenish) 10 | c-accent="<#abdf75>" 11 | c-accent-light="<#caf79c>" 12 | c-accent-dark="<#74b035>" 13 | # text colors 14 | t="" 15 | t-light="" 16 | t-dark="" 17 | t-warm="<#e5d4c0>" 18 | t-highlight="" 19 | t-hl="" 20 | # background colors 21 | bg-light="" 22 | bg="" 23 | bg-dark="" 24 | c-empty="<#554640>" 25 | c-warn="" 26 | c-negative="" -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/AbstractNavigationModuleTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | class AbstractNavigationModuleTest extends PathFinderTest { 6 | 7 | @Test 8 | void registerFindPredicate() { 9 | } 10 | 11 | @Test 12 | void canFind() { 13 | } 14 | 15 | @Test 16 | void filterFindables() { 17 | } 18 | 19 | /*@Test 20 | void findPath() { 21 | setupPathFinder(); 22 | 23 | Waypoint a = makeWaypoint(new Location(0, 0, 0, world)); 24 | Waypoint b = makeWaypoint(new Location(0, 0, 10, world)); 25 | Waypoint c = makeWaypoint(new Location(10, 0, 0, world)); 26 | makeEdge(a, b); 27 | makeEdge(b, a); 28 | makeEdge(b, c); 29 | makeEdge(c, b); 30 | makeEdge(a, c); 31 | makeEdge(c, a); 32 | assertEdge(a.getNodeId(), b.getNodeId()); 33 | 34 | AbstractNavigationModule nav = new AbstractNavigationModule<>(); 35 | PathPlayer player = new TestPlayer(); 36 | 37 | nav.findPath(player, AbstractNavigationModule.NavigateLocationImpl.staticLocation( 38 | new Location(-10, 0, -10, world) 39 | ), Set.of(AbstractNavigationModule.NavigateLocationImpl.staticLocation( 40 | new Location(10, 0, 10, world) 41 | ))); 42 | 43 | shutdownPathFinder(); 44 | }*/ 45 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/command/CommandPlaceholderProcessorImplTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.command; 2 | 3 | import org.junit.jupiter.api.Assertions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | class CommandPlaceholderProcessorImplTest { 7 | 8 | @Test 9 | void addResolver() { 10 | } 11 | 12 | @Test 13 | void process() { 14 | 15 | CommandPlaceholderProcessorImpl processor = new CommandPlaceholderProcessorImpl(); 16 | processor.addResolver(CmdTagResolver.tag("test", u -> "test")); 17 | 18 | Assertions.assertEquals("some test x", processor.process("some ${test} x")); 19 | Assertions.assertEquals("some test x", processor.process("some ${ test} x")); 20 | Assertions.assertEquals("some test x", processor.process("some ${test } x")); 21 | Assertions.assertEquals("some test x", processor.process("some ${ test } x")); 22 | Assertions.assertEquals("some test", processor.process("some ${test.${test.${test}.test.${test.${test}}}}")); 23 | Assertions.assertEquals("some test", processor.process("some ${test}${other}")); 24 | } 25 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/dump/DumpWriterImplTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.dump; 2 | 3 | import com.google.gson.Gson; 4 | import java.util.Map; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.BeforeEach; 7 | import org.junit.jupiter.api.Test; 8 | 9 | class DumpWriterImplTest { 10 | 11 | 12 | @BeforeEach 13 | void beforeEach() { 14 | new DumpWriterImpl(false); 15 | } 16 | 17 | @Test 18 | void property1() { 19 | DumpWriterProvider.get().addProperty("a", () -> "abc"); 20 | Assertions.assertEquals(new Gson().toJson(Map.of("a", "abc")), DumpWriterProvider.get().toString()); 21 | DumpWriterProvider.get().removeProperty("a"); 22 | Assertions.assertEquals("{}", DumpWriterProvider.get().toString()); 23 | } 24 | 25 | @Test 26 | void property2() { 27 | DumpWriterProvider.get().addProperty("a", () -> 1); 28 | Assertions.assertEquals(new Gson().toJson(Map.of("a", 1)), DumpWriterProvider.get().toString()); 29 | } 30 | 31 | class Obj { 32 | int x = 1; 33 | String a = "abc"; 34 | } 35 | 36 | @Test 37 | void property3() { 38 | DumpWriterProvider.get().addProperty("a", Obj::new); 39 | Assertions.assertEquals(new Gson().toJson(Map.of("a", new Obj())), DumpWriterProvider.get().toString()); 40 | } 41 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/nodeselection/NumberRangeTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodeselection; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertThrows; 5 | import static org.junit.jupiter.api.Assertions.assertTrue; 6 | import de.cubbossa.pathfinder.node.selection.NumberRange; 7 | import lombok.SneakyThrows; 8 | import org.junit.jupiter.api.Test; 9 | 10 | class NumberRangeTest { 11 | 12 | @Test 13 | void from() { 14 | assertEquals(new NumberRange(1, Double.MAX_VALUE), NumberRange.from(1)); 15 | } 16 | 17 | @Test 18 | void to() { 19 | assertEquals(new NumberRange(-Double.MAX_VALUE, 1), NumberRange.to(1)); 20 | } 21 | 22 | @Test 23 | void range() { 24 | assertEquals(new NumberRange(1, 3), NumberRange.range(1, 3)); 25 | } 26 | 27 | @Test 28 | void throwOrder() { 29 | assertThrows(IllegalArgumentException.class, () -> NumberRange.range(3, 1)); 30 | } 31 | 32 | @Test 33 | void contains() { 34 | assertTrue(NumberRange.range(1, 3).contains(2)); 35 | } 36 | 37 | @Test 38 | @SneakyThrows 39 | void fromString() { 40 | String test = "5..10"; 41 | NumberRange parsed = NumberRange.parse(test); 42 | 43 | assertEquals(new NumberRange(5, 10), parsed); 44 | } 45 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/nodeselection/SelectionVisitorTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.nodeselection; 2 | 3 | import de.cubbossa.pathfinder.antlr.SelectionLanguageLexer; 4 | import de.cubbossa.pathfinder.antlr.SelectionLanguageParser; 5 | import de.cubbossa.pathfinder.node.selection.SelectionVisitor; 6 | import java.util.List; 7 | import org.antlr.v4.runtime.CharStream; 8 | import org.antlr.v4.runtime.CharStreams; 9 | import org.antlr.v4.runtime.CommonTokenStream; 10 | import org.junit.jupiter.api.Test; 11 | 12 | class SelectionVisitorTest { 13 | 14 | @Test 15 | public void test() { 16 | CharStream charStream = CharStreams.fromString("@e[some=1,condition=2,in=3,order=4]"); 17 | SelectionLanguageLexer lexer = new SelectionLanguageLexer(charStream); 18 | CommonTokenStream tokens = new CommonTokenStream(lexer); 19 | SelectionLanguageParser parser = new SelectionLanguageParser(tokens); 20 | SelectionVisitor visitor = new SelectionVisitor(List.of("e")); 21 | 22 | SelectionLanguageParser.ProgramContext tree = parser.program(); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/storage/CacheLayerTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import java.io.File; 4 | 5 | public class CacheLayerTest extends StorageTest { 6 | 7 | public CacheLayerTest() { 8 | useCaches = true; 9 | } 10 | 11 | @Override 12 | StorageImplementation storage(File dir) { 13 | return inMemoryStorage(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/storage/H2StorageTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import java.io.File; 4 | 5 | public class H2StorageTest extends StorageTest { 6 | 7 | @Override 8 | StorageImplementation storage(File dir) { 9 | return inMemoryStorage(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/storage/SqliteStorageTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.storage; 2 | 3 | import de.cubbossa.pathfinder.storage.implementation.SqlStorage; 4 | import de.cubbossa.pathfinder.storage.implementation.SqliteStorage; 5 | import java.io.File; 6 | import java.util.logging.Logger; 7 | 8 | public class SqliteStorageTest extends StorageTest { 9 | 10 | @Override 11 | StorageImplementation storage(File dir) { 12 | SqlStorage implementation = 13 | new SqliteStorage(new File(dir, "temp_database.db"), 14 | nodeTypeRegistry, modifierRegistry, visualizerTypeRegistry); 15 | implementation.setLogger(Logger.getLogger("TESTS")); 16 | return implementation; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/util/CommandHelpGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import dev.jorel.commandapi.CommandAPICommand; 4 | import dev.jorel.commandapi.arguments.IntegerArgument; 5 | import dev.jorel.commandapi.arguments.MultiLiteralArgument; 6 | import dev.jorel.commandapi.arguments.StringArgument; 7 | import java.util.List; 8 | import org.junit.jupiter.api.Test; 9 | 10 | class CommandHelpGeneratorTest { 11 | 12 | @Test 13 | void format() { 14 | 15 | CommandAPICommand cmd = new CommandAPICommand("test") 16 | .withFullDescription("bla1") 17 | .withSubcommand(new CommandAPICommand("sub1") 18 | .withFullDescription("bla2") 19 | .withArguments(new IntegerArgument("int"), new StringArgument("name")) 20 | .executes((commandSender, objects) -> { 21 | }) 22 | ) 23 | .withSubcommand(new CommandAPICommand("gamemode") 24 | .withFullDescription("bla3") 25 | .withArguments(new MultiLiteralArgument("creative", List.of("survival", "adventure"))) 26 | .executes((commandSender, objects) -> { 27 | }) 28 | ) 29 | .withSubcommand(new CommandAPICommand("gamemode") 30 | .withFullDescription("bla4") 31 | .withArguments(new IntegerArgument("test")) 32 | .executes((commandSender, objects) -> { 33 | })) 34 | .executes((commandSender, objects) -> { 35 | }); 36 | } 37 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/util/FileUtilsTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import java.io.File; 4 | import lombok.SneakyThrows; 5 | import org.junit.jupiter.api.Assertions; 6 | import org.junit.jupiter.api.Test; 7 | 8 | class FileUtilsTest { 9 | 10 | private File resources = new File("src/test/resources"); 11 | 12 | @SneakyThrows 13 | @Test 14 | void renameTo() { 15 | 16 | File a = new File(resources, "a/b.txt"); 17 | a.mkdirs(); 18 | a.createNewFile(); 19 | 20 | File target = new File(resources, "c/"); 21 | FileUtils.renameTo(new File(resources, "a/"), target); 22 | 23 | Assertions.assertTrue(target.exists()); 24 | Assertions.assertTrue(target.isDirectory()); 25 | Assertions.assertTrue(target.listFiles().length > 0); 26 | 27 | new File(target, "b.txt").delete(); 28 | target.delete(); 29 | } 30 | 31 | @Test 32 | void copy() { 33 | } 34 | 35 | @Test 36 | void deleteDir() { 37 | } 38 | } -------------------------------------------------------------------------------- /pathfinder-core/src/test/java/de/cubbossa/pathfinder/util/StringCompassTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.util; 2 | 3 | import net.kyori.adventure.text.minimessage.MiniMessage; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | class StringCompassTest { 8 | 9 | private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage(); 10 | 11 | @Test 12 | void asComponent() { 13 | StringCompass compass = new StringCompass("--------", 3, () -> 5.); 14 | compass.addMarker("N", "N", () -> 0.); 15 | compass.addMarker("E", "E", () -> 90.); 16 | compass.addMarker("S", "S", () -> 180.); 17 | compass.addMarker("W", "W", () -> 270.); 18 | 19 | Assertions.assertEquals( 20 | "-W-N-E-", 21 | MINI_MESSAGE.serialize(compass.asComponent().compact())); 22 | } 23 | } -------------------------------------------------------------------------------- /pathfinder-editmode/src/main/java/de/cubbossa/pathfinder/editmode/utils/DataUtils.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.editmode.utils; 2 | 3 | import de.tr7zw.changeme.nbtapi.NBTCompound; 4 | import de.tr7zw.changeme.nbtapi.NBTContainer; 5 | import de.tr7zw.changeme.nbtapi.NBTItem; 6 | import java.util.regex.Matcher; 7 | import java.util.regex.Pattern; 8 | import lombok.experimental.UtilityClass; 9 | import org.bukkit.Material; 10 | import org.bukkit.NamespacedKey; 11 | import org.bukkit.Registry; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | @UtilityClass 15 | public class DataUtils { 16 | 17 | private static final Pattern PTN_ITEMSTACK = 18 | Pattern.compile("\\{id:\"([a-z:_])\",Count:([0-9]+)b,tag:(\\{.*})}"); 19 | 20 | public String serializeItemStack(ItemStack stack) { 21 | return new NBTItem(stack).toString(); 22 | } 23 | 24 | public ItemStack deserializeItemStack(String input) { 25 | Matcher matcher = PTN_ITEMSTACK.matcher(input); 26 | if (!matcher.matches()) { 27 | throw new IllegalArgumentException("Input string is not a valid item stack: " + input); 28 | } 29 | NamespacedKey typeKey = NamespacedKey.fromString(matcher.group(1)); 30 | if (typeKey == null) { 31 | throw new IllegalArgumentException("Invalid material: " + matcher.group(1)); 32 | } 33 | Material type = Registry.MATERIAL.get(typeKey); 34 | if (type == null) { 35 | throw new IllegalArgumentException("Invalid material: " + matcher.group(1)); 36 | } 37 | int amount = Integer.parseInt(matcher.group(2)); 38 | NBTCompound nbt = new NBTContainer(matcher.group(3)); 39 | 40 | ItemStack stack = new ItemStack(type, amount); 41 | NBTItem item = new NBTItem(stack); 42 | item.mergeCompound(nbt); 43 | return item.getItem(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pathfinder-graph/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `java-library` 3 | id("io.freefair.lombok") version "6.6.2" 4 | } 5 | 6 | java { 7 | toolchain { 8 | languageVersion.set(JavaLanguageVersion.of(17)) 9 | } 10 | } 11 | 12 | dependencies { 13 | compileOnlyApi("org.jetbrains:annotations:24.0.0") 14 | 15 | api("com.google.guava:guava:32.1.2-jre") // this shouldn't be needed 16 | 17 | // Tests 18 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0") 19 | testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0") 20 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0") 21 | } 22 | 23 | tasks { 24 | test { 25 | useJUnitPlatform() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /pathfinder-graph/src/main/java/de/cubbossa/pathfinder/graph/GraphEntryNotEstablishedException.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | public class GraphEntryNotEstablishedException extends RuntimeException { 4 | } 5 | -------------------------------------------------------------------------------- /pathfinder-graph/src/main/java/de/cubbossa/pathfinder/graph/NoPathFoundException.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import org.jetbrains.annotations.Nullable; 4 | 5 | /** 6 | * An exception to throw if a {@link PathSolver} was not able to find any path from start to target. 7 | */ 8 | public class NoPathFoundException extends Exception { 9 | 10 | public NoPathFoundException() { 11 | this(null, null, null); 12 | } 13 | 14 | public NoPathFoundException(@Nullable Object from, @Nullable Object to) { 15 | this(from, to, null); 16 | } 17 | 18 | public NoPathFoundException(@Nullable Object from, @Nullable Object to, @Nullable Exception cause) { 19 | super( 20 | (from == null ? "" : "\n - Start Node: " + from + " ") 21 | + (to == null ? "" : "\n - End Node: " + to), 22 | cause 23 | ); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /pathfinder-graph/src/main/java/de/cubbossa/pathfinder/graph/PathSolverResult.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import java.util.List; 4 | 5 | public interface PathSolverResult { 6 | 7 | List getPath(); 8 | 9 | List getEdges(); 10 | 11 | double getCost(); 12 | } 13 | -------------------------------------------------------------------------------- /pathfinder-graph/src/main/java/de/cubbossa/pathfinder/graph/PathSolverResultImpl.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import java.util.List; 4 | 5 | public record PathSolverResultImpl(List path, List edge, 6 | double cost) implements PathSolverResult { 7 | 8 | @Override 9 | public List getPath() { 10 | return path; 11 | } 12 | 13 | @Override 14 | public List getEdges() { 15 | return edge; 16 | } 17 | 18 | @Override 19 | public double getCost() { 20 | return cost; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pathfinder-graph/src/test/java/de/cubbossa/pathfinder/graph/DynamicDijkstraTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import java.util.function.Function; 4 | import org.junit.jupiter.api.TestInstance; 5 | 6 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 7 | class DynamicDijkstraTest extends ShortestPathTest { 8 | @Override 9 | PathSolver solver() { 10 | return new DynamicDijkstra<>(Function.identity()); 11 | } 12 | } -------------------------------------------------------------------------------- /pathfinder-graph/src/test/java/de/cubbossa/pathfinder/graph/GraphUtilsTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import com.google.common.graph.MutableValueGraph; 4 | import com.google.common.graph.ValueGraph; 5 | import com.google.common.graph.ValueGraphBuilder; 6 | import com.google.common.graph.ValueGraphGen; 7 | import com.pholser.junit.quickcheck.From; 8 | import com.pholser.junit.quickcheck.Property; 9 | import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; 10 | import org.junit.jupiter.api.Assertions; 11 | import org.junit.runner.RunWith; 12 | 13 | @RunWith(JUnitQuickcheck.class) 14 | public class GraphUtilsTest { 15 | 16 | @Property 17 | public void islands() { 18 | 19 | MutableValueGraph aToB = ValueGraphBuilder.directed().build(); 20 | aToB.addNode("a"); 21 | aToB.addNode("b"); 22 | aToB.putEdgeValue("a", "b", 1.5); 23 | Assertions.assertEquals(1, GraphUtils.islands(aToB).size()); 24 | 25 | MutableValueGraph bToA = ValueGraphBuilder.directed().build(); 26 | bToA.addNode("a"); 27 | bToA.addNode("b"); 28 | bToA.putEdgeValue("b", "a", 1.5); 29 | Assertions.assertEquals(1, GraphUtils.islands(bToA).size()); 30 | 31 | MutableValueGraph aAndB = ValueGraphBuilder.directed().build(); 32 | aAndB.addNode("a"); 33 | aAndB.addNode("b"); 34 | Assertions.assertEquals(2, GraphUtils.islands(aAndB).size()); 35 | } 36 | 37 | @Property 38 | public void lol(String s) { 39 | System.out.println(s); 40 | } 41 | 42 | @Property 43 | public void testMerge(@From(ValueGraphGen.class) ValueGraph graph) { 44 | System.out.println(graph); 45 | Assertions.assertEquals( 46 | graph, 47 | GraphUtils.merge(graph, graph) 48 | ); 49 | } 50 | } -------------------------------------------------------------------------------- /pathfinder-graph/src/test/java/de/cubbossa/pathfinder/graph/StaticDijkstraTest.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.graph; 2 | 3 | import java.util.function.Function; 4 | import org.junit.jupiter.api.TestInstance; 5 | 6 | @TestInstance(TestInstance.Lifecycle.PER_CLASS) 7 | class StaticDijkstraTest extends ShortestPathTest { 8 | @Override 9 | PathSolver solver() { 10 | return new StaticDijkstra<>(Function.identity()); 11 | } 12 | } -------------------------------------------------------------------------------- /pathfinder-papi/src/main/java/de/cubbossa/pathfinder/module/papi/PlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.module.papi; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathFinderExtension; 5 | import de.cubbossa.pathfinder.misc.NamespacedKey; 6 | import de.cubbossa.pathfinder.PathFinderExtensionBase; 7 | import de.cubbossa.pathfinder.PathFinderPlugin; 8 | import de.cubbossa.pathfinder.visualizer.VisualizerTypeRegistryImpl; 9 | import java.util.logging.Level; 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.plugin.Plugin; 12 | import org.bukkit.plugin.java.JavaPlugin; 13 | import org.jetbrains.annotations.NotNull; 14 | 15 | public class PlaceholderExtension extends PathFinderExtensionBase implements PathFinderExtension { 16 | 17 | @NotNull 18 | @Override 19 | public NamespacedKey getKey() { 20 | return NamespacedKey.fromString("pathfinder:papi"); 21 | } 22 | 23 | @Override 24 | public void onEnable(PathFinder pathPlugin) { 25 | Plugin papi = Bukkit.getPluginManager().getPlugin("PlaceholderAPI"); 26 | if (papi == null) { 27 | disable(); 28 | } 29 | pathPlugin.getLogger().log(Level.INFO, "Found PlaceholderAPI, registered module."); 30 | 31 | PlaceholderHook hook = new PlaceholderHook(JavaPlugin.getPlugin(PathFinderPlugin.class)); 32 | pathPlugin.getDisposer().register(this, hook); 33 | 34 | VisualizerTypeRegistryImpl.getInstance() 35 | .registerVisualizerType(PlaceholderHook.PLACEHOLDER_VISUALIZER_TYPE); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /pathfinder-quests-module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | repositories { 6 | mavenCentral() 7 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 8 | maven("https://repo.codemc.io/repository/maven-public/") 9 | maven("https://libraries.minecraft.net") 10 | maven("https://jitpack.io") 11 | } 12 | 13 | dependencies { 14 | implementation("me.pikamug.quests:quests-core:5.0.5") 15 | implementation("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT") 16 | implementation(project(":pathfinder-api")) 17 | implementation(project(":pathfinder-bukkit")) 18 | 19 | testImplementation(platform("org.junit:junit-bom:5.9.1")) 20 | testImplementation("org.junit.jupiter:junit-jupiter") 21 | } 22 | 23 | tasks.test { 24 | useJUnitPlatform() 25 | } -------------------------------------------------------------------------------- /pathfinder-quests-module/src/main/java/de/cubbossa/pathfinder/module/quests/DiscoveryReward.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.module.quests; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.discovery.BukkitDiscoveryModule; 5 | import de.cubbossa.pathfinder.group.NodeGroup; 6 | import de.cubbossa.pathfinder.misc.NamespacedKey; 7 | import de.cubbossa.pathfinder.misc.PathPlayer; 8 | import java.time.LocalDateTime; 9 | import java.util.List; 10 | import java.util.Map; 11 | import java.util.UUID; 12 | import me.pikamug.quests.module.BukkitCustomReward; 13 | 14 | public class DiscoveryReward extends BukkitCustomReward { 15 | 16 | public DiscoveryReward() { 17 | setName("PathFinder Discovery Reward"); 18 | setAuthor("CubBossa"); 19 | setItem("MAP", (short) 0); 20 | addStringPrompt("Places", "Enter a group or a list of groups that will be discovered.", null); 21 | setDisplay("Discovering: %Places%."); 22 | } 23 | 24 | @Override 25 | public void giveReward(UUID uuid, Map map) { 26 | var module = BukkitDiscoveryModule.getInstance(); 27 | var player = PathPlayer.wrap(uuid); 28 | 29 | String concatenatedGroupList = (String) map.get("Places"); 30 | List groupNames = List.of(concatenatedGroupList.split(",")); 31 | 32 | for (String groupName : groupNames) { 33 | NamespacedKey key; 34 | if (groupName.contains(":")) { 35 | key = NamespacedKey.fromString(groupName); 36 | } else { 37 | key = NamespacedKey.fromString("pathfinder:" + groupName); 38 | } 39 | PathFinder.get().getStorage().loadGroup(key).join() 40 | .ifPresent(group -> module.discover(player, group, LocalDateTime.now())); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pathfinder-quests-module/src/main/java/de/cubbossa/pathfinder/module/quests/PathFinderQuestsModule.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.module.quests; 2 | 3 | import java.util.logging.Level; 4 | import org.bukkit.plugin.java.JavaPlugin; 5 | 6 | public class PathFinderQuestsModule extends JavaPlugin { 7 | 8 | @Override 9 | public void onEnable() { 10 | getLogger().log(Level.SEVERE, "PathFinderQuestsModule is not a plugin, it is a module of the Quests plugin" + 11 | "and must be installed in the modules directory of the Quests directory (/plugins/quests/modules/...)"); 12 | getPluginLoader().disablePlugin(this); 13 | } 14 | } -------------------------------------------------------------------------------- /pathfinder-scripted-visualizer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | id("io.freefair.lombok") version "6.6.2" 4 | id("com.github.johnrengelman.shadow") version "8.1.0" 5 | } 6 | 7 | java { 8 | toolchain { 9 | languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | } 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | 17 | val minecraftVersion = project.property("minecraft_version") as String 18 | 19 | repositories { 20 | mavenCentral() 21 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 22 | maven("https://libraries.minecraft.net/") 23 | maven("https://repo.codemc.org/repository/maven-public/") 24 | maven("https://nexus.leonardbausenwein.de/repository/maven-public/") 25 | maven("https://repo.dmulloy2.net/repository/public/") 26 | maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") 27 | } 28 | 29 | dependencies { 30 | 31 | compileOnly(project(":pathfinder-bukkit")) 32 | 33 | // Tests 34 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") 35 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") 36 | 37 | // Service 38 | annotationProcessor("com.google.auto.service:auto-service:1.0-rc5") 39 | implementation("com.google.auto.service:auto-service:1.0") 40 | 41 | // JavaScript 42 | implementation("org.openjdk.nashorn:nashorn-core:15.4") 43 | implementation("org.snakeyaml:snakeyaml-engine:2.0") 44 | } 45 | 46 | tasks { 47 | test { 48 | useJUnitPlatform() 49 | } 50 | withType { 51 | options.encoding = "UTF-8" 52 | } 53 | } -------------------------------------------------------------------------------- /pathfinder-scripted-visualizer/src/main/java/de/cubbossa/pathfinder/visualizer/ScriptedVisualizerPathfinderExtension.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder.visualizer; 2 | 3 | import de.cubbossa.pathfinder.PathFinder; 4 | import de.cubbossa.pathfinder.PathFinderExtension; 5 | import de.cubbossa.pathfinder.misc.NamespacedKey; 6 | import de.cubbossa.pathfinder.AbstractPathFinder; 7 | import de.cubbossa.pathfinder.PathFinderExtensionBase; 8 | import de.cubbossa.pathfinder.storage.InternalVisualizerStorageImplementation; 9 | import de.cubbossa.pathfinder.storage.implementation.VisualizerStorageImplementationWrapper; 10 | import org.jetbrains.annotations.NotNull; 11 | import org.pf4j.Extension; 12 | 13 | @Extension(points = PathFinderExtension.class) 14 | public class ScriptedVisualizerPathfinderExtension extends PathFinderExtensionBase implements PathFinderExtension { 15 | 16 | public static final NamespacedKey KEY = AbstractPathFinder.pathfinder("scriptline-visualizers"); 17 | public static AbstractVisualizerType ADV_PARTICLE_VISUALIZER_TYPE = 18 | new ScriptLineParticleVisualizerType(); 19 | 20 | @NotNull 21 | @Override 22 | public NamespacedKey getKey() { 23 | return KEY; 24 | } 25 | 26 | @Override 27 | public void onEnable(PathFinder pathPlugin) { 28 | if (pathPlugin.getStorage().getImplementation() instanceof InternalVisualizerStorageImplementation storage) { 29 | ADV_PARTICLE_VISUALIZER_TYPE.setStorage(new VisualizerStorageImplementationWrapper<>(ADV_PARTICLE_VISUALIZER_TYPE, storage)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /pathfinder-test-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | id("io.freefair.lombok") version "6.6.2" 4 | } 5 | 6 | group = "de.cubbossa" 7 | 8 | repositories { 9 | mavenCentral() 10 | maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") 11 | maven("https://nexus.leonardbausenwein.de/repository/maven-public/") 12 | maven("https://libraries.minecraft.net/") 13 | maven("https://repo.codemc.org/repository/maven-public/") 14 | maven("https://repo.papermc.io/repository/maven-public/") 15 | } 16 | 17 | dependencies { 18 | compileOnly(project(":pathfinder-api")) 19 | compileOnly(project(":pathfinder-core")) 20 | implementation("org.junit.jupiter:junit-jupiter-api:5.9.2") 21 | implementation("org.junit.jupiter:junit-jupiter-params:5.9.2") 22 | implementation("org.xerial:sqlite-jdbc:3.41.2.2") 23 | implementation("com.h2database:h2:2.1.214") 24 | } 25 | 26 | tasks.test { 27 | useJUnitPlatform() 28 | } -------------------------------------------------------------------------------- /pathfinder-test-utils/src/main/java/de/cubbossa/pathfinder/TestModifier.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.group.Modifier; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | 6 | public record TestModifier(String data) implements Modifier { 7 | @Override 8 | public NamespacedKey getKey() { 9 | return TestModifierType.KEY; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /pathfinder-test-utils/src/main/java/de/cubbossa/pathfinder/TestModifierType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.group.ModifierType; 4 | import de.cubbossa.pathfinder.misc.NamespacedKey; 5 | import java.io.IOException; 6 | import java.util.Map; 7 | import org.pf4j.Extension; 8 | 9 | @Extension(points = ModifierType.class) 10 | public class TestModifierType implements ModifierType { 11 | 12 | public static final NamespacedKey KEY = NamespacedKey.fromString("pathfinder:test-modifier"); 13 | 14 | @Override 15 | public NamespacedKey getKey() { 16 | return KEY; 17 | } 18 | 19 | @Override 20 | public String getSubCommandLiteral() { 21 | return "mod"; 22 | } 23 | 24 | @Override 25 | public Map serialize(TestModifier modifier) { 26 | return Map.of("data", modifier.data()); 27 | } 28 | 29 | @Override 30 | public TestModifier deserialize(Map values) throws IOException { 31 | return new TestModifier((String) values.get("data")); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /pathfinder-test-utils/src/main/java/de/cubbossa/pathfinder/TestPlayer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.misc.Location; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.misc.World; 6 | import net.kyori.adventure.text.Component; 7 | import net.kyori.adventure.text.ComponentLike; 8 | 9 | import java.util.UUID; 10 | 11 | public class TestPlayer implements PathPlayer { 12 | 13 | private final UUID uuid; 14 | 15 | public TestPlayer() { 16 | this(UUID.randomUUID()); 17 | } 18 | 19 | public TestPlayer(UUID uuid) { 20 | this.uuid = uuid; 21 | } 22 | 23 | @Override 24 | public UUID getUniqueId() { 25 | return uuid; 26 | } 27 | 28 | @Override 29 | public Class getPlayerClass() { 30 | return Object.class; 31 | } 32 | 33 | @Override 34 | public String getName() { 35 | return "testname"; 36 | } 37 | 38 | @Override 39 | public Component getDisplayName() { 40 | return Component.text(getName()); 41 | } 42 | 43 | @Override 44 | public Location getLocation() { 45 | return new Location(0, 0, 0, new World() { 46 | @Override 47 | public UUID getUniqueId() { 48 | return UUID.randomUUID(); 49 | } 50 | 51 | @Override 52 | public String getName() { 53 | return "testworld"; 54 | } 55 | }); 56 | } 57 | 58 | @Override 59 | public boolean hasPermission(String permission) { 60 | return true; 61 | } 62 | 63 | @Override 64 | public Object unwrap() { 65 | return uuid; 66 | } 67 | 68 | @Override 69 | public void sendMessage(ComponentLike message) { 70 | 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /pathfinder-test-utils/src/main/java/de/cubbossa/pathfinder/TestVisualizer.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.misc.PathPlayer; 5 | import de.cubbossa.pathfinder.navigation.UpdatingPath; 6 | import de.cubbossa.pathfinder.node.Node; 7 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizer; 8 | import java.util.List; 9 | import java.util.logging.Logger; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | 13 | public class TestVisualizer extends AbstractVisualizer { 14 | 15 | public TestVisualizer(NamespacedKey key) { 16 | super(key); 17 | } 18 | 19 | @Override 20 | public Class getTargetType() { 21 | return Logger.class; 22 | } 23 | 24 | @Override 25 | public View createView(UpdatingPath nodes, PathPlayer player) { 26 | return new View(player, nodes); 27 | } 28 | 29 | @Override 30 | public boolean equals(Object obj) { 31 | return obj instanceof TestVisualizer visualizer && getKey().equals(visualizer.getKey()); 32 | } 33 | 34 | @Getter 35 | @Setter 36 | public class View extends AbstractVisualizer.AbstractView { 37 | 38 | public View(PathPlayer player, UpdatingPath nodes) { 39 | super(player, nodes); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /pathfinder-test-utils/src/main/java/de/cubbossa/pathfinder/TestVisualizerType.java: -------------------------------------------------------------------------------- 1 | package de.cubbossa.pathfinder; 2 | 3 | import de.cubbossa.pathfinder.misc.NamespacedKey; 4 | import de.cubbossa.pathfinder.visualizer.VisualizerType; 5 | import de.cubbossa.pathfinder.visualizer.AbstractVisualizerType; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import org.pf4j.Extension; 9 | 10 | @Extension(points = VisualizerType.class) 11 | public class TestVisualizerType extends AbstractVisualizerType { 12 | 13 | public TestVisualizerType() { 14 | super(AbstractPathFinder.pathfinder("particle")); 15 | } 16 | 17 | @Override 18 | public TestVisualizer createVisualizerInstance(NamespacedKey key) { 19 | return new TestVisualizer(key); 20 | } 21 | 22 | @Override 23 | public Map serialize(TestVisualizer visualizer) { 24 | return new HashMap<>(); 25 | } 26 | 27 | @Override 28 | public void deserialize(TestVisualizer visualizer, Map values) { 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("org.gradle.toolchains.foojay-resolver-convention") version ("0.4.0") 3 | } 4 | 5 | rootProject.name = "pathfinder" 6 | 7 | sequenceOf( 8 | "api", 9 | "citizens", 10 | "core", 11 | "bukkit", 12 | "graph", 13 | "editmode", 14 | "papi", 15 | "quests-module", 16 | "scripted-visualizer", 17 | ).forEach { 18 | val name = "${rootProject.name}-$it" 19 | include(name) 20 | project(":$name").projectDir = file(name) 21 | } 22 | include("pathfinder-test-utils") 23 | --------------------------------------------------------------------------------