Repository navigation
feat: New plugin made to support LuckPerms #1258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
880ec19
feat: New plugin made to support LuckPerms
RobotHanzo 20b51e2
fix: Declare dependency on LuckPerms in plugin configurations
RobotHanzo 6ef963e
chore: Use DI where necessary
RobotHanzo 2266feb
Merge remote-tracking branch 'refs/remotes/upstream/nightly' into luc…
RobotHanzo ea86b2f
Dependency Updates and removal of addon from plugin name
RobotHanzo 11c0655
Fixed merge issue
RobotHanzo b36db3b
chore: apply spotless
0utplay 3d58456
Add context suggestions
RobotHanzo a4d53eb
Apply suggestions from code review
RobotHanzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import net.fabricmc.loom.task.RemapJarTask | ||
|
|
||
| /* | ||
| * Copyright 2019-2023 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| plugins { | ||
| alias(libs.plugins.fabricLoom) | ||
| } | ||
|
|
||
|
|
||
| dependencies { | ||
| "compileOnly"(libs.bundles.proxyPlatform) | ||
| "compileOnly"(libs.bundles.serverPlatform) | ||
|
|
||
| "compileOnly"(libs.luckPermsApi) | ||
| "compileOnly"(projects.wrapperJvm) | ||
| "compileOnly"(projects.modules.bridge) | ||
|
|
||
| "minecraft"(libs.minecraft) | ||
| "modCompileOnly"(libs.fabricLoader) | ||
| "mappings"(loom.officialMojangMappings()) | ||
| } | ||
|
|
||
| tasks.withType<RemapJarTask> { | ||
| // base setup | ||
| archiveFileName.set(Files.luckPermsPlugin) | ||
| } |
50 changes: 50 additions & 0 deletions
50
...s/luckperms/src/main/java/eu/cloudnetservice/plugins/luckperms/BukkitLuckPermsPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright 2019-2024 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package eu.cloudnetservice.plugins.luckperms; | ||
|
|
||
| import eu.cloudnetservice.ext.platforminject.api.PlatformEntrypoint; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.Dependency; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.PlatformPlugin; | ||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Singleton; | ||
| import lombok.NonNull; | ||
| import net.luckperms.api.LuckPermsProvider; | ||
|
|
||
| @Singleton | ||
| @PlatformPlugin( | ||
| platform = "bukkit", | ||
| name = "CloudNet-LuckPerms", | ||
| authors = "CloudNetService", | ||
| version = "@version@", | ||
| description = "Brings LuckPerms support to all server platforms", | ||
| pluginFileNames = "plugin.yml", | ||
| dependencies = @Dependency(name = "LuckPerms") | ||
| ) | ||
| public class BukkitLuckPermsPlugin implements PlatformEntrypoint { | ||
|
|
||
| private final CloudNetContextCalculator cloudNetContextCalculator; | ||
|
|
||
| @Inject | ||
| public BukkitLuckPermsPlugin(@NonNull CloudNetContextCalculator cloudNetContextCalculator) { | ||
| this.cloudNetContextCalculator = cloudNetContextCalculator; | ||
| } | ||
|
|
||
| @Override | ||
| public void onLoad() { | ||
| LuckPermsProvider.get().getContextManager().registerCalculator(this.cloudNetContextCalculator); | ||
| } | ||
| } |
49 changes: 49 additions & 0 deletions
49
...ckperms/src/main/java/eu/cloudnetservice/plugins/luckperms/BungeecordLuckPermsPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /* | ||
| * Copyright 2019-2024 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package eu.cloudnetservice.plugins.luckperms; | ||
|
|
||
| import eu.cloudnetservice.ext.platforminject.api.PlatformEntrypoint; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.Dependency; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.PlatformPlugin; | ||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Singleton; | ||
| import lombok.NonNull; | ||
| import net.luckperms.api.LuckPermsProvider; | ||
|
|
||
| @Singleton | ||
| @PlatformPlugin( | ||
| platform = "bungeecord", | ||
| name = "CloudNet-LuckPerms", | ||
| authors = "CloudNetService", | ||
| version = "@version@", | ||
| description = "Brings LuckPerms support to all server platforms", | ||
| dependencies = @Dependency(name = "LuckPerms") | ||
| ) | ||
| public class BungeecordLuckPermsPlugin implements PlatformEntrypoint { | ||
|
|
||
| private final CloudNetContextCalculator cloudNetContextCalculator; | ||
|
|
||
| @Inject | ||
| public BungeecordLuckPermsPlugin(@NonNull CloudNetContextCalculator cloudNetContextCalculator) { | ||
| this.cloudNetContextCalculator = cloudNetContextCalculator; | ||
| } | ||
|
|
||
| @Override | ||
| public void onLoad() { | ||
| LuckPermsProvider.get().getContextManager().registerCalculator(this.cloudNetContextCalculator); | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
...ckperms/src/main/java/eu/cloudnetservice/plugins/luckperms/CloudNetContextCalculator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright 2019-2024 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package eu.cloudnetservice.plugins.luckperms; | ||
|
|
||
| import eu.cloudnetservice.wrapper.configuration.WrapperConfiguration; | ||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Singleton; | ||
| import lombok.NonNull; | ||
| import net.luckperms.api.context.ContextConsumer; | ||
| import net.luckperms.api.context.ContextSet; | ||
| import net.luckperms.api.context.MutableContextSet; | ||
| import net.luckperms.api.context.StaticContextCalculator; | ||
|
|
||
| @Singleton | ||
| public class CloudNetContextCalculator implements StaticContextCalculator { | ||
|
|
||
| private final WrapperConfiguration wrapperConfiguration; | ||
|
|
||
| @Inject | ||
| public CloudNetContextCalculator(@NonNull WrapperConfiguration wrapperConfiguration) { | ||
| this.wrapperConfiguration = wrapperConfiguration; | ||
| } | ||
|
|
||
| private @NonNull ContextSet contextSet() { | ||
| var contextSet = MutableContextSet.create(); | ||
| var serviceId = this.wrapperConfiguration.serviceConfiguration().serviceId(); | ||
|
|
||
| contextSet.add("service", serviceId.name()); | ||
| contextSet.add("task", serviceId.taskName()); | ||
| contextSet.add("node", serviceId.nodeUniqueId()); | ||
| contextSet.add("environment", serviceId.environmentName()); | ||
| for (var group : this.wrapperConfiguration.serviceConfiguration().groups()) { | ||
| contextSet.add("group", group); | ||
| } | ||
| return contextSet; | ||
| } | ||
|
|
||
| @Override | ||
| public void calculate(@NonNull ContextConsumer consumer) { | ||
| consumer.accept(this.contextSet()); | ||
| } | ||
|
|
||
| @Override | ||
| public @NonNull ContextSet estimatePotentialContexts() { | ||
| return this.contextSet(); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
...s/luckperms/src/main/java/eu/cloudnetservice/plugins/luckperms/FabricLuckPermsPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright 2019-2024 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package eu.cloudnetservice.plugins.luckperms; | ||
|
|
||
| import eu.cloudnetservice.ext.platforminject.api.PlatformEntrypoint; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.Dependency; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.PlatformPlugin; | ||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Singleton; | ||
| import lombok.NonNull; | ||
| import net.luckperms.api.LuckPermsProvider; | ||
|
|
||
| @Singleton | ||
| @PlatformPlugin( | ||
| platform = "fabric", | ||
| name = "CloudNet-LuckPerms", | ||
| version = "@version@", | ||
| dependencies = { | ||
| @Dependency(name = "fabricloader", version = ">=0.14.17"), | ||
| @Dependency(name = "minecraft", version = ">=1.20.4"), | ||
| @Dependency(name = "java", version = ">=17"), | ||
| @Dependency(name = "LuckPerms") | ||
| }, | ||
| authors = "CloudNetService", | ||
| description = "Brings LuckPerms support to all server platforms" | ||
| ) | ||
| public class FabricLuckPermsPlugin implements PlatformEntrypoint { | ||
|
|
||
| private final CloudNetContextCalculator cloudNetContextCalculator; | ||
|
|
||
| @Inject | ||
| public FabricLuckPermsPlugin(@NonNull CloudNetContextCalculator cloudNetContextCalculator) { | ||
| this.cloudNetContextCalculator = cloudNetContextCalculator; | ||
| } | ||
|
|
||
| @Override | ||
| public void onLoad() { | ||
| LuckPermsProvider.get().getContextManager().registerCalculator(this.cloudNetContextCalculator); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
...s/luckperms/src/main/java/eu/cloudnetservice/plugins/luckperms/NukkitLuckPermsPlugin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * Copyright 2019-2024 CloudNetService team & contributors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package eu.cloudnetservice.plugins.luckperms; | ||
|
|
||
| import eu.cloudnetservice.ext.platforminject.api.PlatformEntrypoint; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.Dependency; | ||
| import eu.cloudnetservice.ext.platforminject.api.stereotype.PlatformPlugin; | ||
| import jakarta.inject.Inject; | ||
| import jakarta.inject.Singleton; | ||
| import lombok.NonNull; | ||
| import net.luckperms.api.LuckPermsProvider; | ||
|
|
||
| @Singleton | ||
| @PlatformPlugin( | ||
| platform = "nukkit", | ||
| api = "1.0.5", | ||
| name = "CloudNet-LuckPerms", | ||
| version = "@version@", | ||
| authors = "CloudNetService", | ||
| description = "Brings LuckPerms support to all server platforms", | ||
| dependencies = @Dependency(name = "LuckPerms") | ||
| ) | ||
| public class NukkitLuckPermsPlugin implements PlatformEntrypoint { | ||
|
|
||
| private final CloudNetContextCalculator cloudNetContextCalculator; | ||
|
|
||
| @Inject | ||
| public NukkitLuckPermsPlugin(@NonNull CloudNetContextCalculator cloudNetContextCalculator) { | ||
| this.cloudNetContextCalculator = cloudNetContextCalculator; | ||
| } | ||
|
|
||
| @Override | ||
| public void onLoad() { | ||
| LuckPermsProvider.get().getContextManager().registerCalculator(this.cloudNetContextCalculator); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.