├── .editorconfig ├── .gitbook.yaml ├── .github ├── FUNDING.yml └── workflows │ ├── build-publish.yml │ └── gradle-wrapper-validation.yml ├── .gitignore ├── .gitlab-ci.yml ├── LICENSE ├── LICENSE_HEADER ├── README.md ├── api ├── build.gradle.kts └── src │ ├── main │ └── java │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ ├── EngineBuilderService.java │ │ ├── PermissionsEngine.java │ │ ├── PermissionsEngineBuilder.java │ │ ├── context │ │ ├── ContextDefinition.java │ │ ├── ContextDefinitionProvider.java │ │ ├── ContextInheritance.java │ │ ├── ContextValue.java │ │ ├── EnumContextDefinition.java │ │ └── SimpleContextDefinition.java │ │ ├── datastore │ │ ├── ConversionResult.java │ │ ├── DataStore.java │ │ ├── DataStoreContext.java │ │ ├── DataStoreFactories.java │ │ ├── DataStoreFactory.java │ │ └── ProtoDataStore.java │ │ ├── exception │ │ ├── ErrorReport.java │ │ ├── PEBKACException.java │ │ ├── PermissionsException.java │ │ └── PermissionsLoadingException.java │ │ ├── logging │ │ ├── FormattedLogger.java │ │ └── PermissionCheckNotifier.java │ │ ├── package-info.java │ │ ├── query │ │ └── PermissionsQuery.java │ │ ├── rank │ │ ├── RankLadder.java │ │ └── RankLadderCollection.java │ │ ├── subject │ │ ├── CalculatedSubject.java │ │ ├── ImmutableSubjectData.java │ │ ├── InvalidIdentifierException.java │ │ ├── Segment.java │ │ ├── SubjectDataCache.java │ │ ├── SubjectRef.java │ │ ├── SubjectType.java │ │ └── SubjectTypeCollection.java │ │ └── util │ │ ├── Change.java │ │ ├── ImmutablesStyle.java │ │ ├── NodeTree.java │ │ └── TranslatableProvider.java │ └── test │ └── java │ └── ca │ └── stellardrift │ └── permissionsex │ └── util │ └── NodeTreeTest.java ├── build.gradle.kts ├── buildSrc ├── build.gradle.kts └── src │ └── main │ └── kotlin │ ├── ArchiveAllowedClasses.kt │ ├── Dependencies.kt │ ├── PexPlatformExtension.kt │ ├── pex-component.gradle.kts │ └── pex-platform.gradle.kts ├── core ├── build.gradle.kts └── src │ ├── main │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── impl │ │ │ ├── PermissionsEx.java │ │ │ ├── PermissionsExBuilder.java │ │ │ ├── backend │ │ │ ├── AbstractDataStore.java │ │ │ ├── file │ │ │ │ ├── FileDataStore.java │ │ │ │ ├── FileSubjectData.java │ │ │ │ └── SchemaMigrations.java │ │ │ └── memory │ │ │ │ ├── MemoryContextInheritance.java │ │ │ │ ├── MemoryDataStore.java │ │ │ │ └── MemorySubjectData.java │ │ │ ├── config │ │ │ ├── ConfigTransformations.java │ │ │ ├── EmptyPlatformConfiguration.java │ │ │ ├── FilePermissionsExConfiguration.java │ │ │ ├── PCollectionSerializer.java │ │ │ ├── PMapSerializer.java │ │ │ ├── PermissionsExConfiguration.java │ │ │ ├── ProtoDataStoreSerializer.java │ │ │ ├── SubjectRefSerializer.java │ │ │ └── SupplierSerializer.java │ │ │ ├── context │ │ │ ├── IpSetContextDefinition.java │ │ │ ├── PEXContextDefinition.java │ │ │ ├── ServerTagContextDefinition.java │ │ │ ├── TimeContextDefinition.java │ │ │ └── TimeContextParser.java │ │ │ ├── logging │ │ │ ├── DebugPermissionCheckNotifier.java │ │ │ ├── RecordingPermissionCheckNotifier.java │ │ │ └── WrappingFormattedLogger.java │ │ │ ├── package-info.java │ │ │ ├── rank │ │ │ ├── AbstractRankLadder.java │ │ │ ├── FixedRankLadder.java │ │ │ └── RankLadderCache.java │ │ │ ├── subject │ │ │ ├── BakedSubjectData.java │ │ │ ├── CalculatedSubjectImpl.java │ │ │ ├── InheritanceSubjectDataBaker.java │ │ │ ├── LazySubjectRef.java │ │ │ ├── SubjectDataBaker.java │ │ │ ├── SubjectDataCacheImpl.java │ │ │ ├── SubjectTypeCollectionImpl.java │ │ │ └── ToDataSubjectRefImpl.java │ │ │ └── util │ │ │ ├── CacheListenerHolder.java │ │ │ ├── CachingValue.java │ │ │ ├── IpSet.java │ │ │ ├── PCollections.java │ │ │ └── Util.java │ ├── messages │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── impl │ │ │ ├── backend │ │ │ ├── file │ │ │ │ └── messages.properties │ │ │ └── messages.properties │ │ │ ├── commands │ │ │ └── parse │ │ │ │ └── messages.properties │ │ │ ├── config │ │ │ └── messages.properties │ │ │ ├── logging │ │ │ └── messages.properties │ │ │ ├── messages.properties │ │ │ ├── rank │ │ │ └── messages.properties │ │ │ ├── subject │ │ │ └── messages.properties │ │ │ └── util │ │ │ └── glob │ │ │ └── globMessages.properties │ └── resources │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── impl │ │ └── config │ │ └── default.conf │ ├── test │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── impl │ │ │ ├── TranslatableProviderClasspathTest.java │ │ │ ├── backend │ │ │ └── file │ │ │ │ └── SchemaMigrationsTest.java │ │ │ ├── config │ │ │ └── DefaultConfigTest.java │ │ │ ├── data │ │ │ ├── CacheListenerHolderTest.java │ │ │ └── SubjectDataBakerTest.java │ │ │ └── util │ │ │ └── IpSetTest.java │ └── resources │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── impl │ │ └── backend │ │ └── file │ │ ├── test0to1.post.yml │ │ ├── test0to1.pre.yml │ │ ├── test1to2.post.json │ │ ├── test1to2.pre.yml │ │ ├── test2to3.post.json │ │ ├── test2to3.pre.json │ │ ├── test3to4.post.json │ │ └── test3to4.pre.json │ └── testFixtures │ └── java │ └── ca │ └── stellardrift │ └── permissionsex │ └── test │ ├── EmptyTestConfiguration.java │ └── PermissionsExTest.java ├── datastore ├── conversion │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── datastore │ │ │ └── conversion │ │ │ ├── ReadOnlyDataStore.java │ │ │ ├── ReadOnlySegment.java │ │ │ ├── ReadOnlySubjectData.java │ │ │ └── ultraperms │ │ │ └── UltraPermissionsFile.java │ │ ├── kotlin │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── datastore │ │ │ └── conversion │ │ │ ├── OpsDataStore.kt │ │ │ ├── groupmanager │ │ │ ├── EntityType.kt │ │ │ ├── GroupManagerContextInheritance.kt │ │ │ ├── GroupManagerDataStore.kt │ │ │ └── GroupManagerSubjectData.kt │ │ │ ├── luckperms │ │ │ ├── File.kt │ │ │ ├── LuckPermsConversionProvider.kt │ │ │ └── LuckPermsSqlDataStore.kt │ │ │ └── ultraperms │ │ │ └── UltraPermissionsDataStore.kt │ │ └── messages │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── datastore │ │ └── conversion │ │ ├── groupmanager │ │ └── messages.properties │ │ ├── luckperms │ │ └── messages.properties │ │ └── messages.properties ├── file │ └── build.gradle.kts └── sql │ ├── build.gradle.kts │ └── src │ ├── main │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── datastore │ │ │ └── sql │ │ │ ├── CheckedBiConsumer.java │ │ │ ├── SchemaMigrations.java │ │ │ ├── SqlConstants.java │ │ │ ├── SqlContextInheritance.java │ │ │ ├── SqlDao.java │ │ │ ├── SqlDataStore.java │ │ │ ├── SqlRankLadder.java │ │ │ ├── SqlSegment.java │ │ │ ├── SqlSubjectData.java │ │ │ ├── SqlSubjectRef.java │ │ │ ├── dao │ │ │ ├── H2SqlDao.java │ │ │ ├── LegacyDao.java │ │ │ ├── LegacyMigration.java │ │ │ ├── MySqlDao.java │ │ │ ├── PCollectionsCollectorFactory.java │ │ │ ├── PexJdbiPlugin.java │ │ │ └── SchemaMigration.java │ │ │ └── package-info.java │ ├── messages │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── datastore │ │ │ └── sql │ │ │ └── messages.properties │ └── resources │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── datastore │ │ └── sql │ │ └── deploy │ │ ├── h2.sql │ │ ├── mysql.sql │ │ └── postgresql.sql │ └── test │ ├── java │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── datastore │ │ └── sql │ │ ├── SchemaMigrationsTest.java │ │ └── SqlDaoTest.java │ └── resources │ └── ca │ └── stellardrift │ └── permissionsex │ └── datastore │ └── sql │ └── 2to3.old.sql ├── doc ├── 2.0-home.md ├── SUMMARY.md ├── components-in-detail │ ├── README.md │ ├── command.md │ ├── data-stores.md │ ├── defaults-and-fallbacks.md │ └── subject.md ├── contributing │ ├── README.md │ ├── localization.md │ └── style-guide.md ├── learning-v2-from-other-plugins-and-v1 │ ├── README.md │ ├── changes-in-2.0.md │ └── command-equivalency.md ├── platforms │ ├── README.md │ ├── bukkit.md │ ├── bungeecord.md │ ├── fabric.md │ ├── sponge.md │ └── velocity.md └── tutorial.md ├── etc ├── build-accountsclient.sh ├── discord-embeds │ └── pex2.json ├── logo.afdesign ├── logos │ ├── 200x200.png │ └── 50x50.png ├── messages-template.java.tmpl └── permissions-schema.json ├── gradle.properties ├── gradle ├── gradle.nix └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── impl-blocks ├── glob │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ ├── antlr │ │ │ └── ca │ │ │ │ └── stellardrift │ │ │ │ └── permissionsex │ │ │ │ └── util │ │ │ │ └── glob │ │ │ │ └── parser │ │ │ │ └── Glob.g4 │ │ └── java │ │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── util │ │ │ └── glob │ │ │ ├── CharsNode.java │ │ │ ├── GlobNode.java │ │ │ ├── GlobParseException.java │ │ │ ├── GlobVisitor.java │ │ │ ├── Globs.java │ │ │ ├── OrNode.java │ │ │ ├── SequenceNode.java │ │ │ ├── UnitNode.java │ │ │ └── package-info.java │ │ └── test │ │ └── java │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── util │ │ └── glob │ │ └── GlobTest.java ├── hikari-config │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── sql │ │ └── hikari │ │ └── Hikari.java ├── legacy │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── legacy │ │ │ └── LegacyConversions.java │ │ └── test │ │ └── java │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── legacy │ │ └── LegacyConversionsTest.java ├── minecraft │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ ├── java │ │ │ └── ca │ │ │ │ └── stellardrift │ │ │ │ └── permissionsex │ │ │ │ └── minecraft │ │ │ │ ├── BaseDirectoryScope.java │ │ │ │ ├── BrigadierRegistration.java │ │ │ │ ├── MinecraftPermissionsEx.java │ │ │ │ ├── command │ │ │ │ ├── ButtonType.java │ │ │ │ ├── CallbackController.java │ │ │ │ ├── CommandException.java │ │ │ │ ├── CommandPermissionException.java │ │ │ │ ├── CommandRegistrationContext.java │ │ │ │ ├── Commander.java │ │ │ │ ├── Elements.java │ │ │ │ ├── Formats.java │ │ │ │ ├── MessageFormatter.java │ │ │ │ ├── PEXCommandPreprocessor.java │ │ │ │ ├── Permission.java │ │ │ │ ├── argument │ │ │ │ │ ├── ContextValueParser.java │ │ │ │ │ ├── OptionValueParser.java │ │ │ │ │ ├── Parsers.java │ │ │ │ │ ├── PatternParser.java │ │ │ │ │ ├── PermissionValueParser.java │ │ │ │ │ ├── RankLadderParser.java │ │ │ │ │ ├── SubjectIdentifierParser.java │ │ │ │ │ └── SubjectTypeParser.java │ │ │ │ └── definition │ │ │ │ │ ├── DeleteSubcommand.java │ │ │ │ │ ├── InfoSubcommand.java │ │ │ │ │ ├── OptionSubcommand.java │ │ │ │ │ ├── ParentSubcommand.java │ │ │ │ │ ├── PermissionsExCommand.java │ │ │ │ │ ├── PermissionsSubcommands.java │ │ │ │ │ ├── RankingCommands.java │ │ │ │ │ └── SubjectRefProvider.java │ │ │ │ └── profile │ │ │ │ ├── MinecraftProfile.java │ │ │ │ ├── ProfileApiResolver.java │ │ │ │ ├── ProfileApiResolverImpl.java │ │ │ │ └── package-info.java │ │ └── messages │ │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── minecraft │ │ │ ├── command │ │ │ ├── argument │ │ │ │ └── messages.properties │ │ │ ├── definition │ │ │ │ └── messages.properties │ │ │ └── messages.properties │ │ │ └── messages.properties │ │ └── test │ │ └── java │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── minecraft │ │ └── profile │ │ └── ProfileTest.java └── proxy-common │ ├── build.gradle.kts │ └── src │ └── main │ └── java │ └── ca │ └── stellardrift │ └── permissionsex │ └── proxycommon │ ├── ProxyCommon.java │ └── ProxyContextDefinition.java ├── platform ├── bukkit │ ├── LICENSE │ ├── LICENSE_HEADER │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── bukkit │ │ │ ├── BukkitCommander.java │ │ │ ├── BukkitConfiguration.java │ │ │ ├── BukkitContexts.java │ │ │ ├── BukkitMessageFormatter.java │ │ │ ├── CraftBukkitInterface.java │ │ │ ├── FieldReplacer.java │ │ │ ├── PEXPermissible.java │ │ │ ├── PEXPermissionAttachment.java │ │ │ ├── PEXPermissionSubscriptionMap.java │ │ │ ├── PEXVault.java │ │ │ ├── PEXVaultChat.java │ │ │ ├── PermissibleInjector.java │ │ │ ├── PermissionList.java │ │ │ ├── PermissionsExPlugin.java │ │ │ └── PluginIntegrations.java │ │ └── messages │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── bukkit │ │ └── messages.properties ├── bungee │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── bungee │ │ │ ├── BungeeCommander.java │ │ │ ├── BungeeContexts.java │ │ │ ├── BungeeMessageFormatter.java │ │ │ └── PermissionsExPlugin.java │ │ └── messages │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── bungee │ │ └── messages.properties ├── fabric │ ├── build.gradle.kts │ └── src │ │ ├── accessor │ │ ├── java │ │ │ └── ca │ │ │ │ └── stellardrift │ │ │ │ └── permissionsex │ │ │ │ └── fabric │ │ │ │ └── mixin │ │ │ │ ├── HandshakeC2SPacketAccess.java │ │ │ │ └── ServerCommandSourceAccess.java │ │ └── resources │ │ │ └── permissionsex.accessor.mixins.json │ │ ├── main │ │ ├── java │ │ │ └── ca │ │ │ │ └── stellardrift │ │ │ │ └── permissionsex │ │ │ │ └── fabric │ │ │ │ ├── FabricContexts.java │ │ │ │ ├── FabricPermissionsEx.java │ │ │ │ ├── MinecraftPermissions.java │ │ │ │ └── impl │ │ │ │ ├── FabricCommander.java │ │ │ │ ├── FabricMessageFormatter.java │ │ │ │ ├── FabricPermissionsExImpl.java │ │ │ │ ├── FabricSubjectTypes.java │ │ │ │ ├── Functions.java │ │ │ │ ├── PreLaunchHacks.java │ │ │ │ ├── PreLaunchInjector.java │ │ │ │ ├── RedirectTargets.java │ │ │ │ ├── WitherMutatorInjectionPoint.java │ │ │ │ ├── bridge │ │ │ │ ├── ClientConnectionBridge.java │ │ │ │ ├── PermissionCommandSourceBridge.java │ │ │ │ └── ServerCommandSourceBridge.java │ │ │ │ ├── commands │ │ │ │ ├── FabricCommandContextKeys.java │ │ │ │ ├── FabricCommandManager.java │ │ │ │ ├── FabricCommandPreprocessor.java │ │ │ │ ├── FabricCommandRegistrationHandler.java │ │ │ │ ├── FabricExecutor.java │ │ │ │ └── FabricServerCommandManager.java │ │ │ │ ├── context │ │ │ │ ├── CommandSourceContextDefinition.java │ │ │ │ └── IdentifierContextDefinition.java │ │ │ │ └── package-info.java │ │ ├── messages │ │ │ └── ca │ │ │ │ └── stellardrift │ │ │ │ └── permissionsex │ │ │ │ └── fabric │ │ │ │ ├── impl │ │ │ │ └── messages.properties │ │ │ │ └── messages.properties │ │ └── resources │ │ │ └── fabric.mod.yml │ │ └── mixin │ │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── fabric │ │ │ └── mixin │ │ │ ├── check │ │ │ ├── ArgumentBuilderMixin.java │ │ │ ├── BlockItemMixin.java │ │ │ ├── CommandBlockExecutorMixin.java │ │ │ ├── CommandBlockItemMixin.java │ │ │ ├── DebugStickItemMixin.java │ │ │ ├── DedicatedPlayerManagerMixin.java │ │ │ ├── DedicatedServerMixin.java │ │ │ ├── EntityArgumentTypeMixin.java │ │ │ ├── EntitySelectorMixin.java │ │ │ ├── EntityTypeMixin.java │ │ │ ├── MessageArgumentTypeMixin.java │ │ │ ├── PlayerManagerMixin.java │ │ │ ├── ServerCommandSourceMixin.java │ │ │ ├── ServerPlayNetworkHandlerMixin.java │ │ │ ├── ServerPlayerEntityMixin.java │ │ │ ├── ServerPlayerInteractionManagerMixin.java │ │ │ └── StructureBlockEntityMixin.java │ │ │ ├── lifecycle │ │ │ ├── ClientConnectionMixin.java │ │ │ ├── GameProfileMixin.java │ │ │ ├── MinecraftClientMixin.java │ │ │ ├── MinecraftDedicatedServerMixin.java │ │ │ └── ServerHandshakeNetworkHandlerMixin.java │ │ │ └── source │ │ │ ├── CommandBlockExecutorMixin.java │ │ │ ├── CommandFunctionFunctionElementMixin.java │ │ │ ├── CommandFunctionManagerMixin.java │ │ │ ├── FunctionLoaderMixin.java │ │ │ ├── RconCommandOutputMixin.java │ │ │ ├── ServerCommandSourceMixin.java │ │ │ └── ServerPlayerEntityMixin.java │ │ └── resources │ │ └── permissionsex.mixins.json ├── sponge │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── java │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── sponge │ │ │ ├── Contexts.java │ │ │ ├── PEXPermissionDescription.java │ │ │ ├── PEXSubject.java │ │ │ ├── PEXSubjectCollection.java │ │ │ ├── PEXSubjectData.java │ │ │ ├── PEXSubjectReference.java │ │ │ ├── PermissionsExPlugin.java │ │ │ ├── PermissionsExService.java │ │ │ ├── SpongeCommander.java │ │ │ ├── SpongeMessageFormatter.java │ │ │ ├── Timings.java │ │ │ └── rank │ │ │ ├── RankLadder.java │ │ │ ├── RankingService.java │ │ │ └── package-info.java │ │ ├── messages │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── sponge │ │ │ ├── command │ │ │ └── messages.properties │ │ │ └── messages.properties │ │ ├── resources │ │ └── META-INF │ │ │ └── plugins.yml │ │ └── templates │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── sponge │ │ └── ProjectData.java ├── sponge7 │ ├── build.gradle.kts │ └── src │ │ └── main │ │ ├── kotlin │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── sponge │ │ │ ├── PEXPermissionDescription.kt │ │ │ ├── PEXSubject.kt │ │ │ ├── PEXSubjectCollection.kt │ │ │ ├── PEXSubjectData.kt │ │ │ ├── PEXSubjectReference.kt │ │ │ ├── PermissionsExPlugin.kt │ │ │ ├── SpongeCommander.kt │ │ │ ├── Timings.kt │ │ │ └── Util.kt │ │ ├── messages │ │ └── ca │ │ │ └── stellardrift │ │ │ └── permissionsex │ │ │ └── sponge │ │ │ └── messages.properties │ │ └── templates │ │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── sponge │ │ └── PomData.kt └── velocity │ ├── build.gradle.kts │ └── src │ └── main │ ├── java │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── velocity │ │ ├── PEXPermissionFunction.java │ │ ├── PermissionsExPlugin.java │ │ ├── VelocityCommander.java │ │ ├── VelocityContexts.java │ │ ├── VelocityMessageFormatter.java │ │ └── package-info.java │ ├── messages │ └── ca │ │ └── stellardrift │ │ └── permissionsex │ │ └── velocity │ │ └── messages.properties │ └── templates │ └── ca │ └── stellardrift │ └── permissionsex │ └── velocity │ └── ProjectData.java ├── renovate.json ├── settings.gradle.kts ├── shell.nix └── src └── site └── site.xml /.gitbook.yaml: -------------------------------------------------------------------------------- 1 | root: ./doc/ 2 | 3 | structure: 4 | readme: 2.0-home.md 5 | summary: SUMMARY.md 6 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [zml2008] -------------------------------------------------------------------------------- /.github/workflows/build-publish.yml: -------------------------------------------------------------------------------- 1 | # Making changes? https://github.com/nektos/act may help you test locally 2 | 3 | name: Build And Test 4 | 5 | on: [push, pull_request] 6 | 7 | jobs: 8 | build: 9 | # Only run on PRs if the source branch is on someone else's repo 10 | if: ${{ github.event_name != 'pull_request' || github.repository != github.event.repository.full_name }} 11 | runs-on: ${{ matrix.os }} 12 | strategy: 13 | matrix: 14 | os: [ubuntu-latest, windows-latest] 15 | steps: 16 | - name: Check out 17 | uses: actions/checkout@v2 18 | - name: Setup JDK 11 19 | uses: actions/setup-java@v1 20 | with: 21 | java-version: 11 22 | - name: Cache Gradle packages 23 | uses: actions/cache@v2 24 | with: 25 | path: ~/.gradle/caches 26 | key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} 27 | restore-keys: ${{ runner.os }}-gradle 28 | - name: Build with Gradle 29 | run: ./gradlew build 30 | - name: Archive test results 31 | uses: actions/upload-artifact@v2 32 | with: 33 | name: test-results 34 | path: | 35 | build/test-results/test/ 36 | */build/test-results/test/ 37 | platform/*/build/test-results/test 38 | - name: Archive distributable plugins 39 | uses: actions/upload-artifact@v2 40 | if: ${{ runner.os == 'Linux' }} # Only upload one set of artifacts 41 | with: 42 | name: PermissionsEx (all platforms) 43 | path: build/libs/ 44 | - name: Publish to Maven 45 | if: ${{ runner.os == 'Linux' && github.event_name == 'push' && github.ref == 'refs/heads/master' }} 46 | run: ./gradlew publish 47 | env: 48 | ORG_GRADLE_PROJECT_pexUsername: ${{ secrets.REPO_USERNAME }} 49 | ORG_GRADLE_PROJECT_pexPassword: ${{ secrets.REPO_PASSWORD }} 50 | ORG_GRADLE_PROJECT_stellardriftUsername: ${{ secrets.STELLARDRIFT_REPO_USER }} 51 | ORG_GRADLE_PROJECT_stellardriftPassword: ${{ secrets.STELLARDRIFT_REPO_PASSWORD }} 52 | -------------------------------------------------------------------------------- /.github/workflows/gradle-wrapper-validation.yml: -------------------------------------------------------------------------------- 1 | name: "Validate Gradle Wrapper" 2 | on: [push, pull_request] 3 | 4 | jobs: 5 | validation: 6 | name: "Validation" 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: gradle/wrapper-validation-action@v1 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .classpath 3 | .factorypath 4 | .settings/ 5 | .vscode 6 | 7 | .gradle/ 8 | 9 | /platform/*/debug/ 10 | /platform/*/run/ 11 | build/ 12 | /bin 13 | /dist 14 | /.idea/ 15 | /PermissionsEx.iml 16 | /idea/ 17 | .DS_Store 18 | .*.swp 19 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # This is the Gradle build system for JVM applications 2 | # https://gradle.org/ 3 | # https://github.com/gradle/gradle 4 | image: gradle:jdk8 5 | 6 | # Disable the Gradle daemon for Continuous Integration servers as correctness 7 | # is usually a priority over speed in CI environments. Using a fresh 8 | # runtime for each build is more reliable since the runtime is completely 9 | # isolated from any previous builds. 10 | variables: 11 | GRADLE_OPTS: "-Dorg.gradle.daemon=false" 12 | 13 | before_script: 14 | - export GRADLE_USER_HOME=`pwd`/.gradle 15 | 16 | build: 17 | stage: build 18 | script: gradle --build-cache assemble 19 | artifacts: 20 | paths: 21 | - "build/libs/*-all.jar" 22 | cache: 23 | key: "$CI_COMMIT_REF_NAME" 24 | policy: push 25 | paths: 26 | - build 27 | - .gradle 28 | 29 | test: 30 | stage: test 31 | script: gradle check 32 | cache: 33 | key: "$CI_COMMIT_REF_NAME" 34 | policy: pull 35 | paths: 36 | - build 37 | - .gradle 38 | -------------------------------------------------------------------------------- /LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | PermissionsEx 2 | Copyright (C) zml and PermissionsEx contributors 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | -------------------------------------------------------------------------------- /api/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import ca.stellardrift.build.common.adventure 2 | import ca.stellardrift.build.common.configurate 3 | 4 | plugins { 5 | id("pex-component") 6 | } 7 | 8 | useCheckerFramework() 9 | useImmutables() 10 | 11 | dependencies { 12 | val adventureVersion: String by project 13 | val configurateVersion: String by project 14 | val pCollectionsVersion: String by project 15 | val slf4jVersion: String by project 16 | 17 | api("org.pcollections:pcollections:$pCollectionsVersion") 18 | api(adventure("api", adventureVersion)) 19 | implementation(adventure("text-serializer-plain", adventureVersion)) 20 | api(configurate("core", configurateVersion)) 21 | api("org.slf4j:slf4j-api:$slf4jVersion") 22 | } 23 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/EngineBuilderService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex; 18 | 19 | import java.util.ServiceLoader; 20 | 21 | final class EngineBuilderService { 22 | 23 | static final PermissionsEngineBuilder.Factory ACTIVE_BUILDER; 24 | 25 | static { 26 | final ServiceLoader factoryLoader = ServiceLoader.load( 27 | PermissionsEngineBuilder.Factory.class, 28 | EngineBuilderService.class.getClassLoader() 29 | ); 30 | 31 | ACTIVE_BUILDER = factoryLoader.iterator().next(); 32 | } 33 | 34 | private EngineBuilderService() { 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/context/ContextInheritance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.context; 18 | 19 | import org.checkerframework.checker.nullness.qual.Nullable; 20 | 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | /** 25 | * Holder for information about inheritance between contexts. Immutable. 26 | * 27 | * @since 2.0.0 28 | */ 29 | public interface ContextInheritance { 30 | /** 31 | * Get the parents of a specific context. 32 | * 33 | *

When this context is present in a subject's active contexts, its parents are appended 34 | * to the subject's active contexts for the purpose of data queries.

35 | * 36 | * @param context The child context 37 | * @return Any parent contexts, or an empty list 38 | * @since 2.0.0 39 | */ 40 | List> parents(ContextValue context); 41 | 42 | /** 43 | * Set the parents for a specific context. 44 | * 45 | * @param context The context to set parents in 46 | * @param parents The parents to set, or {@code null} to clear parents for the context. 47 | * @return A new context inheritance object with the updated parents 48 | * @since 2.0.0 49 | */ 50 | ContextInheritance parents(ContextValue context, @Nullable List> parents); 51 | 52 | /** 53 | * Get all parent data as a map from context to list of parent contexts. 54 | * 55 | *

The returned map is immutable.

56 | * 57 | * @return parents 58 | * @since 2.0.0 59 | */ 60 | Map, List>> allParents(); 61 | 62 | } 63 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/datastore/ConversionResult.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore; 18 | 19 | import net.kyori.adventure.text.Component; 20 | import org.immutables.value.Value; 21 | 22 | /** 23 | * A possible result of a conversion lookup. 24 | * 25 | * @since 2.0.0 26 | */ 27 | @Value.Immutable 28 | public interface ConversionResult { 29 | 30 | /** 31 | * Create a new builder for a conversion result. 32 | * 33 | * @return new builder 34 | * @since 2.0.0 35 | */ 36 | static Builder builder() { 37 | return new Builder(); 38 | } 39 | 40 | /** 41 | * A short description of the data that will be converted. 42 | * 43 | * @return conversion description 44 | * @since 2.0.0 45 | */ 46 | Component description(); 47 | 48 | /** 49 | * The data store, configured based on the discovered environment but not yet initialized. 50 | * 51 | * @return convertible data store 52 | * @since 2.0.0 53 | */ 54 | ProtoDataStore store(); 55 | 56 | /** 57 | * Builder for a conversion result. 58 | * 59 | * @since 2.0.0 60 | */ 61 | class Builder extends ConversionResultImpl.Builder { 62 | Builder() {} 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/datastore/DataStoreFactories.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore; 18 | 19 | import org.pcollections.HashTreePMap; 20 | import org.pcollections.PMap; 21 | 22 | import java.util.Locale; 23 | import java.util.ServiceLoader; 24 | 25 | import static java.util.Objects.requireNonNull; 26 | 27 | class DataStoreFactories { 28 | // service loader, needs explicitly specified ClassLoader as a workaround for Bukkit/Bungee brokenness 29 | @SuppressWarnings("rawtypes") 30 | private static final ServiceLoader LOADER = ServiceLoader.load(DataStoreFactory.class, DataStoreFactory.class.getClassLoader()); 31 | 32 | static final PMap> REGISTRY; 33 | 34 | static { 35 | PMap> factories = HashTreePMap.empty(); 36 | for (final DataStoreFactory factory : LOADER) { 37 | factories = factories.plus(requireNonNull(factory.name(), 38 | () -> "Factory in class " + factory.getClass() + " had a null name()").toLowerCase(Locale.ROOT), factory); 39 | } 40 | 41 | REGISTRY = factories; 42 | } 43 | 44 | private DataStoreFactories() { 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/exception/ErrorReport.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.exception; 18 | 19 | import org.slf4j.Logger; 20 | 21 | import java.net.URL; 22 | import java.nio.file.Path; 23 | 24 | /** 25 | * A way to collect information about the environment when an error occurs 26 | */ 27 | public interface ErrorReport { 28 | 29 | static ErrorReport.Visitor report() { 30 | throw new UnsupportedOperationException("nyi"); 31 | } 32 | 33 | ErrorReport write(final Path file); 34 | 35 | ErrorReport write(final Logger logger); 36 | 37 | void printDescription(final Logger logger); 38 | 39 | /** 40 | * Upload this error report to a paste service 41 | * @return 42 | */ 43 | URL upload(); 44 | 45 | String toString(); 46 | 47 | 48 | interface Visitor { 49 | 50 | Visitor exception(final Throwable error); 51 | 52 | Visitor description(final String description); 53 | 54 | Visitor beginSection(final String header); 55 | 56 | ListStage beginList(); 57 | 58 | Visitor endSection(); 59 | 60 | interface ListStage { 61 | ListStage element(final String element); 62 | 63 | Visitor endList(); 64 | } 65 | } 66 | 67 | 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/exception/PEBKACException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.exception; 18 | 19 | import net.kyori.adventure.text.Component; 20 | 21 | /** 22 | * This exception is thrown when an error occurs that is due to misconfiguration of 23 | * the permissions system. 24 | */ 25 | public final class PEBKACException extends PermissionsException { 26 | private static final long serialVersionUID = -3841706491554528729L; 27 | 28 | public PEBKACException(final Component message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/exception/PermissionsLoadingException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.exception; 18 | 19 | import net.kyori.adventure.text.Component; 20 | 21 | public final class PermissionsLoadingException extends PermissionsException { 22 | private static final long serialVersionUID = -3894757413277685930L; 23 | 24 | public PermissionsLoadingException(final Component message) { 25 | super(message); 26 | } 27 | 28 | public PermissionsLoadingException(final Component message, final Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | public PermissionsLoadingException(final Throwable cause) { 33 | super(/* Messages.ERROR_GENERAL_LOADING.toComponent() */ null, cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/logging/PermissionCheckNotifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.logging; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextValue; 20 | import ca.stellardrift.permissionsex.subject.SubjectRef; 21 | import org.checkerframework.checker.nullness.qual.Nullable; 22 | 23 | import java.util.List; 24 | import java.util.Map; 25 | import java.util.Set; 26 | 27 | /** 28 | * Delegate to handle notifying of permission and option checks. 29 | * 30 | * @since 2.0.0 31 | */ 32 | public interface PermissionCheckNotifier { 33 | void onPermissionCheck(SubjectRef subject, Set> contexts, String permission, int value); 34 | void onOptionCheck(SubjectRef subject, Set> contexts, String option, @Nullable String value); 35 | void onParentCheck(SubjectRef subject, Set> contexts, List> parents); 36 | } 37 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | /** 18 | * The PermissionsEx permissions engine. 19 | */ 20 | @DefaultQualifier(NonNull.class) 21 | @ImmutablesStyle 22 | package ca.stellardrift.permissionsex; 23 | 24 | import ca.stellardrift.permissionsex.util.ImmutablesStyle; 25 | import org.checkerframework.checker.nullness.qual.NonNull; 26 | import org.checkerframework.framework.qual.DefaultQualifier; -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/rank/RankLadderCollection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.rank; 18 | 19 | import org.checkerframework.checker.nullness.qual.Nullable; 20 | 21 | import java.util.concurrent.CompletableFuture; 22 | import java.util.function.Consumer; 23 | import java.util.function.UnaryOperator; 24 | import java.util.stream.Stream; 25 | 26 | public interface RankLadderCollection { 27 | 28 | CompletableFuture get(String identifier, @Nullable Consumer listener); 29 | 30 | CompletableFuture update(String identifier, UnaryOperator updateFunc); 31 | 32 | CompletableFuture has(String identifier); 33 | 34 | CompletableFuture set(String identifier, RankLadder newData); 35 | 36 | void addListener(String identifier, Consumer listener); 37 | 38 | Stream names(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/subject/InvalidIdentifierException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.subject; 18 | 19 | /** 20 | * An exception thrown when an identifier is provided that isn't valid for a subject type. 21 | * 22 | * @since 2.0.0 23 | */ 24 | public final class InvalidIdentifierException extends IllegalArgumentException { 25 | private static final long serialVersionUID = 300758874983936090L; 26 | 27 | private final String unparsedIdentifier; 28 | 29 | public InvalidIdentifierException(final String unparsedIdentifier) { 30 | super("Invalid subject identifier: " + unparsedIdentifier); 31 | 32 | this.unparsedIdentifier = unparsedIdentifier; 33 | } 34 | 35 | /** 36 | * Get the provided input that was supposed to be parsed. 37 | * 38 | * @return the original input 39 | * @since 2.0.0 40 | */ 41 | public String unparsedIdentifier() { 42 | return this.unparsedIdentifier; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/util/Change.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.util; 18 | 19 | import org.immutables.value.Value; 20 | 21 | /** 22 | * Represents a change in the value of some object. 23 | * 24 | * @param the type of object being changed 25 | * @since 2.0.0 26 | */ 27 | @Value.Immutable(builder = false) 28 | public interface Change { 29 | 30 | static Change of(final T old, final T current) { 31 | return new ChangeImpl<>(old, current); 32 | } 33 | 34 | /** 35 | * The previous value before the operation. 36 | * 37 | * @return the previous value 38 | * @since 2.0.0 39 | */ 40 | @Value.Parameter 41 | T old(); 42 | 43 | /** 44 | * The current value. 45 | * 46 | * @return the current value 47 | * @since 2.0.0 48 | */ 49 | @Value.Parameter 50 | T current(); 51 | 52 | /** 53 | * Get whether any change actually occurred. 54 | * 55 | * @return if a change occurred 56 | * @since 2.0.0 57 | */ 58 | default boolean changed() { 59 | return old() != current(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /api/src/main/java/ca/stellardrift/permissionsex/util/ImmutablesStyle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.util; 18 | 19 | import org.immutables.value.Value; 20 | 21 | import java.lang.annotation.ElementType; 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.RetentionPolicy; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Supertype for compile-time generated data 28 | */ 29 | @Target({ElementType.PACKAGE, ElementType.TYPE}) 30 | @Retention(RetentionPolicy.CLASS) 31 | @Value.Style( 32 | with = "*", 33 | of = "new", 34 | typeImmutable = "*Impl", 35 | overshadowImplementation = true, 36 | visibility = Value.Style.ImplementationVisibility.PACKAGE, 37 | deferCollectionAllocation = true, 38 | jdkOnly = true 39 | ) 40 | public @interface ImmutablesStyle { 41 | 42 | } 43 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.github.ben-manes.versions") version "0.38.0" 3 | } 4 | 5 | val pexDescription: String by project 6 | group = "ca.stellardrift.permissionsex" 7 | version = "2.0-SNAPSHOT" 8 | description = pexDescription 9 | 10 | val collectExcludes = ext["buildExcludes"].toString().split(',').toSet() 11 | 12 | val collectImplementationArtifacts by tasks.registering(Copy::class) { 13 | val config = configurations.detachedConfiguration( 14 | *subprojects 15 | .filter { it.name !in collectExcludes && it.path.contains("platform:")} 16 | .map { dependencies.project(it.path, configuration = "shadow") } 17 | .toTypedArray() 18 | ) 19 | config.isTransitive = false 20 | 21 | from(config) 22 | rename("(.+)-all(.+)", "PermissionsEx $1$2") 23 | into("$buildDir/libs") 24 | 25 | doFirst { 26 | if (destinationDir.exists()) { 27 | destinationDir.deleteRecursively() 28 | } 29 | } 30 | 31 | } 32 | 33 | tasks.register("build") { 34 | dependsOn(collectImplementationArtifacts) 35 | group = "build" 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/Dependencies.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.api.Project 2 | import org.gradle.api.artifacts.Dependency 3 | import org.gradle.api.plugins.JavaPlugin 4 | import org.gradle.kotlin.dsl.dependencies 5 | import org.gradle.kotlin.dsl.provideDelegate 6 | 7 | fun Project.useImmutables() { 8 | val immutablesGroup = "org.immutables" 9 | val immutablesVersion: String by this 10 | 11 | dependencies { 12 | add(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME, "$immutablesGroup:value:$immutablesVersion") 13 | add(JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME, "$immutablesGroup:value:$immutablesVersion:annotations") 14 | add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "$immutablesGroup:builder:$immutablesVersion") 15 | } 16 | } 17 | 18 | fun Project.useCheckerFramework(): Dependency? { 19 | val checkerVersion: String by this 20 | 21 | return dependencies.add(JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME, "org.checkerframework:checker-qual:$checkerVersion") 22 | } 23 | 24 | fun Project.useAutoService() { 25 | val autoServiceGroup = "com.google.auto.service" 26 | val autoServiceVersion: String by this 27 | 28 | dependencies { 29 | add(JavaPlugin.ANNOTATION_PROCESSOR_CONFIGURATION_NAME, "$autoServiceGroup:auto-service:$autoServiceVersion") 30 | add(JavaPlugin.COMPILE_ONLY_API_CONFIGURATION_NAME, "$autoServiceGroup:auto-service-annotations:$autoServiceVersion") 31 | } 32 | } -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/PexPlatformExtension.kt: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | import org.gradle.api.Project 3 | import org.gradle.api.provider.Provider 4 | import org.gradle.api.tasks.TaskProvider 5 | import org.gradle.jvm.toolchain.JavaLanguageVersion 6 | import org.gradle.jvm.toolchain.JavaLauncher 7 | import org.gradle.jvm.toolchain.JavaToolchainService 8 | import org.gradle.kotlin.dsl.getByType 9 | import javax.inject.Inject 10 | 11 | abstract class PexPlatformExtension @Inject constructor(val relocationRoot: String, val task: TaskProvider, val project: Project) { 12 | 13 | @get:Inject 14 | abstract val toolchains: JavaToolchainService 15 | 16 | fun relocate(vararg relocations: String, keepElements: Int = 1) { 17 | this.task.configure { 18 | relocations.forEach { 19 | val shortenedPackageName = it.split('.') 20 | .takeLast(keepElements) 21 | .joinToString(".") 22 | relocate(it, "$relocationRoot.$shortenedPackageName") 23 | } 24 | } 25 | } 26 | 27 | fun excludeChecker() { 28 | this.task.configure { 29 | exclude("org/checkerframework/**") 30 | } 31 | } 32 | 33 | fun developmentRuntime(): Provider { 34 | return project.extensions.getByType(JavaToolchainService::class).launcherFor { 35 | languageVersion.set(JavaLanguageVersion.of(project.findProperty("developmentRuntime") as String)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /buildSrc/src/main/kotlin/pex-platform.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | plugins { 4 | id("pex-component") 5 | id("com.github.johnrengelman.shadow") 6 | } 7 | 8 | tasks { 9 | 10 | javadoc { 11 | enabled = false 12 | } 13 | 14 | jar { 15 | manifest.attributes( 16 | "Specification-Title" to rootProject.name, 17 | "Specification-Version" to project.version, 18 | "Implementation-Title" to "${rootProject.name} ${project.name.capitalize()}", 19 | "Implementation-Version" to "${project.version}${project.findProperty("pexSuffix") ?: ""}" 20 | ) 21 | } 22 | } 23 | 24 | val pexRelocationRoot: String by project 25 | val shadowJar = tasks.named("shadowJar", ShadowJar::class) { 26 | inputs.property("pexRelocationRoot", pexRelocationRoot) 27 | 28 | // Caffeine reflectively accesses some of its cache implementations, so it can't be minimized 29 | minimize { 30 | exclude(dependency("com.github.ben-manes.caffeine:.*:.*")) 31 | exclude(project(":datastore:sql")) 32 | } 33 | 34 | // Don't shade compile-only annotations, or other project's module info files 35 | exclude("**/module-info.class") 36 | 37 | // Process service files 38 | mergeServiceFiles() 39 | } 40 | 41 | val validateShadowing by tasks.registering(ArchiveAllowedClasses::class) { 42 | input.from(shadowJar) 43 | allowedPackages.add("ca.stellardrift") 44 | } 45 | 46 | tasks.check { 47 | dependsOn(validateShadowing) 48 | } 49 | 50 | tasks.assemble { 51 | dependsOn(shadowJar) 52 | } 53 | 54 | extensions.create("pexPlatform", PexPlatformExtension::class, pexRelocationRoot, shadowJar, project) 55 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/config/EmptyPlatformConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.config; 18 | 19 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 20 | 21 | /** 22 | * A dummy object that provides an empty platform configuration for implementations of PermissionsEx with no platform-specific options 23 | */ 24 | @ConfigSerializable 25 | public class EmptyPlatformConfiguration { 26 | } 27 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/config/PermissionsExConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.config; 18 | 19 | import ca.stellardrift.permissionsex.datastore.ProtoDataStore; 20 | import ca.stellardrift.permissionsex.exception.PEBKACException; 21 | import org.checkerframework.checker.nullness.qual.Nullable; 22 | 23 | import java.io.IOException; 24 | import java.util.List; 25 | 26 | /** 27 | * Configuration for PermissionsEx 28 | */ 29 | public interface PermissionsExConfiguration { 30 | @Nullable ProtoDataStore getDataStore(String name); 31 | 32 | ProtoDataStore getDefaultDataStore(); 33 | 34 | boolean isDebugEnabled(); 35 | 36 | List getServerTags(); 37 | 38 | void validate() throws PEBKACException; 39 | 40 | /** 41 | * Get a configuration containing options only applicable to one implementation of PermissionsEx 42 | * 43 | * @return The configuration object 44 | */ 45 | PlatformType getPlatformConfig(); 46 | 47 | PermissionsExConfiguration reload() throws IOException; 48 | 49 | default void save() throws IOException {} 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/context/IpSetContextDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.context; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextDefinition; 20 | import ca.stellardrift.permissionsex.impl.util.IpSet; 21 | import org.checkerframework.checker.nullness.qual.Nullable; 22 | 23 | /** 24 | * An abstract context definiton for context types that use a {@link IpSet} 25 | */ 26 | public abstract class IpSetContextDefinition extends ContextDefinition { 27 | 28 | protected IpSetContextDefinition(final String name) { 29 | super(name); 30 | } 31 | 32 | @Override 33 | public final String serialize(final IpSet canonicalValue) { 34 | return canonicalValue.toString(); 35 | } 36 | 37 | @Override 38 | public @Nullable IpSet deserialize(final String userValue) { 39 | try { 40 | return IpSet.fromCidr(userValue); 41 | } catch (final IllegalArgumentException ex) { 42 | return null; 43 | } 44 | } 45 | 46 | @Override 47 | public boolean matches(final IpSet ownVal, final IpSet testVal) { 48 | return ownVal.contains(testVal); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/context/PEXContextDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.context; 18 | 19 | import ca.stellardrift.permissionsex.impl.config.PermissionsExConfiguration; 20 | import ca.stellardrift.permissionsex.context.ContextDefinition; 21 | 22 | public abstract class PEXContextDefinition extends ContextDefinition { 23 | 24 | PEXContextDefinition(final String name) { 25 | super(name); 26 | } 27 | 28 | public abstract void update(PermissionsExConfiguration config); 29 | } 30 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | @ImmutablesStyle 18 | package ca.stellardrift.permissionsex.impl; 19 | 20 | import ca.stellardrift.permissionsex.util.ImmutablesStyle; -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/rank/FixedRankLadder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.rank; 18 | 19 | import ca.stellardrift.permissionsex.impl.util.PCollections; 20 | import ca.stellardrift.permissionsex.rank.RankLadder; 21 | import ca.stellardrift.permissionsex.subject.SubjectRef; 22 | import org.pcollections.PVector; 23 | import org.pcollections.TreePVector; 24 | 25 | import java.util.List; 26 | 27 | import static java.util.Map.Entry; 28 | 29 | public class FixedRankLadder extends AbstractRankLadder { 30 | private final PVector> ranks; 31 | 32 | public FixedRankLadder(String name, List> ranks) { 33 | super(name); 34 | this.ranks = PCollections.asVector(ranks); 35 | } 36 | 37 | @Override 38 | public PVector> ranks() { 39 | return this.ranks; 40 | } 41 | 42 | @Override 43 | protected RankLadder newWithRanks(final PVector> ents) { 44 | return new FixedRankLadder(name(), ents); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/subject/SubjectDataBaker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.subject; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextValue; 20 | 21 | import java.util.Set; 22 | import java.util.concurrent.CompletableFuture; 23 | 24 | public interface SubjectDataBaker { 25 | CompletableFuture bake(CalculatedSubjectImpl data, Set> activeContexts); 26 | 27 | static SubjectDataBaker inheritance() { 28 | return InheritanceSubjectDataBaker.INSTANCE; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/ca/stellardrift/permissionsex/impl/util/CachingValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.util; 18 | 19 | import java.util.function.LongSupplier; 20 | import java.util.function.Supplier; 21 | 22 | import static java.util.Objects.requireNonNull; 23 | 24 | public final class CachingValue { 25 | private final LongSupplier currentTime; 26 | private final long maxDelta; 27 | private final Supplier updater; 28 | private volatile long lastTime; 29 | private volatile V lastValue; 30 | 31 | /** 32 | * Create a value that is cached for a certain amount of time. 33 | */ 34 | public static CachingValue timeBased(final long maxDelta, final Supplier updateFunc) { 35 | return new CachingValue<>(System::currentTimeMillis, maxDelta, updateFunc); 36 | } 37 | 38 | public CachingValue(final LongSupplier currentTime, final long maxDelta, final Supplier updater) { 39 | requireNonNull(currentTime, "currentTime"); 40 | requireNonNull(updater, "updater"); 41 | this.currentTime = currentTime; 42 | this.maxDelta = maxDelta; 43 | this.updater = updater; 44 | this.refresh(); 45 | } 46 | 47 | public V get() { 48 | final long now = currentTime.getAsLong(); 49 | if ((now - this.lastTime) > this.maxDelta) { 50 | this.lastValue = updater.get(); 51 | this.lastTime = now; 52 | } 53 | return this.lastValue; 54 | } 55 | 56 | public void refresh() { 57 | this.lastValue = this.updater.get(); 58 | this.lastTime = currentTime.getAsLong(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/backend/file/messages.properties: -------------------------------------------------------------------------------- 1 | file.conversion.illegal-char=The permission at {0} contains a now-illegal character '*' 2 | file.load.context=Each context section must be of map type! Check that no duplicate nesting has occurred. 3 | file.error.autoreload=Error while {0} permissions configuration: {1}. Old configuration will continue to be used until the error is corrected. 4 | file.error.subject-autoreload=During an automatic reload of the permissions storage, {0} {1} failed to load: 5 | file.reload.auto=Automatically reloaded {0} based on a change made outside of PEX 6 | file.error.legacy-migration=While loading legacy {0} permissions from {1} 7 | file.error.load=While loading permissions file from {0} 8 | file.error.initial-data=Error creating initial data for file backend 9 | file.error.schema-migration-save=While performing version upgrade 10 | file.schema-migration.success={0} schema version updated from {1} to {2} 11 | file.error.deserialize-subject=While deserializing subject data for {0}: 12 | 13 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/backend/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | datastore.move.error=Destination subject already existed or source subject did not! 19 | datastore.error.serialize=Error while serializing data store {0} 20 | datastore.error.deserialize=Error while deserializing data store {0} 21 | 22 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/commands/parse/messages.properties: -------------------------------------------------------------------------------- 1 | error.children.unknown=Input command {0} was not a valid subcommand! 2 | error.children.state=Invalid subcommand state -- only one value must be provided for child arg {0} 3 | error.arguments.notenough=Not enough arguments! 4 | error.arguments.toomany=Too many arguments! 5 | error.permission=You do not have permission to use this command! 6 | error.general=Error occurred while executing command: {0} 7 | 8 | error.parse.bufferOverrun=Buffer overrun while parsing args 9 | error.parse.notquote=Actual next character '{0}' did not match expected quotation character '{1}' 10 | error.parse.unterminated-quoted=Unterminated quoted string found 11 | 12 | usage=Usage: {0} 13 | 14 | choices.error.invalid=Argument was not a valid choice. Valid choices: {0} 15 | 16 | integer.error.format=Expected an integer, but input '{0}' was not 17 | uuid.error.format=Expected input '{0}' to be a UUID 18 | enum.error.invalid=Enum value '{0}' is not a valid value 19 | literal.error.invalid=Argument {0} did not match expected next argument {0} 20 | 21 | flag.error.unknownlong=Unknown long flag {0} specified 22 | flag.error.unknownshort=Unknown short flag {0} specified 23 | 24 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/config/messages.properties: -------------------------------------------------------------------------------- 1 | config.error.no-backends=No backends defined 2 | config.error.no-default=Default backend is not set! 3 | config.error.invalid-default=Default backend {0} is not an available backend! Choices are: {1} 4 | config.error.default-config=Default config file is not present in jar! 5 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/logging/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | check.permission=Permission {0} checked in {1} for {2}: {3} 19 | check.option=Option {0} checked in {1} for {2}: {3} 20 | check.parent=Parents checked in {0} for {1}: {2} 21 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | config.error.load=Error while loading configuration: {0} 19 | config.error.save=Unable to write permissions configuration 20 | config.error.unknown-format=Configuration file {0} is of an unknown file type! 21 | 22 | conversion.banner=Welcome to PermissionsEx! We're creating some default data. If you have data from another plugin to import, it will be listed here. Run the command /pex import [id] to import from one of these backends: 23 | conversion.pluginheader=Plugin {0} has data in: 24 | conversion.instance=- {0}: {0} 25 | conversion.result.success=Successfully migrated old-style default data to new location 26 | 27 | error.general.loading=Error while loading permissions 28 | 29 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/rank/messages.properties: -------------------------------------------------------------------------------- 1 | formatter.button.info-prompt=Click here to view more info 2 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/subject/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | baker.error.circular-inheritance=Potential circular inheritance found while traversing inheritance for {0} when visiting {1} 19 | -------------------------------------------------------------------------------- /core/src/main/messages/ca/stellardrift/permissionsex/impl/util/glob/globMessages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | error.parse=Unable to parse glob: Error at token {0} (at position {1}:{2}) 19 | -------------------------------------------------------------------------------- /core/src/main/resources/ca/stellardrift/permissionsex/impl/config/default.conf: -------------------------------------------------------------------------------- 1 | # The default backend to use. Must be contained in the backends mapping. 2 | #default-backend = null 3 | 4 | # Whether to log permissions checks being performed. This can be activated (or deactivated) temporarily by running the command `/pex debug` 5 | debug = false 6 | 7 | # The list of backends able to be selected 8 | backends { 9 | # This is the default backend, and is preferred if the H2 driver is available 10 | default { 11 | type = sql 12 | url = "jdbc:h2:permissions" 13 | } 14 | default-file { 15 | type = "file" 16 | file = "permissions.json" 17 | } 18 | } 19 | 20 | # Tags that apply to this server (which match with permissions blocks restricted by server-tag contexts 21 | server-tags = [] 22 | 23 | -------------------------------------------------------------------------------- /core/src/test/java/ca/stellardrift/permissionsex/impl/TranslatableProviderClasspathTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl; 18 | 19 | import ca.stellardrift.permissionsex.util.TranslatableProvider; 20 | import net.kyori.adventure.text.Component; 21 | import net.kyori.adventure.translation.GlobalTranslator; 22 | import org.junit.jupiter.api.Test; 23 | 24 | import java.util.Locale; 25 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; 27 | 28 | class TranslatableProviderClasspathTest { 29 | 30 | // A simple test to ensure we are still loading translations from the classpath properly 31 | @Test 32 | void testBundleDiscovery() { 33 | final TranslatableProvider message = Messages.CONFIG_ERROR_SAVE; 34 | 35 | assertEquals( 36 | Component.text("Unable to write permissions configuration"), 37 | GlobalTranslator.render(message.tr(), Locale.ENGLISH) 38 | ); 39 | } 40 | 41 | @Test 42 | void testLanguageFallback() { 43 | final TranslatableProvider message = Messages.CONFIG_ERROR_SAVE; 44 | 45 | assertEquals( 46 | Component.text("Unable to write permissions configuration"), 47 | GlobalTranslator.render(message.tr(), new Locale("ab", "cd")) 48 | ); 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /core/src/test/java/ca/stellardrift/permissionsex/impl/config/DefaultConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.impl.config; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.spongepowered.configurate.ConfigurateException; 21 | 22 | public class DefaultConfigTest { 23 | /** 24 | * This is a sanity check that loads the config included in the jar at build time and makes sure it is syntactically valid 25 | */ 26 | @Test 27 | void testDefaultConfigLoading() throws ConfigurateException { 28 | FilePermissionsExConfiguration.loadDefaultConfiguration(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test0to1.post.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | test-noopts: 3 | permissions: 4 | - some-permission 5 | worlds: 6 | world_nether: 7 | options: 8 | prefix: nether user 9 | options: 10 | prefix: that one 11 | suffix: who sucks 12 | default: true 13 | test-existingopts: 14 | options: 15 | hello: world 16 | prefix: someone else 17 | suffix: who is ok I guess 18 | default: true 19 | users: 20 | test-noopts: 21 | permissions: 22 | - some-permission 23 | worlds: 24 | world_nether: 25 | options: 26 | prefix: nether user 27 | options: 28 | prefix: that one 29 | suffix: who sucks 30 | default: true 31 | test-existingopts: 32 | options: 33 | hello: world 34 | prefix: someone else 35 | suffix: who is ok I guess 36 | default: true 37 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test0to1.pre.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | test-noopts: 3 | default: true 4 | prefix: that one 5 | suffix: who sucks 6 | permissions: 7 | - some-permission 8 | worlds: 9 | world_nether: 10 | prefix: nether user 11 | test-existingopts: 12 | default: true 13 | prefix: someone else 14 | suffix: who is ok I guess 15 | options: 16 | hello: world 17 | users: 18 | test-noopts: 19 | default: true 20 | prefix: that one 21 | suffix: who sucks 22 | permissions: 23 | - some-permission 24 | worlds: 25 | world_nether: 26 | prefix: nether user 27 | test-existingopts: 28 | default: true 29 | prefix: someone else 30 | suffix: who is ok I guess 31 | options: 32 | hello: world 33 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test1to2.pre.yml: -------------------------------------------------------------------------------- 1 | groups: 2 | default: 3 | permissions: 4 | - modifyworld.* 5 | - '#worldedit.wand' 6 | options: 7 | default: true 8 | another: 9 | permissions: 10 | - bukkit.command.time 11 | - essentials.gamemode 12 | worlds: 13 | world_nether: 14 | options: 15 | prefix: nether another 16 | suffix: nether suffix 17 | options: 18 | prefix: global another 19 | suffix: another the suffix 20 | default: false 21 | test: 22 | permissions: 23 | - -worldedit.navigation.jumpto.command 24 | - worldedit.navigation.jumpto* 25 | - -worldedit.navigation.jumpto.tool 26 | inheritance: 27 | - default 28 | options: 29 | default: false 30 | test2: 31 | permissions: 32 | - worldedit.selection.pos 33 | - worldedit.navigation.jumpto.(command|tool) 34 | inheritance: 35 | - test 36 | options: 37 | default: false 38 | admin: 39 | permissions: 40 | - '*' 41 | 42 | users: 43 | 2f224fdf-ca9a-4043-8166-0d673ba4c0b8: 44 | permissions: 45 | - test.permission 46 | - test.perm 47 | - permissionsex.* 48 | - essentials.me 49 | - bukkit.command.me 50 | group: 51 | - another 52 | - test2 53 | options: 54 | name: zml2008 55 | suffix: '' 56 | worlds: 57 | world: 58 | permissions: 59 | - worldedit.navigation.jumpto.command 60 | worlds: 61 | world_nether: 62 | inheritance: 63 | - world 64 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test2to3.post.json: -------------------------------------------------------------------------------- 1 | { 2 | "subjects": { 3 | "group": { 4 | "default": [ 5 | { 6 | "permissions": { 7 | "some.perm": 1 8 | } 9 | } 10 | ], 11 | "resident": [ 12 | {} 13 | ], 14 | "elder": [ 15 | {} 16 | ], 17 | "mayor": [ 18 | {} 19 | ], 20 | "mod": [ 21 | {} 22 | ], 23 | "head-mod": [ 24 | {} 25 | ], 26 | "admin": [ 27 | {} 28 | ], 29 | "owner": [ 30 | { 31 | "permissions-default": 1 32 | } 33 | ] 34 | } 35 | }, 36 | "rank-ladders": { 37 | "default": [ 38 | "group:default", 39 | "group:resident", 40 | "group:elder", 41 | "group:mayor" 42 | ], 43 | "moderation": [ 44 | "group:mod", 45 | "group:head-mod", 46 | "group:admin" 47 | ] 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test2to3.pre.json: -------------------------------------------------------------------------------- 1 | { 2 | "groups": { 3 | "default": [ { 4 | "permissions": { 5 | "some.perm": 1 6 | }, 7 | "options": { 8 | "rank": 1000 9 | } 10 | } ], 11 | "resident": [ { 12 | "options": { 13 | "rank": 900 14 | } 15 | } ], 16 | "elder": [ { 17 | "options": { 18 | "rank": 800 19 | } 20 | 21 | } ], 22 | "mayor": [ { 23 | "options": { 24 | "rank": 700 25 | } 26 | } ], 27 | "mod": [ { 28 | "options": { 29 | "rank": 1000, 30 | "rank-ladder": "moderation" 31 | } 32 | 33 | } ], 34 | "head-mod": [ { 35 | "options": { 36 | "rank": 900, 37 | "rank-ladder": "moderation" 38 | } 39 | 40 | } ], 41 | "admin": [ { 42 | "options": { 43 | "rank": 800, 44 | "rank-ladder": "moderation" 45 | } 46 | } ], 47 | "owner": [ { 48 | "permissions-default": 1 49 | } ] 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test3to4.post.json: -------------------------------------------------------------------------------- 1 | { 2 | "subjects": { 3 | "group": { 4 | "default": [ 5 | { 6 | "permissions": { 7 | "some.perm": 1 8 | } 9 | } 10 | ], 11 | "owner": [ 12 | { 13 | "permissions-default": 1 14 | } 15 | ] 16 | } 17 | }, 18 | "rank-ladders": { 19 | "default": [ 20 | "group:default", 21 | "group:resident", 22 | "group:elder", 23 | "group:mayor" 24 | ], 25 | "moderation": [ 26 | "group:mod", 27 | "group:head-mod", 28 | "group:admin" 29 | ] 30 | }, 31 | "context-inheritance": { 32 | "world:world_nether": [ 33 | "world:world" 34 | ] 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /core/src/test/resources/ca/stellardrift/permissionsex/impl/backend/file/test3to4.pre.json: -------------------------------------------------------------------------------- 1 | { 2 | "subjects": { 3 | "group": { 4 | "default": [ 5 | { 6 | "permissions": { 7 | "some.perm": 1 8 | } 9 | } 10 | ], 11 | "owner": [ 12 | { 13 | "permissions-default": 1 14 | } 15 | ] 16 | } 17 | }, 18 | "worlds": { 19 | "world_nether": { 20 | "inheritance": [ 21 | "world" 22 | ] 23 | } 24 | }, 25 | "rank-ladders": { 26 | "default": [ 27 | "group:default", 28 | "group:resident", 29 | "group:elder", 30 | "group:mayor" 31 | ], 32 | "moderation": [ 33 | "group:mod", 34 | "group:head-mod", 35 | "group:admin" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /datastore/conversion/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import ca.stellardrift.build.common.configurate 2 | 3 | plugins { 4 | id("pex-component") 5 | id("ca.stellardrift.opinionated.kotlin") 6 | id("ca.stellardrift.localization") 7 | } 8 | 9 | tasks.javadoc { 10 | enabled = false 11 | } 12 | 13 | useAutoService() 14 | dependencies { 15 | implementation(project(":api")) 16 | implementation(project(":core")) 17 | implementation(configurate("yaml")) 18 | implementation(configurate("extra-kotlin")) 19 | } 20 | -------------------------------------------------------------------------------- /datastore/conversion/src/main/java/ca/stellardrift/permissionsex/datastore/conversion/ReadOnlySubjectData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.conversion; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextValue; 20 | import ca.stellardrift.permissionsex.subject.ImmutableSubjectData; 21 | import ca.stellardrift.permissionsex.subject.Segment; 22 | 23 | import java.util.Set; 24 | import java.util.function.BiFunction; 25 | import java.util.function.UnaryOperator; 26 | 27 | /** 28 | * An implementation of the subject data interface that blocks all write operations 29 | */ 30 | public abstract class ReadOnlySubjectData implements ImmutableSubjectData { 31 | 32 | @Override 33 | public ImmutableSubjectData withSegments(BiFunction>, Segment, Segment> transformer) { 34 | throw readOnly(); 35 | } 36 | 37 | @Override 38 | public ImmutableSubjectData withSegment(Set> contexts, UnaryOperator operation) { 39 | throw readOnly(); 40 | } 41 | 42 | @Override 43 | public ImmutableSubjectData withSegment(Set> contexts, Segment segment) { 44 | throw readOnly(); 45 | } 46 | 47 | @Override 48 | public ImmutableSubjectData mergeFrom(ImmutableSubjectData other) { 49 | throw readOnly(); 50 | } 51 | 52 | private UnsupportedOperationException readOnly() { 53 | return new UnsupportedOperationException(this.getClass() + " is a read-only subject data holder, for migration purposes only."); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /datastore/conversion/src/main/kotlin/ca/stellardrift/permissionsex/datastore/conversion/ultraperms/UltraPermissionsDataStore.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.conversion.ultraperms 18 | 19 | import java.net.URL 20 | import java.util.UUID 21 | 22 | data class PermissionEntry(val holder: String, val permission: String, val positive: Boolean, val expiry: Long) 23 | data class ServerEntry(val name: String, val lastHeartbeat: Long) 24 | data class UserEntry(val name: String, val superadmin: Boolean, val groups: Map, val prefix: String, val suffix: String, val skull: URL) 25 | data class GroupEntry(val name: String, val serverId: UUID, val priority: Int, val default: Boolean, val icon: String /* Material */) 26 | 27 | /*class UltraPermissionsDataStore { 28 | companion object : ConversionProvider { 29 | override val name: Component 30 | get() = +"UltraPermissions" 31 | 32 | override fun listConversionOptions(pex: PermissionsEx<*>): List { 33 | val ultraPermsDir = pex.getBaseDirectory(BaseDirectoryScope.JAR).resolve("UltraPermissions") 34 | if (Files.exists(ultraPermsDir)) { 35 | // TODO: prepare an instance of an UltraPerms configuration 36 | } 37 | return listOf() 38 | } 39 | } 40 | }*/ 41 | -------------------------------------------------------------------------------- /datastore/conversion/src/main/messages/ca/stellardrift/permissionsex/datastore/conversion/groupmanager/messages.properties: -------------------------------------------------------------------------------- 1 | error.no-dir=GroupManager directory {0} does not exist 2 | name=GroupManager 3 | description=GroupManager file store 4 | -------------------------------------------------------------------------------- /datastore/conversion/src/main/messages/ca/stellardrift/permissionsex/datastore/conversion/luckperms/messages.properties: -------------------------------------------------------------------------------- 1 | name=LuckPerms 2 | description.file-separate=LuckPerms {0} separate 3 | description.file-combined=LuckPerms {0} combined 4 | error.invalid-track=LuckPerms data store only supports subject type group, but a subject with type {0} was passed to rank ladder {1} 5 | -------------------------------------------------------------------------------- /datastore/conversion/src/main/messages/ca/stellardrift/permissionsex/datastore/conversion/messages.properties: -------------------------------------------------------------------------------- 1 | ops.name=Ops List 2 | ops.description=Server ops.json 3 | ops.error.no-file=Ops file {0} does not exist, so no operators will be available for import 4 | 5 | -------------------------------------------------------------------------------- /datastore/file/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("pex-component") 3 | } 4 | 5 | useAutoService() 6 | dependencies { 7 | implementation(project(":api")) 8 | } 9 | -------------------------------------------------------------------------------- /datastore/sql/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("pex-component") 3 | id("ca.stellardrift.localization") 4 | } 5 | 6 | useAutoService() 7 | dependencies { 8 | api(project(":api")) 9 | implementation(project(":core")) 10 | implementation("com.google.guava:guava:21.0") 11 | 12 | implementation(platform("org.jdbi:jdbi3-bom:3.18.0")) 13 | implementation("org.jdbi:jdbi3-core") 14 | implementation("org.jdbi:jdbi3-postgres") 15 | implementation("org.jdbi:jdbi3-sqlite") 16 | 17 | testImplementation(testFixtures(project(":core"))) 18 | } 19 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/CheckedBiConsumer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql; 18 | 19 | public interface CheckedBiConsumer { 20 | /** 21 | * Perform the action with the provided arguments 22 | * 23 | * @param a The first argument 24 | * @param b The second argument 25 | * @throws E The exception that may be thrown if an error occurs 26 | */ 27 | void accept(A a, B b) throws E; 28 | } 29 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/SqlConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql; 18 | 19 | public class SqlConstants { 20 | public static final String OPTION_SCHEMA_VERSION = "schema_version"; 21 | public static final int UNALLOCATED = -1; 22 | public static final int VERSION_NOT_INITIALIZED = -2; 23 | public static final int VERSION_PRE_VERSIONING = -1; 24 | } 25 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/SqlRankLadder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql; 18 | 19 | import ca.stellardrift.permissionsex.impl.rank.AbstractRankLadder; 20 | import ca.stellardrift.permissionsex.impl.util.PCollections; 21 | import ca.stellardrift.permissionsex.rank.RankLadder; 22 | import ca.stellardrift.permissionsex.subject.SubjectRef; 23 | import org.pcollections.PVector; 24 | 25 | public class SqlRankLadder extends AbstractRankLadder { 26 | private final PVector> entries; 27 | 28 | public SqlRankLadder(String name, PVector> entries) { 29 | super(name); 30 | this.entries = entries; 31 | } 32 | 33 | @Override 34 | public PVector> ranks() { 35 | return this.entries; 36 | } 37 | 38 | @Override 39 | protected RankLadder newWithRanks(final PVector> ents) { 40 | return new SqlRankLadder(name(), ents.stream() 41 | .map(SqlSubjectRef::from) 42 | .collect(PCollections.toPVector())); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/dao/H2SqlDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql.dao; 18 | 19 | import ca.stellardrift.permissionsex.datastore.sql.SqlDao; 20 | import ca.stellardrift.permissionsex.datastore.sql.SqlDataStore; 21 | 22 | import java.sql.SQLException; 23 | 24 | public class H2SqlDao extends SqlDao { 25 | 26 | public H2SqlDao(SqlDataStore ds) throws SQLException { 27 | super(ds); 28 | } 29 | 30 | @Override 31 | protected String getInsertGlobalParameterQueryUpdating() { 32 | return "MERGE INTO {}global (`key`, `value`) KEY(`key`) VALUES (?, ?)"; 33 | } 34 | 35 | @Override 36 | protected String getInsertOptionUpdatingQuery() { 37 | return "MERGE INTO {}options (`segment`, `key`, `value`) VALUES (?, ?, ?)"; 38 | } 39 | 40 | @Override 41 | protected String getInsertPermissionUpdatingQuery() { 42 | return "MERGE INTO {}permissions (`segment`, `key`, `value`) VALUES (?, ?, ?)"; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/dao/LegacyMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql.dao; 18 | 19 | /** 20 | * Dao to handle legacy operations 21 | */ 22 | public interface LegacyMigration extends SchemaMigration { 23 | 24 | enum Type { 25 | GROUP, USER, WORLD 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/dao/MySqlDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql.dao; 18 | 19 | import ca.stellardrift.permissionsex.datastore.sql.SqlDao; 20 | import ca.stellardrift.permissionsex.datastore.sql.SqlDataStore; 21 | 22 | import java.sql.SQLException; 23 | 24 | public class MySqlDao extends SqlDao { 25 | public MySqlDao(SqlDataStore ds) throws SQLException { 26 | super(ds); 27 | } 28 | 29 | @Override 30 | protected String getInsertGlobalParameterQueryUpdating() { 31 | return "INSERT INTO {}global (`key`, `value`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)"; 32 | } 33 | 34 | @Override 35 | protected String getInsertOptionUpdatingQuery() { 36 | return "INSERT INTO {}options (segment, `key`, `value`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)"; 37 | } 38 | 39 | @Override 40 | protected String getInsertPermissionUpdatingQuery() { 41 | return "INSERT INTO {}permissions (segment, `key`, `value`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `value`=VALUES(`value`)"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/dao/PexJdbiPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql.dao; 18 | 19 | import org.jdbi.v3.core.Jdbi; 20 | import org.jdbi.v3.core.collector.JdbiCollectors; 21 | import org.jdbi.v3.core.spi.JdbiPlugin; 22 | 23 | import java.sql.SQLException; 24 | 25 | public final class PexJdbiPlugin extends JdbiPlugin.Singleton { 26 | 27 | @Override 28 | public void customizeJdbi(Jdbi jdbi) throws SQLException { 29 | jdbi.getConfig(JdbiCollectors.class).register(PCollectionsCollectorFactory.INSTANCE); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/dao/SchemaMigration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.datastore.sql.dao; 18 | 19 | import ca.stellardrift.permissionsex.datastore.sql.SqlDao; 20 | 21 | import java.sql.SQLException; 22 | 23 | /** 24 | * Schema migration for SQL backend 25 | */ 26 | @FunctionalInterface 27 | public interface SchemaMigration { 28 | void migrate(SqlDao dao) throws SQLException; 29 | } 30 | -------------------------------------------------------------------------------- /datastore/sql/src/main/java/ca/stellardrift/permissionsex/datastore/sql/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | @DefaultQualifier(NonNull.class) 18 | package ca.stellardrift.permissionsex.datastore.sql; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.checkerframework.framework.qual.DefaultQualifier; -------------------------------------------------------------------------------- /datastore/sql/src/main/messages/ca/stellardrift/permissionsex/datastore/sql/messages.properties: -------------------------------------------------------------------------------- 1 | db.impl-not-supported=Database implementation %s is not supported! 2 | db.connection-error=Could not connect to SQL database! 3 | schema-update.success=Updated database schema from version {0} to {1} 4 | error.loading=Error loading permissions for {0} {1} 5 | error.initialize-tables=Error initializing tables in SQL database 6 | -------------------------------------------------------------------------------- /doc/2.0-home.md: -------------------------------------------------------------------------------- 1 | # Home 2 | 3 | This section contains documentation about the new 2.0 release of PermissionsEx. Keep in mind that this documentation is _still heavily WIP_, so some sections may be unclear or incomplete. 4 | 5 | Just getting started? You'll want to work through the [tutorial](tutorial.md). 6 | 7 | Coming from PermissionsEx v1? Take a look at the list of [changes in v2](learning-v2-from-other-plugins-and-v1/changes-in-2.0.md), and the [new commands](components-in-detail/command.md). 8 | 9 | Take a look at the contents in sidebar for more information! 10 | 11 | -------------------------------------------------------------------------------- /doc/SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [Home](2.0-home.md) 4 | * [Getting Started](tutorial.md) 5 | * [Commands](components-in-detail/command.md) 6 | * [Platforms](platforms/README.md) 7 | * [Paper/Spigot/Bukkit](platforms/bukkit.md) 8 | * [Waterfall/BungeeCord](platforms/bungeecord.md) 9 | * [Fabric](platforms/fabric.md) 10 | * [Sponge (v7 and v8)](platforms/sponge.md) 11 | * [Velocity](platforms/velocity.md) 12 | * [Components in Detail](components-in-detail/README.md) 13 | * [Subject](components-in-detail/subject.md) 14 | * [Defaults and Fallbacks](components-in-detail/defaults-and-fallbacks.md) 15 | * [Data Stores](components-in-detail/data-stores.md) 16 | * [Learning v2 from other plugins and v1](learning-v2-from-other-plugins-and-v1/README.md) 17 | * [Command Equivalency](learning-v2-from-other-plugins-and-v1/command-equivalency.md) 18 | * [Changes In 2.0](learning-v2-from-other-plugins-and-v1/changes-in-2.0.md) 19 | * [Contributing](contributing/README.md) 20 | * [Documentation Style Guide](contributing/style-guide.md) 21 | * [Localization](contributing/localization.md) 22 | 23 | -------------------------------------------------------------------------------- /doc/components-in-detail/README.md: -------------------------------------------------------------------------------- 1 | # Components in Detail 2 | 3 | -------------------------------------------------------------------------------- /doc/components-in-detail/defaults-and-fallbacks.md: -------------------------------------------------------------------------------- 1 | # Defaults and Fallbacks 2 | 3 | PermissionsEx has several solutions to apply data across a wide collection of subjects. While defaults and fallbacks are similar, they have a few key differences that are important to note. Fallbacks are most similar to how PEX v1's default group used to work, while defaults allow providing data that is actually applicable to every subject on the server. Defaults are also extremely useful for plugins that want to provide permissions that should not be granted with wildcards. For example, a vanish plugin might want to set the permission `vanish.autovanish.on-join` to false in the transient data of the default user subject. That woul make sure that admins are not automatically vanished on join, which is most likely not the intention of the server administrator. 4 | 5 | ## Defaults 6 | 7 | Defaults are applied to any subject, regardless if it has its own parents. They are stored under the `default` subject type. There are per-type defaults, such as `default:`, that are only applied to `` subjects, and global defaults, stored under the subject `default:default`, that are applied to every subject. Defaults are only queried once at the lowest priority in subject data calculations, using the type of the subject that data is being calculated for, not any of its parents. For example, if a permission was being queried. 8 | 9 | For the purpose of non-inheritable permissions, per-type defaults include non-inheritable permissions set directly and global defaults do not include non-inheritable permissions. 10 | 11 | ## Fallbacks 12 | 13 | Fallbacks are only applied to subjects without any of their own data defined. Fallback data has higher priority than defaults. These fallback permissions are defined in the `fallback:` subject, where `` is the type of subject needing a fallback \(for example, `user`. This means that the moment anything is set on a subject, its fallback information will disappear. **This can result in the loss of previously granted access!** 14 | 15 | For the purposes of non-inheritable permissions, fallback data is treated as if it were directly included in the subject being queried. 16 | 17 | -------------------------------------------------------------------------------- /doc/contributing/README.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | -------------------------------------------------------------------------------- /doc/contributing/localization.md: -------------------------------------------------------------------------------- 1 | # Localization 2 | 3 | PermissionsEx is built to be translatable. Players will be shown messages in their client's locale if the plugin has been translated, and server messages will be shown in the server's default locale. 4 | 5 | Currently, messages are only available in English, so we are seeking contributors to translate to other languages. 6 | 7 | ## Overriding messages on your own server 8 | 9 | Currently, messages can be changed only by editing the `messages.properties` files within the jar. There is usually one per package with the messages used in that package. 10 | 11 | An eventual goal is to allow overriding messages using files in the plugin data folder, but this has not been implemented yet. 12 | 13 | ## How to contribute 14 | 15 | While we eventually plan to put up a CrowdIn page to allow translations to be contributed more easily, the only way to contribute at the moment is to provide new versions of the files in the `src/main/messages` folder in each module. 16 | 17 | Feel free to ask for help in the Discord -- we will be happy to assist in getting more localizations in. 18 | 19 | -------------------------------------------------------------------------------- /doc/contributing/style-guide.md: -------------------------------------------------------------------------------- 1 | # Documentation Style Guide 2 | 3 | For PEX 2.0's documentation, it is important to have a consistent style so that the documentation is easy to follow for users. 4 | 5 | ## Tutorials 6 | 7 | A tutorial is a recipe for a specific configuration. It doesn't necessarily describe every aspect of a PEX feature. The goal of a tutorial is to provide a path a user can easily follow to achieve a certain goal, like setting up an admin group or setting up a ladder of membership levels. 8 | 9 | Each tutorial should follow a step structure, where each step describes what is being done, as well as how to do it in the various interfaces to access PEX \(commands, gui, potentialy text file\). 10 | 11 | ## Subsystem Description 12 | 13 | A subsystem description describes how a particular component of PEX works in detail. It's not focused on a specific way of doing things, but should give the information necessary to use the full feature set of the subsystem. Sections of one of these pages might be: 14 | 15 | * Commands 16 | * Effect on a subject of the various configuration states 17 | * How to apply these changes directly to a backend \(file?\) 18 | 19 | -------------------------------------------------------------------------------- /doc/learning-v2-from-other-plugins-and-v1/README.md: -------------------------------------------------------------------------------- 1 | # Learning v2 from other plugins and v1 2 | 3 | -------------------------------------------------------------------------------- /doc/platforms/README.md: -------------------------------------------------------------------------------- 1 | # Platforms 2 | 3 | PermissionsEx is supported on a variety of platforms, and is designed to be easy to port to others. -------------------------------------------------------------------------------- /doc/platforms/bungeecord.md: -------------------------------------------------------------------------------- 1 | # PermissionsEx for Waterfall/BungeeCord 2 | 3 | * All commands have an extra `/` prefix to be run on the proxy, and output gold text to distinguish them from commands running on the server. 4 | 5 | For example, `/pex` will become `//pex` to work with the proxy's instance of the plugin. 6 | 7 | * All subjects, when queried on the proxy, are in the `proxy=true` context 8 | -------------------------------------------------------------------------------- /doc/platforms/sponge.md: -------------------------------------------------------------------------------- 1 | # PermissionsEx for Sponge 2 | 3 | PermissionsEx integrates directly with the Sponge permissions API. This API was designed together with PEX v2, so they have fairly equivalent functionality. PEX itself exposes a few more features than Sponge does, so it may be necessary for developers to integrate directly with the PEX API. 4 | 5 | If another permissions plugin is installed, PEX will fail to enable. 6 | 7 | ## Contexts 8 | 9 | In addition to the [global contexts](../components-in-detail/subject.md#contexts) 10 | 11 | | Context Key | Example Value | Description | 12 | | :--- | :--- | :--- | 13 | | `world` | `DIM-1` | The world a subject is currently in | 14 | | `dimension` | `Overworld` | The dimension of the world a subject is currently in | 15 | | `remoteip` | `127.0.0.1` | The IP address a subject is connecting from | 16 | | `localhost` | `myminecraftserver.com` | The hostname a client is connecting to the server with | 17 | | `localip` | `[2607:f8b0:400a:801::200e]` | The ip \(on the server\) that is receiving the connection from a subject | 18 | | `localport` | `25565` | The port \(on the server\) that the client is connecting to | 19 | -------------------------------------------------------------------------------- /doc/platforms/velocity.md: -------------------------------------------------------------------------------- 1 | ## PermissionsEx for Velocity 2 | 3 | PermissionsEx requires Velocity 1.1.0 or newer. 4 | 5 | * All commands have an extra `/` prefix to be run on the proxy, and output gold text to distinguish them from commands running on the server. 6 | 7 | For example, `/pex` will become `//pex` to work with the proxy's instance of the plugin. 8 | 9 | * All subjects, when queried on the proxy, are in the `proxy=true` context 10 | -------------------------------------------------------------------------------- /etc/build-accountsclient.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | DESTDIR="AccountsClient" 5 | git clone https://github.com/Mojang/AccountsClient.git $DESTDIR 6 | cd $DESTDIR 7 | 8 | sed -i "s/testLogging\.showStandardStreams = true//" build.gradle 9 | sed -i "s/apply plugin: 'idea'/apply plugin: 'idea'\napply plugin: 'maven'\ngroup = 'com.mojang'/" build.gradle 10 | echo "rootProject.name = 'AccountsClient'" >> settings.gradle 11 | 12 | gradle clean install 13 | 14 | cd .. 15 | rm -rf $DESTDIR 16 | -------------------------------------------------------------------------------- /etc/discord-embeds/pex2.json: -------------------------------------------------------------------------------- 1 | { 2 | "embed": { 3 | "description": "PermissionsEx 2 is the next generation of PermissionsEx. While development builds are available, PEX 2 still has no guarantees of stability and should be considered to be in a *pre-alpha* state", 4 | "url": "https://github.com/PEXPlugins/PermissionsEx", 5 | "color": 16098851, 6 | "timestamp": "{TIMESTAMP_NOW}", 7 | "footer": { 8 | "text": "Requested by {USER}" 9 | }, 10 | "thumbnail": { 11 | "url": "https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/master/etc/logos/200x200.png" 12 | }, 13 | 14 | "author": { 15 | "name": "PermissionsEx", 16 | "url": "https://github.com/PEXPlugins/PermissionsEx", 17 | "icon_url": "https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/master/etc/logos/50x50.png" 18 | }, 19 | "fields": [ 20 | { 21 | "name": "Supported Platforms", 22 | "value": "Sponge, Fabric, Paper/Spigot, Velocity, Waterfall/Bungee" 23 | }, 24 | { 25 | "name": "Documentation", 26 | "value": "https://permissionsex.stellardrift.ca" 27 | }, 28 | { 29 | "name": "Downloads", 30 | "value": "https://jenkins.addstar.com.au/job/PermissionsEx/lastSuccessfulBuild/" 31 | } 32 | ] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /etc/logo.afdesign: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/c41c3456a064121697b052e43864474791116423/etc/logo.afdesign -------------------------------------------------------------------------------- /etc/logos/200x200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/c41c3456a064121697b052e43864474791116423/etc/logos/200x200.png -------------------------------------------------------------------------------- /etc/logos/50x50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/c41c3456a064121697b052e43864474791116423/etc/logos/50x50.png -------------------------------------------------------------------------------- /etc/messages-template.java.tmpl: -------------------------------------------------------------------------------- 1 | package $packageName; 2 | 3 | import ca.stellardrift.permissionsex.util.TranslatableProvider; 4 | 5 | final class ${className} { 6 | private static final String BUNDLE_NAME = "${bundleName}"; 7 | <% def propPattern = ~/[.-]/ %><% for (prop in keys) { %><% def propKey = propPattern.matcher(prop.toUpperCase()).replaceAll("_") %> 8 | public static final TranslatableProvider ${propKey} = new TranslatableProvider(BUNDLE_NAME, "${prop}");<% } %> 9 | 10 | private ${className}() { 11 | } 12 | 13 | static { 14 | TranslatableProvider.registerAllTranslations( 15 | BUNDLE_NAME, 16 | TranslatableProvider.knownLocales(${className}.class, BUNDLE_NAME), 17 | ${className}.class.getClassLoader() 18 | ); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # 18 | 19 | pexGroup=ca.stellardrift.permissionsex 20 | pexVersion=2.0-SNAPSHOT 21 | pexSuffix=+local 22 | pexRelocationRoot=ca.stellardrift.permissionsex.ext 23 | pexDescription=A powerful permissions plugin for Minecraft servers 24 | 25 | # The Java version to use for dev tasks 26 | developmentRuntime=16 27 | 28 | # comma separated list of modules to exclude from the final archive 29 | buildExcludes= 30 | 31 | adventureVersion=4.7.0 32 | adventurePlatformVersion=4.0.0-SNAPSHOT 33 | antlrVersion=4.9.2 34 | autoServiceVersion=1.0-rc7 35 | checkerVersion=3.11.0 36 | cloudVersion=1.4.0 37 | configurateVersion=4.0.0 38 | errorproneVersion=2.5.1 39 | h2Version=1.4.200 40 | immutablesVersion=2.8.8 41 | junitVersion=5.7.1 42 | pCollectionsVersion=3.1.4 43 | slf4jVersion=1.7.30 44 | velocityVersion=1.1.4 45 | 46 | kotlin.code.style=official 47 | kapt.use.worker.api=true 48 | kapt.include.compile.classpath=false 49 | kapt.incremental.apt=false 50 | 51 | org.gradle.caching=true 52 | org.gradle.parallel=true 53 | org.gradle.jvmargs=-Xmx1G 54 | -------------------------------------------------------------------------------- /gradle/gradle.nix: -------------------------------------------------------------------------------- 1 | {fetchurl, gradleGen, jdk, java ? jdk}: 2 | # Create a custom gradle with our chosen JDK 3 | (gradleGen.override { java = java; }).gradleGen rec { 4 | name = "gradle-6.7.1"; 5 | nativeVersion = "0.22-milestone-9"; 6 | 7 | src = fetchurl { 8 | url = "https://services.gradle.org/distributions/${name}-bin.zip"; 9 | sha256 = "0789xjsjk5azza4nrsz1v0ziyk7nfc2i1b43v4vqm0y3hvnvaf9j"; 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PEXPlugins/PermissionsEx/c41c3456a064121697b052e43864474791116423/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-6.8.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /impl-blocks/glob/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("pex-component") 3 | antlr 4 | } 5 | 6 | configurations.compile { 7 | exclude("org.antlr", "antlr4") 8 | } 9 | 10 | useCheckerFramework() 11 | dependencies { 12 | val antlrVersion: String by project 13 | antlr("org.antlr:antlr4:$antlrVersion") 14 | implementation("org.antlr:antlr4-runtime:$antlrVersion") 15 | } 16 | 17 | tasks.generateGrammarSource { 18 | this.arguments.addAll(listOf("-visitor", "-no-listener")) 19 | } 20 | -------------------------------------------------------------------------------- /impl-blocks/glob/src/main/antlr/ca/stellardrift/permissionsex/util/glob/parser/Glob.g4: -------------------------------------------------------------------------------- 1 | grammar Glob; 2 | 3 | @header { 4 | package ca.stellardrift.permissionsex.util.glob.parser; 5 | } 6 | 7 | rootGlob: glob EOF; 8 | 9 | glob: element+; 10 | 11 | element: or 12 | | chars 13 | | unit=LITERAL; 14 | 15 | /** Each single character is one possibility */ 16 | chars: '[' content=LITERAL ']'; 17 | 18 | /* Choose one of the subsequences */ 19 | or: '{' (glob ','?)* '}'; 20 | 21 | 22 | LITERAL: (ESC | CHAR | DIGIT)+; 23 | 24 | fragment DIGIT : [0-9]; 25 | CHAR: ~('{' | '}' | '[' | ']' | ','); 26 | ESC: '\\' ('{' | '}' | ','); 27 | 28 | 29 | -------------------------------------------------------------------------------- /impl-blocks/glob/src/main/java/ca/stellardrift/permissionsex/util/glob/GlobNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.util.glob; 18 | 19 | import java.util.Objects; 20 | 21 | /** 22 | * A compiled version of a glob expression. 23 | * 24 | * A glob expression is a literal string, with several additional tokens: 25 | *
26 | *
{a,b,c}
27 | *
Any of the comma-separated tokens, represented by {@link OrNode}
28 | *
[a-ce]
29 | *
Any of the characters specified. a - indicates a character range
30 | *
31 | */ 32 | public abstract class GlobNode implements Iterable { 33 | GlobNode() {} 34 | 35 | /** 36 | * Check if the input matches this glob 37 | * 38 | * @param input text to validate 39 | * @return whether we match 40 | */ 41 | public boolean matches(String input) { 42 | Objects.requireNonNull(input, "input"); 43 | for (String value : this) { 44 | if (input.equals(value)) { 45 | return true; 46 | } 47 | } 48 | return false; 49 | } 50 | 51 | public boolean matchesIgnoreCase(String input) { 52 | Objects.requireNonNull(input, "input"); 53 | for (String value : this) { 54 | if (input.equalsIgnoreCase(value)) { 55 | return true; 56 | } 57 | } 58 | return false; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /impl-blocks/glob/src/main/java/ca/stellardrift/permissionsex/util/glob/GlobParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.util.glob; 18 | 19 | 20 | import org.checkerframework.checker.nullness.qual.Nullable; 21 | 22 | /** 23 | * This error is thrown when invalid glob syntax is presented 24 | */ 25 | public final class GlobParseException extends Exception { 26 | private static final long serialVersionUID = 1019525110836056128L; 27 | 28 | GlobParseException(final @Nullable String msg) { 29 | super(msg); 30 | } 31 | 32 | GlobParseException(final @Nullable String msg, final @Nullable Throwable cause) { 33 | super(msg, cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /impl-blocks/glob/src/main/java/ca/stellardrift/permissionsex/util/glob/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | @DefaultQualifier(NonNull.class) 18 | package ca.stellardrift.permissionsex.util.glob; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.checkerframework.framework.qual.DefaultQualifier; -------------------------------------------------------------------------------- /impl-blocks/hikari-config/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | plugins { 19 | id("pex-component") 20 | } 21 | 22 | useCheckerFramework() 23 | dependencies { 24 | val h2Version: String by project 25 | api("org.pcollections:pcollections:3.1.4") 26 | api("com.zaxxer:HikariCP:4.0.3") 27 | compileOnly("com.h2database:h2:$h2Version") 28 | } 29 | -------------------------------------------------------------------------------- /impl-blocks/legacy/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("pex-component") 3 | } 4 | 5 | dependencies { 6 | api(project(":api")) 7 | } 8 | -------------------------------------------------------------------------------- /impl-blocks/legacy/src/main/java/ca/stellardrift/permissionsex/legacy/LegacyConversions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.legacy; 18 | 19 | import java.util.regex.Matcher; 20 | import java.util.regex.Pattern; 21 | 22 | public final class LegacyConversions { 23 | public static final String SUBJECTS_USER = "user"; 24 | public static final String SUBJECTS_GROUP = "group"; 25 | private static final Pattern MATCHER_GROUP_PATTERN = Pattern.compile("\\((.*?)\\)"); 26 | 27 | @SuppressWarnings("JdkObsolete") // StringBuilder methods on Matcher were only added in JDK 9 28 | public static String convertLegacyPermission(String permission) { 29 | final StringBuffer ret = new StringBuffer(); 30 | Matcher matcher = MATCHER_GROUP_PATTERN.matcher(permission); // Convert regex multimatches to shell globs 31 | while (matcher.find()) { 32 | matcher.appendReplacement(ret, "{" + matcher.group(1).replace('|', ',') + "}"); 33 | } 34 | matcher.appendTail(ret); 35 | if (ret.length() > 2 && ret.substring(ret.length() - 2).equals(".*")) { // Delete .* from nodes -- this is implied now 36 | ret.delete(ret.length() - 2, ret.length()); 37 | } 38 | return ret.toString(); 39 | } 40 | 41 | private LegacyConversions() { 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /impl-blocks/legacy/src/test/java/ca/stellardrift/permissionsex/legacy/LegacyConversionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.legacy; 18 | 19 | import org.junit.jupiter.api.Test; 20 | import org.pcollections.HashTreePMap; 21 | 22 | import java.util.Map; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | 26 | class LegacyConversionsTest { 27 | @Test 28 | public void testConvertPermission() { 29 | final Map expectedConversions = HashTreePMap.empty() 30 | .plus("permissions.*", "permissions") 31 | .plus("worldedit.navigation.(jumpto|thru).*", "worldedit.navigation.{jumpto,thru}") 32 | .plus("worldedit.navigation.(jumpto|thru).(tool|command)", "worldedit.navigation.{jumpto,thru}.{tool,command}") 33 | .plus("worldedit.navigation.(jumpto.*", "worldedit.navigation.(jumpto"); 34 | for (Map.Entry ent : expectedConversions.entrySet()) { 35 | assertEquals(ent.getValue(), LegacyConversions.convertLegacyPermission(ent.getKey())); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import ca.stellardrift.build.common.adventure 2 | 3 | /* 4 | * PermissionsEx 5 | * Copyright (C) zml and PermissionsEx contributors 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | plugins { 21 | id("pex-component") 22 | id("ca.stellardrift.localization") 23 | } 24 | 25 | useImmutables() 26 | dependencies { 27 | val cloudVersion: String by project 28 | val immutablesVersion: String by project 29 | 30 | api(project(":api")) 31 | api(project(":core")) 32 | implementation(adventure("text-serializer-plain")) 33 | compileOnlyApi("org.immutables:gson:$immutablesVersion") 34 | runtimeOnly(project(":datastore:sql")) 35 | api("cloud.commandframework:cloud-core:$cloudVersion") 36 | api("cloud.commandframework:cloud-minecraft-extras:$cloudVersion") 37 | compileOnly("cloud.commandframework:cloud-brigadier:$cloudVersion") 38 | compileOnly("com.mojang:brigadier:1.0.17") 39 | 40 | // Fixed version to line up with MC 41 | implementation("com.google.code.gson:gson:2.8.0") 42 | 43 | testRuntimeOnly("org.slf4j:slf4j-simple:1.7.30") 44 | } 45 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/BaseDirectoryScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft; 18 | 19 | public enum BaseDirectoryScope { 20 | /** 21 | * The base directory for PermissionsEx's configuration files 22 | */ 23 | CONFIG, 24 | /** 25 | * Where jar files should be put to update the plugin 26 | */ 27 | JAR, 28 | /** 29 | * Server base directory, where files like server.properties and ops.json are located 30 | */ 31 | SERVER, 32 | /** 33 | * The server's worlds container 34 | */ 35 | WORLDS 36 | } 37 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/command/ButtonType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft.command; 18 | 19 | public enum ButtonType { 20 | /** 21 | * A button for a positive action, like adding or setting to true 22 | */ 23 | POSITIVE, 24 | /** 25 | * A button for a negative or cautionary action, like removing or setting to false 26 | */ 27 | NEGATIVE, 28 | /** 29 | * A button for a neutral action, like moving or renaming 30 | */ 31 | NEUTRAL 32 | } 33 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/command/CommandPermissionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft.command; 18 | 19 | public final class CommandPermissionException extends CommandException { 20 | private static final long serialVersionUID = 6825582153629314194L; 21 | 22 | private final String checkedPermission; 23 | 24 | public CommandPermissionException(final String checkedPermission) { 25 | super(Messages.EXECUTOR_ERROR_NO_PERMISSION.tr()); 26 | this.checkedPermission = checkedPermission; 27 | } 28 | 29 | public String checkedPermission() { 30 | return this.checkedPermission; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/command/PEXCommandPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft.command; 18 | 19 | import ca.stellardrift.permissionsex.PermissionsEngine; 20 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 21 | import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext; 22 | import cloud.commandframework.execution.preprocessor.CommandPreprocessor; 23 | import cloud.commandframework.keys.CloudKey; 24 | import cloud.commandframework.keys.SimpleCloudKey; 25 | import io.leangen.geantyref.TypeToken; 26 | import org.checkerframework.checker.nullness.qual.NonNull; 27 | 28 | public class PEXCommandPreprocessor implements CommandPreprocessor { 29 | 30 | public static final CloudKey> PEX_MANAGER = SimpleCloudKey.of( 31 | "permissionsex:manager", 32 | new TypeToken>() {} 33 | ); 34 | public static final CloudKey PEX_ENGINE = SimpleCloudKey.of( 35 | "permissionsex:engine", 36 | TypeToken.get(PermissionsEngine.class) 37 | ); 38 | 39 | private final MinecraftPermissionsEx manager; 40 | 41 | public PEXCommandPreprocessor(MinecraftPermissionsEx manager) { 42 | this.manager = manager; 43 | } 44 | 45 | @Override 46 | public void accept(@NonNull CommandPreprocessingContext ctx) { 47 | ctx.getCommandContext().store(PEX_MANAGER, this.manager); 48 | ctx.getCommandContext().store(PEX_ENGINE, this.manager.engine()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/profile/ProfileApiResolver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft.profile; 18 | 19 | import java.util.concurrent.Executor; 20 | import java.util.stream.Stream; 21 | 22 | /** 23 | * An interface to the profile API 24 | */ 25 | public interface ProfileApiResolver { 26 | 27 | static ProfileApiResolver resolver(final Executor executor) { 28 | return new ProfileApiResolverImpl(executor); 29 | } 30 | 31 | /** 32 | * Resolve all profiles matching the provided names. 33 | * 34 | * @param names Names to resolve 35 | * @return a future providing the total number of profiles resolved. 36 | */ 37 | Stream resolveByName(Iterable names); 38 | } 39 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/java/ca/stellardrift/permissionsex/minecraft/profile/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | @DefaultQualifier(NonNull.class) 18 | @ImmutablesStyle 19 | package ca.stellardrift.permissionsex.minecraft.profile; 20 | 21 | import ca.stellardrift.permissionsex.util.ImmutablesStyle; 22 | import org.checkerframework.checker.nullness.qual.NonNull; 23 | import org.checkerframework.framework.qual.DefaultQualifier; -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/messages/ca/stellardrift/permissionsex/minecraft/command/argument/messages.properties: -------------------------------------------------------------------------------- 1 | context.name=context 2 | subjecttype.error.notatype=Subject type {0} is not registered! 3 | subject.error.nameinvalid=Name '{0}' is invalid for subjects of type {1} 4 | context.error.format=Contexts must be in the form = 5 | context.error.type=Unknown context type {0} 6 | context.error.value=Unable to parse value for context {0} 7 | 8 | option-value.error.quote-unterminated=No matching word ending with a quotation mark was found! 9 | 10 | pattern.error.syntax=Invalid regular expression syntax for input '{0}' at position {1}: {2} 11 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/messages/ca/stellardrift/permissionsex/minecraft/command/messages.properties: -------------------------------------------------------------------------------- 1 | formatter.button.info-prompt=Click here to view more info 2 | formatter.boolean.true=true 3 | formatter.boolean.false=false 4 | 5 | common.args.context.global=Global 6 | common.transient.description=Whether data should be stored transiently (i.e in-memory only) and not be saved 7 | common.context.description=Contexts to apply the changes in 8 | 9 | executor.error.async-task=Error ({0}) occurred while performing command task! Please see console for details: {0} 10 | executor.error.async-task.console=Error occurred while executing command for user {0} 11 | executor.error.no-permission=You do not have permission to use this command! 12 | 13 | command.arg-type.callback-id=An ID of a registered callback 14 | 15 | command.callback.description=Execute a callback. This command is usually not run manually. 16 | command.callback.arg.callback-id=id 17 | command.callback.error.unknown-id=Unknown callback identifier {0} 18 | command.callback.error.only-own-allowed=You can only activate your own callbacks! 19 | 20 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/main/messages/ca/stellardrift/permissionsex/minecraft/messages.properties: -------------------------------------------------------------------------------- 1 | uuidconversion.begin=Trying to convert users stored by name to UUID 2 | uuidconversion.error.duplicate=Duplicate entry for {0} found while converting to UUID 3 | uuidconversion.end={0} users successfully converted from name to UUID 4 | uuidconversion.error.general=Error converting users to UUID 5 | uuidconversion.error.dns=Unable to resolve Mojang API for UUID conversion. Do you have an internet connection? UUID conversion will not proceed (but may be necessary). 6 | 7 | command.error.unknown=An unknown error occurred while executing the command {0}! Please see the console for details. 8 | command.error.unknown.console=An unknown error occurred while {0} was executing the command '{1}': {2} 9 | 10 | describe.response.active-data-store=Active data store: {0} 11 | describe.response.available-data-stores=Available data store types: {0} 12 | describe.response.available-data-stores.none=No available data store types 13 | describe.response.available-data-stores.single=Available data store type: {0} 14 | describe.response.available-data-stores.plural=Available data store types: {0} 15 | describe.basedirs.header=Base directories 16 | describe.basedirs.config=Config: {0} 17 | describe.basedirs.jar=Jar: {0} 18 | describe.basedirs.server=Server: {0} 19 | describe.basedirs.worlds=Worlds: {0} 20 | -------------------------------------------------------------------------------- /impl-blocks/minecraft/src/test/java/ca/stellardrift/permissionsex/minecraft/profile/ProfileTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.minecraft.profile; 18 | 19 | import org.junit.jupiter.api.Disabled; 20 | import org.junit.jupiter.api.Test; 21 | 22 | import java.util.Arrays; 23 | import java.util.Map; 24 | import java.util.UUID; 25 | import java.util.concurrent.ForkJoinPool; 26 | import java.util.function.Function; 27 | import java.util.stream.Collectors; 28 | 29 | import static org.junit.jupiter.api.Assertions.assertEquals; 30 | 31 | public class ProfileTest { 32 | @Test 33 | @Disabled("Makes network requests") 34 | void integrationTest() { 35 | final ProfileApiResolver resolver = ProfileApiResolver.resolver(ForkJoinPool.commonPool()); 36 | 37 | final Map results = resolver.resolveByName(Arrays.asList("zml", "waylon531", "toolongsothiswontmatchanybody")) 38 | .collect(Collectors.toMap(MinecraftProfile::name, Function.identity())); 39 | 40 | assertEquals(2, results.size()); 41 | 42 | assertEquals(MinecraftProfile.of(UUID.fromString("2f224fdf-ca9a-4043-8166-0d673ba4c0b8"), "zml"), results.get("zml")); 43 | assertEquals(MinecraftProfile.of(UUID.fromString("5e63604d-4fda-40d8-a21c-ccfea1e51315"), "waylon531"), results.get("waylon531")); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /impl-blocks/proxy-common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | * 17 | */ 18 | plugins { 19 | id("pex-component") 20 | } 21 | 22 | dependencies { 23 | api(project(":api")) 24 | } 25 | -------------------------------------------------------------------------------- /impl-blocks/proxy-common/src/main/java/ca/stellardrift/permissionsex/proxycommon/ProxyCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.proxycommon; 18 | 19 | import ca.stellardrift.permissionsex.subject.SubjectRef; 20 | import ca.stellardrift.permissionsex.subject.SubjectType; 21 | import org.spongepowered.configurate.util.UnmodifiableCollections; 22 | 23 | import java.util.Map; 24 | 25 | public final class ProxyCommon { 26 | private ProxyCommon() {} 27 | 28 | private static final String SERVER_CONSOLE_NAME = "Server"; 29 | public static final SubjectType SUBJECTS_SYSTEM = SubjectType.stringIdentBuilder("system") 30 | .fixedEntries(UnmodifiableCollections.immutableMapEntry("Server", () -> null)) 31 | .build(); 32 | public static final SubjectRef IDENT_SERVER_CONSOLE = SubjectRef.subject(SUBJECTS_SYSTEM, SERVER_CONSOLE_NAME); 33 | public static final String PROXY_COMMAND_PREFIX = "/"; 34 | } 35 | -------------------------------------------------------------------------------- /impl-blocks/proxy-common/src/main/java/ca/stellardrift/permissionsex/proxycommon/ProxyContextDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.proxycommon; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextDefinition; 20 | import ca.stellardrift.permissionsex.subject.CalculatedSubject; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | import org.checkerframework.checker.nullness.qual.Nullable; 23 | import org.spongepowered.configurate.serialize.Scalars; 24 | 25 | import java.util.Objects; 26 | import java.util.function.Consumer; 27 | 28 | public final class ProxyContextDefinition extends ContextDefinition { 29 | public static final ProxyContextDefinition INSTANCE = new ProxyContextDefinition(); 30 | 31 | private ProxyContextDefinition() { 32 | super("proxy"); 33 | } 34 | 35 | @Override 36 | public @NonNull String serialize(final Boolean canonicalValue) { 37 | return String.valueOf(canonicalValue); 38 | } 39 | 40 | @Override 41 | public @Nullable Boolean deserialize(final String userValue) { 42 | return Scalars.BOOLEAN.tryDeserialize(userValue); 43 | } 44 | 45 | @Override 46 | public boolean matches(final Boolean ownVal, final Boolean testVal) { 47 | return Objects.equals(ownVal, testVal); 48 | } 49 | 50 | @Override 51 | public void accumulateCurrentValues(final CalculatedSubject subject, final Consumer consumer) { 52 | consumer.accept(true); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /platform/bukkit/LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | PermissionsEx - a permissions plugin for your server ecosystem 2 | Copyright © $year zml [at] stellardrift [dot] ca and PermissionsEx contributors 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation, either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . 16 | -------------------------------------------------------------------------------- /platform/bukkit/src/main/java/ca/stellardrift/permissionsex/bukkit/BukkitConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx - a permissions plugin for your server ecosystem 3 | * Copyright © 2021 zml [at] stellardrift [dot] ca and PermissionsEx contributors 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package ca.stellardrift.permissionsex.bukkit; 19 | 20 | import org.spongepowered.configurate.objectmapping.ConfigSerializable; 21 | import org.spongepowered.configurate.objectmapping.meta.Comment; 22 | import org.spongepowered.configurate.objectmapping.meta.Setting; 23 | 24 | @ConfigSerializable 25 | final class BukkitConfiguration { 26 | 27 | @Setting 28 | @Comment("Whether to fall back to checking op status when a permission is unset in PEX") 29 | private boolean fallbackOp = true; 30 | 31 | boolean fallbackOp() { 32 | return this.fallbackOp; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /platform/bukkit/src/main/java/ca/stellardrift/permissionsex/bukkit/BukkitMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx - a permissions plugin for your server ecosystem 3 | * Copyright © 2021 zml [at] stellardrift [dot] ca and PermissionsEx contributors 4 | * 5 | * This program is free software: you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation, either version 3 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | package ca.stellardrift.permissionsex.bukkit; 19 | 20 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 21 | import ca.stellardrift.permissionsex.minecraft.command.MessageFormatter; 22 | import ca.stellardrift.permissionsex.subject.SubjectRef; 23 | import org.bukkit.command.CommandSender; 24 | import org.checkerframework.checker.nullness.qual.Nullable; 25 | 26 | final class BukkitMessageFormatter extends MessageFormatter { 27 | 28 | public BukkitMessageFormatter(final MinecraftPermissionsEx manager) { 29 | super(manager); 30 | } 31 | 32 | @Override 33 | protected @Nullable String friendlyName(final SubjectRef reference) { 34 | final @Nullable Object associated = reference.type().getAssociatedObject(reference.identifier()); 35 | return associated instanceof CommandSender ? ((CommandSender) associated).getName() : super.friendlyName(reference); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /platform/bungee/src/main/java/ca/stellardrift/permissionsex/bungee/BungeeMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.bungee; 18 | 19 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 20 | import ca.stellardrift.permissionsex.minecraft.command.MessageFormatter; 21 | import ca.stellardrift.permissionsex.proxycommon.ProxyCommon; 22 | import ca.stellardrift.permissionsex.subject.SubjectRef; 23 | import net.kyori.adventure.text.format.NamedTextColor; 24 | import net.md_5.bungee.api.CommandSender; 25 | import org.checkerframework.checker.nullness.qual.Nullable; 26 | 27 | final class BungeeMessageFormatter extends MessageFormatter { 28 | 29 | BungeeMessageFormatter(final MinecraftPermissionsEx manager) { 30 | super(manager, NamedTextColor.GOLD, NamedTextColor.YELLOW); 31 | } 32 | 33 | @Override 34 | protected String transformCommand(final String cmd) { 35 | return ProxyCommon.PROXY_COMMAND_PREFIX + cmd; 36 | } 37 | 38 | @Override 39 | protected @Nullable String friendlyName(final SubjectRef reference) { 40 | final @Nullable Object associated = reference.type().getAssociatedObject(reference.identifier()); 41 | return associated instanceof CommandSender ? ((CommandSender) associated).getName() : super.friendlyName(reference); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /platform/bungee/src/main/messages/ca/stellardrift/permissionsex/bungee/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | error.load.login=Error loading information for user {0}/{1} during handshake 19 | error.load.logout=Error unloading user {0}/{1} during disconnect 20 | -------------------------------------------------------------------------------- /platform/fabric/src/accessor/java/ca/stellardrift/permissionsex/fabric/mixin/HandshakeC2SPacketAccess.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin; 18 | 19 | import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; 20 | import org.spongepowered.asm.mixin.Mixin; 21 | import org.spongepowered.asm.mixin.gen.Accessor; 22 | 23 | @Mixin(HandshakeC2SPacket.class) 24 | public interface HandshakeC2SPacketAccess { 25 | @Accessor("address") 26 | String address(); 27 | 28 | @Accessor("port") 29 | int port(); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /platform/fabric/src/accessor/resources/permissionsex.accessor.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "ca.stellardrift.permissionsex.fabric.mixin", 4 | "compatibilityLevel": "JAVA_8", 5 | "refmap": "fabric-accessor-refmap.json", 6 | "mixins": [ 7 | "HandshakeC2SPacketAccess", 8 | "ServerCommandSourceAccess" 9 | ], 10 | "injectors": { 11 | "defaultRequire": 1 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/FabricMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl; 18 | 19 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 20 | import ca.stellardrift.permissionsex.minecraft.command.MessageFormatter; 21 | import ca.stellardrift.permissionsex.subject.SubjectRef; 22 | import net.minecraft.util.Nameable; 23 | import org.checkerframework.checker.nullness.qual.Nullable; 24 | 25 | final class FabricMessageFormatter extends MessageFormatter { 26 | 27 | FabricMessageFormatter(final MinecraftPermissionsEx manager) { 28 | super(manager); 29 | } 30 | 31 | @Override 32 | protected @Nullable String friendlyName(final SubjectRef reference) { 33 | final @Nullable Object associated = reference.type().getAssociatedObject(reference.identifier()); 34 | return associated instanceof Nameable ? ((Nameable) associated).getName().asString() : super.friendlyName(reference); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/PreLaunchInjector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl; 18 | 19 | import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import java.lang.reflect.InvocationTargetException; 24 | 25 | /** 26 | * Load Brig and Authlib for mixin purposes 27 | */ 28 | public class PreLaunchInjector implements PreLaunchEntrypoint { 29 | private static final Logger LOGGER = LoggerFactory.getLogger(PreLaunchInjector.class); 30 | 31 | @Override 32 | public void onPreLaunch() { 33 | /*try { 34 | PreLaunchHacks.hackilyLoadForMixin("com.mojang.brigadier.Message"); 35 | PreLaunchHacks.hackilyLoadForMixin("cloud.commandframework.brigadier.BrigadierManagerHolder"); 36 | } catch (final ClassNotFoundException | InvocationTargetException | IllegalAccessException ex) { 37 | LOGGER.warn("Failed to inject Brigadier into transformation path, Vanilla command permissions may not work.", ex); 38 | }*/ 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/bridge/ClientConnectionBridge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.bridge; 18 | 19 | import org.checkerframework.checker.nullness.qual.Nullable; 20 | 21 | import java.net.InetAddress; 22 | import java.net.InetSocketAddress; 23 | 24 | public interface ClientConnectionBridge { 25 | 26 | /** 27 | * The hostname a client used to connect to this server. 28 | * 29 | *

May be unresolved if the provided hostname could not be resolved.

30 | */ 31 | @Nullable InetSocketAddress virtualHost(); 32 | 33 | void virtualHost(InetSocketAddress address); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/bridge/PermissionCommandSourceBridge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.bridge; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextValue; 20 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 21 | import ca.stellardrift.permissionsex.subject.CalculatedSubject; 22 | import ca.stellardrift.permissionsex.subject.SubjectRef; 23 | import ca.stellardrift.permissionsex.subject.SubjectType; 24 | 25 | import java.util.Set; 26 | 27 | public interface PermissionCommandSourceBridge { 28 | default boolean hasPermission(final String perm) { 29 | return asCalculatedSubject().hasPermission(perm); 30 | } 31 | 32 | default CalculatedSubject asCalculatedSubject() { 33 | return FabricPermissionsEx.engine().subjects(this.permType()).get(this.permIdentifier()).join(); 34 | } 35 | 36 | default Set> activeContexts() { 37 | return asCalculatedSubject().activeContexts(); 38 | } 39 | 40 | /** 41 | * Get a reference pointing to this subject. 42 | */ 43 | default SubjectRef asReference() { 44 | return SubjectRef.subject(this.permType(), this.permIdentifier()); 45 | } 46 | 47 | SubjectType permType(); 48 | I permIdentifier(); 49 | 50 | } 51 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/bridge/ServerCommandSourceBridge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.bridge; 18 | 19 | import ca.stellardrift.permissionsex.subject.SubjectRef; 20 | import net.minecraft.server.command.ServerCommandSource; 21 | import org.checkerframework.checker.nullness.qual.Nullable; 22 | 23 | public interface ServerCommandSourceBridge { 24 | /** 25 | * Apply a permission subject override for a [ServerCommandSource]. 26 | */ 27 | ServerCommandSource withSubjectOverride(@Nullable SubjectRef override); 28 | 29 | /** 30 | * Set a new override on an existing [ServerCommandSource]. 31 | * 32 | * Internal use only 33 | * 34 | * [withSubjectOverride] should probably be used instead. 35 | */ 36 | void subjectOverride(@Nullable SubjectRef override); 37 | 38 | /** 39 | * Get the subject override for a [ServerCommandSource] 40 | */ 41 | @Nullable SubjectRef subjectOverride(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/commands/FabricCommandContextKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.commands; 18 | 19 | import cloud.commandframework.context.CommandContext; 20 | import cloud.commandframework.keys.CloudKey; 21 | import cloud.commandframework.keys.SimpleCloudKey; 22 | import io.leangen.geantyref.TypeToken; 23 | import net.minecraft.command.CommandSource; 24 | 25 | /** 26 | * Keys used in {@link CommandContext}s available within a {@link FabricCommandManager} 27 | */ 28 | public final class FabricCommandContextKeys { 29 | 30 | private FabricCommandContextKeys() { 31 | } 32 | 33 | public static final CloudKey NATIVE_COMMAND_SOURCE = SimpleCloudKey.of( 34 | "cloud:fabric_command_source", 35 | TypeToken.get(CommandSource.class) 36 | ); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/commands/FabricCommandPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.commands; 18 | 19 | import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext; 20 | import cloud.commandframework.execution.preprocessor.CommandPreprocessor; 21 | import org.checkerframework.checker.nullness.qual.NonNull; 22 | 23 | final class FabricCommandPreprocessor implements CommandPreprocessor { 24 | 25 | private final FabricCommandManager manager; 26 | 27 | FabricCommandPreprocessor(final FabricCommandManager manager) { 28 | this.manager = manager; 29 | } 30 | 31 | @Override 32 | public void accept(@NonNull final CommandPreprocessingContext context) { 33 | context.getCommandContext().store( 34 | FabricCommandContextKeys.NATIVE_COMMAND_SOURCE, 35 | this.manager.getBackwardsCommandSourceMapper().apply(context.getCommandContext().getSender()) 36 | ); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/context/CommandSourceContextDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.context; 18 | 19 | import net.minecraft.server.command.ServerCommandSource; 20 | 21 | import java.util.function.Consumer; 22 | 23 | /** 24 | * An interface that can be implemented by context definitions that can draw from 25 | * a {@link ServerCommandSource} to get current context data. 26 | */ 27 | public interface CommandSourceContextDefinition { 28 | void accumulateCurrentValues(ServerCommandSource source, Consumer consumer); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/context/IdentifierContextDefinition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.impl.context; 18 | 19 | import ca.stellardrift.permissionsex.context.ContextDefinition; 20 | import net.minecraft.util.Identifier; 21 | import org.checkerframework.checker.nullness.qual.Nullable; 22 | 23 | public abstract class IdentifierContextDefinition extends ContextDefinition { 24 | 25 | protected IdentifierContextDefinition(final String name) { 26 | super(name); 27 | } 28 | 29 | @Override 30 | public String serialize(final Identifier canonicalValue) { 31 | return canonicalValue.toString(); 32 | } 33 | 34 | @Override 35 | public @Nullable Identifier deserialize(final String userValue) { 36 | return Identifier.tryParse(userValue); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /platform/fabric/src/main/java/ca/stellardrift/permissionsex/fabric/impl/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | /** 18 | * The implementation of PermissionsEx for Fabric. 19 | */ 20 | @ApiStatus.Internal 21 | @DefaultQualifier(NonNull.class) 22 | package ca.stellardrift.permissionsex.fabric.impl; 23 | 24 | import org.checkerframework.checker.nullness.qual.NonNull; 25 | import org.checkerframework.framework.qual.DefaultQualifier; 26 | import org.jetbrains.annotations.ApiStatus; 27 | -------------------------------------------------------------------------------- /platform/fabric/src/main/messages/ca/stellardrift/permissionsex/fabric/impl/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | command.error.console=Unable to execute command {0} for sender {1} due to an error 19 | command.error.to-sender=Error executing command {0}, see console for details 20 | 21 | gameprofile.error.lookup=Unable to resolve profile {0} due to {1} 22 | 23 | mod.load.success=Loaded v{0} 24 | mod.enable.error=An error occurred while enabling PermissionsEx 25 | mod.enable.success=v{0} successfully enabled! Welcome! 26 | mod.error.shutdown-timeout=Unable to shut down PermissionsEx executor in 10 seconds, remaining tasks will be killed 27 | mod.error.unredirected-check=An operator check was made to the method {0} that PermissionsEx did not handle! 28 | 29 | 30 | integration.register.success=Successfully registered {0} permission resolver 31 | -------------------------------------------------------------------------------- /platform/fabric/src/main/messages/ca/stellardrift/permissionsex/fabric/messages.properties: -------------------------------------------------------------------------------- 1 | gameprofile.error.incomplete=Tried to check permission for incomplete game profile {0} 2 | -------------------------------------------------------------------------------- /platform/fabric/src/main/resources/fabric.mod.yml: -------------------------------------------------------------------------------- 1 | schemaVersion: 1 2 | id: "${project.rootProject.name.toLowerCase()}" 3 | version: "${project.version}" 4 | 5 | name: "${project.rootProject.name}" 6 | description: "${project.ext.pexDescription}" 7 | authors: [ zml ] 8 | contact: 9 | homepage: https://github.com/PEXPlugins/PermissionsEx 10 | issues: https://github.com/PEXPlugins/PermissionsEx/issues 11 | sources: https://github.com/PEXPlugins/PermissionsEx 12 | discord: https://discord.gg/PHpuzZS 13 | license: Apache v2.0 14 | 15 | entrypoints: 16 | preLaunch: 17 | - ca.stellardrift.permissionsex.fabric.impl.PreLaunchInjector 18 | main: 19 | - ca.stellardrift.permissionsex.fabric.impl.FabricPermissionsExImpl::INSTANCE 20 | 21 | mixins: 22 | - permissionsex.accessor.mixins.json 23 | - permissionsex.mixins.json 24 | 25 | depends: 26 | fabricloader: ">=0.4.0" 27 | adventure-platform-fabric: "*" #"^4.0.0" 28 | confabricate: "*" # "^2.0" 29 | fabric-networking-api-v1: "*" 30 | fabric-lifecycle-events-v1: "*" 31 | fabric-command-api-v1: "*" 32 | fabric-permissions-api-v0: "*" 33 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/BlockItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 22 | import net.minecraft.block.entity.BlockEntityType; 23 | import net.minecraft.entity.player.PlayerEntity; 24 | import net.minecraft.item.BlockItem; 25 | import net.minecraft.item.ItemStack; 26 | import net.minecraft.util.Identifier; 27 | import net.minecraft.util.math.BlockPos; 28 | import net.minecraft.world.World; 29 | import org.checkerframework.checker.nullness.qual.Nullable; 30 | import org.spongepowered.asm.mixin.Mixin; 31 | import org.spongepowered.asm.mixin.injection.At; 32 | import org.spongepowered.asm.mixin.injection.Redirect; 33 | 34 | @Mixin(BlockItem.class) 35 | public abstract class BlockItemMixin { 36 | 37 | @Redirect(method = "writeTagToBlockEntity", at = @At(value = "INVOKE", target = RedirectTargets.IS_CREATIVE_LEVEL_TWO_OP)) 38 | private static boolean canCopyData(PlayerEntity player, World world, PlayerEntity unused, BlockPos pos, ItemStack stack) { 39 | final @Nullable Identifier block = BlockEntityType.getId(world.getBlockEntity(pos).getType()); 40 | return FabricPermissionsEx.hasPermission(player, MinecraftPermissions.makeSpecific(MinecraftPermissions.LOAD_BLOCK_ITEM_DATA, block)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/CommandBlockExecutorMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 22 | import net.minecraft.entity.player.PlayerEntity; 23 | import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket; 24 | import net.minecraft.server.network.ServerPlayerEntity; 25 | import net.minecraft.world.CommandBlockExecutor; 26 | import org.spongepowered.asm.mixin.Mixin; 27 | import org.spongepowered.asm.mixin.injection.At; 28 | import org.spongepowered.asm.mixin.injection.Redirect; 29 | 30 | @Mixin(CommandBlockExecutor.class) 31 | public class CommandBlockExecutorMixin { 32 | @Redirect(method = "interact", at = @At(value = "INVOKE", target = RedirectTargets.IS_CREATIVE_LEVEL_TWO_OP)) 33 | public boolean canInteractWithMinecart(PlayerEntity player) { 34 | if (!player.isCreative()) { 35 | return false; 36 | } 37 | 38 | if (player instanceof ServerPlayerEntity && !FabricPermissionsEx.hasPermission(player, MinecraftPermissions.COMMAND_BLOCK_VIEW)) { 39 | ((ServerPlayerEntity) player).networkHandler.sendPacket(new CloseScreenS2CPacket()); 40 | return false; 41 | } 42 | return true; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/CommandBlockItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 22 | import net.minecraft.entity.player.PlayerEntity; 23 | import net.minecraft.item.CommandBlockItem; 24 | import net.minecraft.server.network.ServerPlayerEntity; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.injection.At; 27 | import org.spongepowered.asm.mixin.injection.Redirect; 28 | 29 | @Mixin(CommandBlockItem.class) 30 | public class CommandBlockItemMixin { 31 | @Redirect(method = "getPlacementState", 32 | at = @At(value="INVOKE", target = RedirectTargets.IS_CREATIVE_LEVEL_TWO_OP)) 33 | public boolean canPlaceCommandBlock(PlayerEntity player) { 34 | return !(player instanceof ServerPlayerEntity) || FabricPermissionsEx.hasPermission(player, MinecraftPermissions.COMMAND_BLOCK_PLACE); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/DebugStickItemMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 22 | import net.minecraft.block.BlockState; 23 | import net.minecraft.entity.player.PlayerEntity; 24 | import net.minecraft.item.DebugStickItem; 25 | import net.minecraft.item.ItemStack; 26 | import net.minecraft.util.Identifier; 27 | import net.minecraft.util.math.BlockPos; 28 | import net.minecraft.util.registry.Registry; 29 | import net.minecraft.world.WorldAccess; 30 | import org.spongepowered.asm.mixin.Mixin; 31 | import org.spongepowered.asm.mixin.injection.At; 32 | import org.spongepowered.asm.mixin.injection.Redirect; 33 | 34 | @Mixin(DebugStickItem.class) 35 | public class DebugStickItemMixin { 36 | 37 | @Redirect(method = "use", at = @At(value = "INVOKE", 38 | target = RedirectTargets.IS_CREATIVE_LEVEL_TWO_OP)) 39 | public boolean canUseDebugStick(PlayerEntity ply, PlayerEntity unused, BlockState block, 40 | WorldAccess world, BlockPos pos, boolean isRightClick, ItemStack heldItem) { 41 | Identifier usedBlock = Registry.BLOCK.getId(block.getBlock()); 42 | return FabricPermissionsEx.hasPermission(ply, MinecraftPermissions.makeSpecific(MinecraftPermissions.DEBUG_STICK_USE, usedBlock)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/EntityArgumentTypeMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 20 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 21 | import me.lucko.fabric.api.permissions.v0.Permissions; 22 | import net.minecraft.command.CommandSource; 23 | import net.minecraft.command.argument.EntityArgumentType; 24 | import net.minecraft.server.command.ServerCommandSource; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.injection.At; 27 | import org.spongepowered.asm.mixin.injection.Redirect; 28 | 29 | @Mixin(EntityArgumentType.class) 30 | public class EntityArgumentTypeMixin { 31 | 32 | @Redirect(method = "listSuggestions", at = @At(value= "INVOKE", 33 | target = RedirectTargets.COMMAND_SOURCE_HAS_PERM_LEVEL)) 34 | public boolean commandSourceHasSelectorPermission(CommandSource source, int level) { 35 | return !(source instanceof ServerCommandSource) 36 | || Permissions.check(source, MinecraftPermissions.USE_SELECTOR); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/EntitySelectorMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 20 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 21 | import me.lucko.fabric.api.permissions.v0.Permissions; 22 | import net.minecraft.command.EntitySelector; 23 | import net.minecraft.server.command.ServerCommandSource; 24 | import org.spongepowered.asm.mixin.Mixin; 25 | import org.spongepowered.asm.mixin.injection.At; 26 | import org.spongepowered.asm.mixin.injection.Redirect; 27 | 28 | @Mixin(EntitySelector.class) 29 | public class EntitySelectorMixin { 30 | 31 | /** 32 | * Redirect op level selector usage check to a permission 33 | * 34 | * @param src The source requesting this permission 35 | * @param permissionLevel Generally 2, unused 36 | * @return Permission result 37 | */ 38 | @Redirect(method = "checkSourcePermission", 39 | at = @At(value = "INVOKE", target = RedirectTargets.SERVER_COMMAND_SOURCE_HAS_PERM_LEVEL)) 40 | public boolean commandSourceHasPermission(ServerCommandSource src, int permissionLevel) { 41 | return Permissions.check(src, MinecraftPermissions.USE_SELECTOR); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/EntityTypeMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 22 | import com.mojang.authlib.GameProfile; 23 | import net.minecraft.entity.Entity; 24 | import net.minecraft.entity.EntityType; 25 | import net.minecraft.entity.player.PlayerEntity; 26 | import net.minecraft.nbt.CompoundTag; 27 | import net.minecraft.server.PlayerManager; 28 | import net.minecraft.util.Identifier; 29 | import net.minecraft.world.World; 30 | import org.spongepowered.asm.mixin.Mixin; 31 | import org.spongepowered.asm.mixin.injection.At; 32 | import org.spongepowered.asm.mixin.injection.Redirect; 33 | 34 | @Mixin(EntityType.class) 35 | public class EntityTypeMixin { 36 | @Redirect(method = "loadFromEntityTag", at = @At(value = "INVOKE", target = RedirectTargets.PLAYER_MANAGER_IS_OP)) 37 | private static boolean canLoadRestrictedEntityData(PlayerManager self, GameProfile profile, World world, PlayerEntity player, Entity spawnedEntity, CompoundTag data) { 38 | final Identifier entityType = EntityType.getId(spawnedEntity.getType()); 39 | return FabricPermissionsEx.hasPermission(player, MinecraftPermissions.LOAD_ENTITY_DATA + "." + entityType.getNamespace() + "." + entityType.getPath()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/MessageArgumentTypeMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 20 | import ca.stellardrift.permissionsex.fabric.impl.RedirectTargets; 21 | import me.lucko.fabric.api.permissions.v0.Permissions; 22 | import net.minecraft.command.argument.MessageArgumentType; 23 | import net.minecraft.server.command.ServerCommandSource; 24 | import org.spongepowered.asm.mixin.Mixin; 25 | import org.spongepowered.asm.mixin.injection.At; 26 | import org.spongepowered.asm.mixin.injection.Redirect; 27 | 28 | @Mixin(MessageArgumentType.class) 29 | public class MessageArgumentTypeMixin { 30 | 31 | @Redirect(method = "getMessage", at = @At(value = "INVOKE", 32 | target = RedirectTargets.SERVER_COMMAND_SOURCE_HAS_PERM_LEVEL)) 33 | private static boolean canCommandSourceUseSelectors(ServerCommandSource src, int opLevel) { 34 | return Permissions.check(src, MinecraftPermissions.USE_SELECTOR); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/check/StructureBlockEntityMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.check; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.MinecraftPermissions; 21 | import net.minecraft.block.entity.StructureBlockBlockEntity; 22 | import net.minecraft.entity.player.PlayerEntity; 23 | import net.minecraft.network.packet.s2c.play.CloseScreenS2CPacket; 24 | import net.minecraft.server.network.ServerPlayerEntity; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.injection.At; 27 | import org.spongepowered.asm.mixin.injection.Redirect; 28 | 29 | @Mixin(StructureBlockBlockEntity.class) 30 | public class StructureBlockEntityMixin { 31 | @Redirect(method = "openScreen", at = @At(value = "INVOKE", target = "net.minecraft.entity.player.PlayerEntity.isCreativeLevelTwoOp()Z")) 32 | public boolean canViewStructureBlock(PlayerEntity player) { 33 | if (player instanceof ServerPlayerEntity 34 | && !FabricPermissionsEx.hasPermission(player, MinecraftPermissions.STRUCTURE_BLOCK_VIEW)) { 35 | ((ServerPlayerEntity) player).networkHandler.sendPacket(new CloseScreenS2CPacket()); 36 | return false; 37 | } 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/lifecycle/ClientConnectionMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.lifecycle; 18 | 19 | import ca.stellardrift.permissionsex.fabric.impl.bridge.ClientConnectionBridge; 20 | import io.netty.channel.Channel; 21 | import net.minecraft.network.ClientConnection; 22 | import org.checkerframework.checker.nullness.qual.Nullable; 23 | import org.spongepowered.asm.mixin.Mixin; 24 | import org.spongepowered.asm.mixin.Shadow; 25 | 26 | import java.net.InetSocketAddress; 27 | import java.net.SocketAddress; 28 | 29 | @Mixin(ClientConnection.class) 30 | public class ClientConnectionMixin implements ClientConnectionBridge { 31 | @Shadow 32 | private Channel channel; 33 | 34 | private @Nullable InetSocketAddress pex$virtualHost; 35 | 36 | @Override 37 | public @Nullable InetSocketAddress virtualHost() { 38 | if (this.pex$virtualHost == null) { 39 | SocketAddress tempAddress = channel.localAddress(); 40 | if (tempAddress instanceof InetSocketAddress) { 41 | return ((InetSocketAddress) tempAddress); 42 | } 43 | } else { 44 | return this.pex$virtualHost; 45 | } 46 | return null; 47 | } 48 | 49 | @Override 50 | public void virtualHost(final InetSocketAddress address) { 51 | if (this.pex$virtualHost != null) { 52 | throw new IllegalStateException("Virtual host can only be set once per connection!"); 53 | } 54 | this.pex$virtualHost = address; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/lifecycle/GameProfileMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.lifecycle; 18 | 19 | import ca.stellardrift.permissionsex.minecraft.profile.MinecraftProfile; 20 | import com.mojang.authlib.GameProfile; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.Shadow; 23 | 24 | import java.util.UUID; 25 | 26 | @Mixin(value = GameProfile.class, remap = false) 27 | public abstract class GameProfileMixin implements MinecraftProfile { 28 | @Shadow 29 | public abstract String getName(); 30 | 31 | @Shadow 32 | public abstract UUID getId(); 33 | 34 | @Override 35 | public String name() { 36 | return this.getName(); 37 | } 38 | 39 | // uuid() is implemented by adventure-platform-fabric 40 | } 41 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/lifecycle/MinecraftClientMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.lifecycle; 18 | 19 | import ca.stellardrift.permissionsex.fabric.impl.FabricPermissionsExImpl; 20 | import net.minecraft.client.MinecraftClient; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.injection.At; 23 | import org.spongepowered.asm.mixin.injection.Inject; 24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 25 | 26 | @Mixin(MinecraftClient.class) 27 | public class MinecraftClientMixin { 28 | 29 | @Inject(method = "close", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/model/BakedModelManager;close()V")) 30 | private void pex$fireShutdown(final CallbackInfo ci) { 31 | FabricPermissionsExImpl.INSTANCE.shutdown(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/lifecycle/MinecraftDedicatedServerMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.lifecycle; 18 | 19 | import ca.stellardrift.permissionsex.fabric.impl.FabricPermissionsExImpl; 20 | import net.minecraft.server.dedicated.MinecraftDedicatedServer; 21 | import org.spongepowered.asm.mixin.Mixin; 22 | import org.spongepowered.asm.mixin.injection.At; 23 | import org.spongepowered.asm.mixin.injection.Inject; 24 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 25 | 26 | @Mixin(MinecraftDedicatedServer.class) 27 | public class MinecraftDedicatedServerMixin { 28 | 29 | @Inject(method = "shutdown", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;shutdownExecutors()V")) 30 | private void pex$fireShutdown(final CallbackInfo ci) { 31 | FabricPermissionsExImpl.INSTANCE.shutdown(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/lifecycle/ServerHandshakeNetworkHandlerMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.lifecycle; 18 | 19 | import ca.stellardrift.permissionsex.fabric.impl.bridge.ClientConnectionBridge; 20 | import ca.stellardrift.permissionsex.fabric.mixin.HandshakeC2SPacketAccess; 21 | import net.minecraft.network.ClientConnection; 22 | import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket; 23 | import net.minecraft.server.network.ServerHandshakeNetworkHandler; 24 | import org.spongepowered.asm.mixin.Final; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | import org.spongepowered.asm.mixin.Shadow; 27 | import org.spongepowered.asm.mixin.injection.At; 28 | import org.spongepowered.asm.mixin.injection.Inject; 29 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; 30 | 31 | import java.net.InetSocketAddress; 32 | 33 | @Mixin(ServerHandshakeNetworkHandler.class) 34 | public class ServerHandshakeNetworkHandlerMixin { 35 | @Shadow @Final 36 | private ClientConnection connection; 37 | 38 | @Inject(method = "onHandshake", at = @At("HEAD")) 39 | public void applyVirtualHostToConnection(HandshakeC2SPacket handshakePacket, CallbackInfo ci) { 40 | final ClientConnectionBridge conn = (ClientConnectionBridge) connection; 41 | final HandshakeC2SPacketAccess packet = (HandshakeC2SPacketAccess) handshakePacket; 42 | final InetSocketAddress addr = new InetSocketAddress(packet.address(), packet.port()); 43 | conn.virtualHost(addr); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/source/CommandBlockExecutorMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.source; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.impl.bridge.PermissionCommandSourceBridge; 21 | import ca.stellardrift.permissionsex.subject.CalculatedSubject; 22 | import ca.stellardrift.permissionsex.subject.SubjectType; 23 | import net.minecraft.text.Text; 24 | import net.minecraft.world.CommandBlockExecutor; 25 | import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 26 | import org.jetbrains.annotations.NotNull; 27 | import org.spongepowered.asm.mixin.Mixin; 28 | import org.spongepowered.asm.mixin.Shadow; 29 | 30 | @Mixin(CommandBlockExecutor.class) 31 | public class CommandBlockExecutorMixin implements PermissionCommandSourceBridge { 32 | private volatile @MonotonicNonNull CalculatedSubject pex$subject; 33 | 34 | @Shadow private Text customName; 35 | 36 | @Override 37 | public @NotNull SubjectType permType() { 38 | return FabricPermissionsEx.commandBlocks().type(); 39 | } 40 | 41 | @Override 42 | public @NotNull String permIdentifier() { 43 | return this.customName.asString(); 44 | } 45 | 46 | @Override 47 | public @NotNull CalculatedSubject asCalculatedSubject() { 48 | if (this.pex$subject == null) { 49 | return this.pex$subject = FabricPermissionsEx.engine().subjects(this.permType()).get(this.permIdentifier()).join(); 50 | } 51 | return this.pex$subject; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/java/ca/stellardrift/permissionsex/fabric/mixin/source/RconCommandOutputMixin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.fabric.mixin.source; 18 | 19 | import ca.stellardrift.permissionsex.fabric.FabricPermissionsEx; 20 | import ca.stellardrift.permissionsex.fabric.impl.FabricPermissionsExImpl; 21 | import ca.stellardrift.permissionsex.fabric.impl.bridge.PermissionCommandSourceBridge; 22 | import ca.stellardrift.permissionsex.subject.SubjectType; 23 | import net.minecraft.server.rcon.RconCommandOutput; 24 | import org.jetbrains.annotations.NotNull; 25 | import org.spongepowered.asm.mixin.Mixin; 26 | 27 | /** 28 | * Class is misnamed in Fabric -- this is actually the command output for rcon connections 29 | */ 30 | @Mixin(RconCommandOutput.class) 31 | public class RconCommandOutputMixin implements PermissionCommandSourceBridge { 32 | @Override 33 | public @NotNull SubjectType permType() { 34 | return FabricPermissionsEx.system().type(); 35 | } 36 | 37 | @Override 38 | public @NotNull String permIdentifier() { 39 | return FabricPermissionsExImpl.IDENTIFIER_RCON; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /platform/fabric/src/mixin/resources/permissionsex.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "ca.stellardrift.permissionsex.fabric.mixin", 4 | "compatibilityLevel": "JAVA_8", 5 | "mixins": [ 6 | "check.ArgumentBuilderMixin", 7 | "check.BlockItemMixin", 8 | "check.CommandBlockExecutorMixin", 9 | "check.CommandBlockItemMixin", 10 | "check.DebugStickItemMixin", 11 | "check.DedicatedPlayerManagerMixin", 12 | "check.DedicatedServerMixin", 13 | "check.EntityArgumentTypeMixin", 14 | "check.EntitySelectorMixin", 15 | "check.EntityTypeMixin", 16 | "check.MessageArgumentTypeMixin", 17 | "check.PlayerManagerMixin", 18 | "check.ServerCommandSourceMixin", 19 | "check.ServerPlayerEntityMixin", 20 | "check.ServerPlayerInteractionManagerMixin", 21 | "check.ServerPlayNetworkHandlerMixin", 22 | "check.StructureBlockEntityMixin", 23 | "lifecycle.ClientConnectionMixin", 24 | "lifecycle.GameProfileMixin", 25 | "lifecycle.MinecraftDedicatedServerMixin", 26 | "lifecycle.ServerHandshakeNetworkHandlerMixin", 27 | "source.CommandBlockExecutorMixin", 28 | "source.CommandFunctionFunctionElementMixin", 29 | "source.CommandFunctionManagerMixin", 30 | "source.FunctionLoaderMixin", 31 | "source.RconCommandOutputMixin", 32 | "source.ServerCommandSourceMixin", 33 | "source.ServerPlayerEntityMixin" 34 | ], 35 | "client": [ 36 | "lifecycle.MinecraftClientMixin" 37 | ], 38 | "injectors": { 39 | "defaultRequire": 1, 40 | "injectionPoints": [ 41 | "ca.stellardrift.permissionsex.fabric.impl.WitherMutatorInjectionPoint" 42 | ] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /platform/sponge/src/main/java/ca/stellardrift/permissionsex/sponge/SpongeMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.sponge; 18 | 19 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 20 | import ca.stellardrift.permissionsex.minecraft.command.MessageFormatter; 21 | import ca.stellardrift.permissionsex.subject.SubjectRef; 22 | import org.checkerframework.checker.nullness.qual.Nullable; 23 | import org.spongepowered.api.util.Nameable; 24 | 25 | final class SpongeMessageFormatter extends MessageFormatter { 26 | 27 | SpongeMessageFormatter(final MinecraftPermissionsEx manager) { 28 | super(manager); 29 | } 30 | 31 | @Override 32 | protected @Nullable String friendlyName(final SubjectRef reference) { 33 | final @Nullable Object associated = reference.type().getAssociatedObject(reference.identifier()); 34 | return associated instanceof Nameable ? ((Nameable) associated).name() : super.friendlyName(reference); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /platform/sponge/src/main/java/ca/stellardrift/permissionsex/sponge/Timings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.sponge; 18 | 19 | import co.aikar.timings.Timing; 20 | import org.spongepowered.plugin.PluginContainer; 21 | 22 | final class Timings { 23 | private final PluginContainer plugin; 24 | final OnlyIfSyncTiming getSubject; 25 | final OnlyIfSyncTiming getActiveContexts; 26 | final OnlyIfSyncTiming getPermission; 27 | final OnlyIfSyncTiming getOption; 28 | final OnlyIfSyncTiming getParents; 29 | 30 | Timings(final PluginContainer plugin) { 31 | this.plugin = plugin; 32 | this.getSubject = timing("getSubject"); 33 | this.getActiveContexts = timing("getActiveContexts"); 34 | this.getPermission = timing("getPermission"); 35 | this.getOption = timing("getOption"); 36 | this.getParents = timing("getParents"); 37 | } 38 | 39 | private OnlyIfSyncTiming timing(final String key) { 40 | return new OnlyIfSyncTiming(co.aikar.timings.Timings.of(this.plugin, key)); 41 | } 42 | 43 | static class OnlyIfSyncTiming implements AutoCloseable { 44 | private final Timing timing; 45 | 46 | OnlyIfSyncTiming(final Timing timing) { 47 | this.timing = timing; 48 | } 49 | 50 | public OnlyIfSyncTiming start() { 51 | this.timing.startTimingIfSync(); 52 | return this; 53 | } 54 | 55 | @Override 56 | public void close() { 57 | this.timing.stopTimingIfSync(); 58 | } 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /platform/sponge/src/main/java/ca/stellardrift/permissionsex/sponge/rank/RankingService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.sponge.rank; 18 | 19 | import ca.stellardrift.permissionsex.rank.RankLadder; 20 | 21 | public interface RankingService { 22 | /** 23 | * Get a ladder by name. This will create a new ladder if none exists yet. 24 | * 25 | * @param ladder The name of the ladder to get. Case-insensitive. 26 | * @return the ladder 27 | */ 28 | RankLadder getLadder(String ladder); 29 | 30 | /** 31 | * Return whether or not this ladder is present 32 | * 33 | * @param ladder The ladder to check. Case-insensitive 34 | * @return Whether this ladder is present 35 | */ 36 | boolean hasLadder(String ladder); 37 | } 38 | -------------------------------------------------------------------------------- /platform/sponge/src/main/java/ca/stellardrift/permissionsex/sponge/rank/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | @DefaultQualifier(NonNull.class) 18 | package ca.stellardrift.permissionsex.sponge.rank; 19 | 20 | import org.checkerframework.checker.nullness.qual.NonNull; 21 | import org.checkerframework.framework.qual.DefaultQualifier; 22 | -------------------------------------------------------------------------------- /platform/sponge/src/main/messages/ca/stellardrift/permissionsex/sponge/command/messages.properties: -------------------------------------------------------------------------------- 1 | commands.registrar.error.unknown=Could not find command '{0}' in this registrar! 2 | -------------------------------------------------------------------------------- /platform/sponge/src/main/messages/ca/stellardrift/permissionsex/sponge/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | plugin.init.begin=Pre-init of {0} v{1} 19 | plugin.init.error.general=Error occurred while enabling {0} 20 | plugin.shutdown.begin=Disabling {0} 21 | plugin.data-source.error=Unable to get data source for JDBC URL {0} 22 | 23 | event.client-auth.error=Error while loading data for user {0}/{1} during prelogin 24 | 25 | migration.bukkit.begin=Migrating configuration data from Bukkit 26 | migration.legacy-sponge.success=Migrated legacy Sponge config directory to new location. Configuration is now located in {0} 27 | 28 | commands.fake-op.description=A no-op replacement for Vanilla's operator commands 29 | commands.fake-op.arg.user=user 30 | commands.fake-op.error=PermissionsEx replaces the server op/deop commands. Use PEX commands to manage permissions instead! 31 | 32 | 33 | -------------------------------------------------------------------------------- /platform/sponge/src/main/resources/META-INF/plugins.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - loader: java_plain 3 | id: "${project.rootProject.name.toLowerCase()}" 4 | name: "${project.rootProject.name}" 5 | version: "${project.version}" 6 | main-class: ca.stellardrift.permissionsex.sponge.PermissionsExPlugin 7 | description: "${project.description}" 8 | links: 9 | homepage: "${project.indra.scm.get().url}" 10 | issues: "${project.indra.issues.get().url}" 11 | source: "${project.indra.scm.get().url}" 12 | contributors: 13 | - name: "zml" 14 | description: "permission herder" 15 | dependencies: 16 | - id: spongeapi 17 | version: 8.0.0 18 | -------------------------------------------------------------------------------- /platform/sponge/src/main/templates/ca/stellardrift/permissionsex/sponge/ProjectData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.sponge; 18 | 19 | final class ProjectData { 20 | 21 | private ProjectData() { 22 | } 23 | 24 | static final String ARTIFACT_ID = "${project.rootProject.name.toLowerCase()}"; 25 | static final String NAME = "${project.rootProject.name}"; 26 | static final String VERSION = "${project.version}${project.ext.pexSuffix}"; 27 | static final String DESCRIPTION = "${project.ext.pexDescription}"; 28 | } 29 | -------------------------------------------------------------------------------- /platform/sponge7/src/main/kotlin/ca/stellardrift/permissionsex/sponge/Timings.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.sponge 18 | 19 | import co.aikar.timings.Timing 20 | import co.aikar.timings.Timings 21 | 22 | class Timings(private val plugin: PermissionsExPlugin) { 23 | val getSubject: Timing = timing("getSubject") 24 | val getActiveContexts: Timing = timing("getActiveContexts") 25 | val getPermission: Timing = timing("getPermission") 26 | val getOption: Timing = timing("getOption") 27 | val getParents: Timing = timing("getParents") 28 | 29 | private fun timing(key: String): Timing { 30 | return Timings.of(plugin, key) 31 | } 32 | } 33 | 34 | inline fun Timing.time(action: () -> T): T { 35 | startTimingIfSync() 36 | try { 37 | return action() 38 | } finally { 39 | stopTimingIfSync() 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /platform/sponge7/src/main/messages/ca/stellardrift/permissionsex/sponge/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | plugin.init.begin=Pre-init of {0} v{1} 19 | plugin.init.error.general=Error occurred while enabling {0} 20 | plugin.init.error.other-provider-installed=You appear to already be using a different permissions plugin! We will now disable. 21 | plugin.shutdown.begin=Disabling {0} 22 | plugin.data-source.error=Unable to get data source for JDBC URL {0} 23 | 24 | event.client-auth.error=Error while loading data for user {0}/{1} during prelogin 25 | 26 | formatter.error.subject-name=Unable to get name for subject {0} 27 | formatter.button.info-prompt=Click here to view more information 28 | 29 | migration.bukkit.begin=Migrating configuration data from Bukkit 30 | migration.legacy-sponge.success=Migrated legacy Sponge config directory to new location. Configuration is now located in {0} 31 | 32 | commands.fake-op.description=A no-op replacement for Vanilla's operator commands 33 | commands.fake-op.arg.user=user 34 | commands.fake-op.error=PermissionsEx replaces the server op/deop commands. Use PEX commands to manage permissions instead! 35 | 36 | 37 | -------------------------------------------------------------------------------- /platform/sponge7/src/main/templates/ca/stellardrift/permissionsex/sponge/PomData.kt: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package ca.stellardrift.permissionsex.sponge 19 | 20 | object PomData { 21 | const val ARTIFACT_ID = "${project.rootProject.name.toLowerCase()}" 22 | const val NAME = "${project.rootProject.name}" 23 | const val VERSION = "${project.version}${project.ext.pexSuffix}" 24 | const val DESCRIPTION = "${project.ext.pexDescription}" 25 | } 26 | -------------------------------------------------------------------------------- /platform/velocity/src/main/java/ca/stellardrift/permissionsex/velocity/VelocityMessageFormatter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package ca.stellardrift.permissionsex.velocity; 18 | 19 | import ca.stellardrift.permissionsex.minecraft.MinecraftPermissionsEx; 20 | import ca.stellardrift.permissionsex.minecraft.command.MessageFormatter; 21 | import ca.stellardrift.permissionsex.proxycommon.ProxyCommon; 22 | import net.kyori.adventure.text.format.NamedTextColor; 23 | 24 | final class VelocityMessageFormatter extends MessageFormatter { 25 | 26 | VelocityMessageFormatter(final MinecraftPermissionsEx manager) { 27 | super(manager, NamedTextColor.GOLD, NamedTextColor.YELLOW); 28 | } 29 | 30 | @Override 31 | protected String transformCommand(final String cmd) { 32 | return ProxyCommon.PROXY_COMMAND_PREFIX + cmd; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /platform/velocity/src/main/java/ca/stellardrift/permissionsex/velocity/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | /** 18 | * The Velocity implementation of PermissionsEx. 19 | */ 20 | @DefaultQualifier(NonNull.class) 21 | package ca.stellardrift.permissionsex.velocity; 22 | 23 | import org.checkerframework.checker.nullness.qual.NonNull; 24 | import org.checkerframework.framework.qual.DefaultQualifier; 25 | -------------------------------------------------------------------------------- /platform/velocity/src/main/messages/ca/stellardrift/permissionsex/velocity/messages.properties: -------------------------------------------------------------------------------- 1 | # 2 | # PermissionsEx 3 | # Copyright (C) zml and PermissionsEx contributors 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | plugin.reload.error=Failed to reload PermissionsEx! See error below for more details. 19 | plugin.init.error=Unable to load PermissionsEx engine 20 | plugin.init.success=Successfully enabled {0} v{1} 21 | plugin.disable.timeout=Unable to close executor nicely, tasks did not finish in time! 22 | plugin.disable.success=Successfully disabled {0} v{1} -- see you next time! 23 | -------------------------------------------------------------------------------- /platform/velocity/src/main/templates/ca/stellardrift/permissionsex/velocity/ProjectData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * PermissionsEx 3 | * Copyright (C) zml and PermissionsEx contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package ca.stellardrift.permissionsex.velocity; 19 | 20 | final class ProjectData { 21 | 22 | private ProjectData() { 23 | } 24 | 25 | static final String ARTIFACT_ID = "${project.rootProject.name.toLowerCase()}"; 26 | static final String NAME = "${project.rootProject.name}"; 27 | static final String VERSION = "${project.version}${project.ext.pexSuffix}"; 28 | static final String DESCRIPTION = "${project.ext.pexDescription}"; 29 | } 30 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "ignoreDeps": [ 6 | "net.fabricmc.fabric-api:fabric-api", 7 | "org.checkerframework:checker-qual", 8 | "org.spongepowered:spongevanilla" 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "PermissionsEx" 2 | 3 | include("api") 4 | include("core") 5 | 6 | listOf("sponge", "sponge7", "bukkit", "fabric", "bungee", "velocity").forEach { 7 | include(":platform:$it") 8 | } 9 | 10 | listOf("proxy-common", "hikari-config", "minecraft", "glob", "legacy").forEach { 11 | include("impl-blocks:$it") 12 | } 13 | 14 | // listOf("file", "sql", "conversion").forEach { 15 | listOf("file", "sql").forEach { 16 | include(":datastore:$it") 17 | } 18 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | {pkgs ? import {}, jdk ? pkgs.jdk11 }: 2 | let 3 | gradle6 = pkgs.callPackage gradle/gradle.nix { java = jdk; }; 4 | in 5 | pkgs.mkShell { 6 | buildInputs = with pkgs; [ jdk gradle6 gitAndTools.gitFull ]; 7 | } 8 | -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | org.apache.maven.skins 12 | maven-fluido-skin 13 | 1.3.1 14 | 15 | 16 | --------------------------------------------------------------------------------