mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 14:38:48 +00:00
Hard depend LP, some cleanup
This commit is contained in:
1 parent
2187d4ce66
commit
a6cc4ac818
8 files changed
+32
-75
No files matched your search
@@ -19,7 +19,6 @@ dependencies {
|
||||
|
||||
// Plugins
|
||||
compileOnly("me.clip:placeholderapi:2.10.9")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
||||
}
|
||||
|
||||
carbonShadowPlatform {
|
||||
@@ -43,7 +42,8 @@ bukkit {
|
||||
main = "net.draycia.carbon.bukkit.CarbonChatBukkit"
|
||||
apiVersion = "1.16"
|
||||
author = "Draycia"
|
||||
softDepend = listOf("PlaceholderAPI", "Vault")
|
||||
depend = listOf("LuckPerms")
|
||||
softDepend = listOf("PlaceholderAPI")
|
||||
loadBefore = listOf("Essentials")
|
||||
website = GITHUB_REPO_URL
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package net.draycia.carbon.bukkit.util;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class BukkitCapabilities {
|
||||
|
||||
private static @Nullable Boolean vaultEnabled = null;
|
||||
private static @Nullable Permission permission = null;
|
||||
private static @Nullable Chat chat = null;
|
||||
|
||||
private BukkitCapabilities() {
|
||||
|
||||
}
|
||||
|
||||
public static boolean vaultEnabled() {
|
||||
if (vaultEnabled == null) {
|
||||
vaultEnabled = Bukkit.getPluginManager().isPluginEnabled("Vault");
|
||||
}
|
||||
|
||||
return vaultEnabled;
|
||||
}
|
||||
|
||||
public static @Nullable Permission permission() {
|
||||
if (!vaultEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (permission == null) {
|
||||
final @Nullable RegisteredServiceProvider<Permission> rsp = Bukkit.getServer()
|
||||
.getServicesManager().getRegistration(Permission.class);
|
||||
|
||||
if (rsp != null) {
|
||||
permission = rsp.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
return permission;
|
||||
}
|
||||
|
||||
public static @Nullable Chat chat() {
|
||||
if (!vaultEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (chat == null) {
|
||||
final @Nullable RegisteredServiceProvider<Chat> rsp = Bukkit.getServer()
|
||||
.getServicesManager().getRegistration(Chat.class);
|
||||
|
||||
if (rsp != null) {
|
||||
chat = rsp.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
return chat;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,4 +18,5 @@ dependencies {
|
||||
// Other
|
||||
api(libs.guice)
|
||||
api(libs.cloudMinecraftExtras)
|
||||
api(libs.luckPermsApi)
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.draycia.carbon.common.users;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
@@ -9,6 +11,9 @@ import net.draycia.carbon.api.users.punishments.MuteEntry;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import net.luckperms.api.util.Tristate;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
@@ -19,6 +24,10 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
public abstract CarbonPlayerCommon carbonPlayerCommon();
|
||||
|
||||
public User user() {
|
||||
return Objects.requireNonNull(LuckPermsProvider.get().getUserManager().getUser(this.uuid()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean awareOf(final CarbonPlayer other) {
|
||||
if (other.vanished()) {
|
||||
@@ -30,20 +39,24 @@ public abstract class WrappedCarbonPlayer implements CarbonPlayer {
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
// TODO: LuckPerms
|
||||
return this.carbonPlayerCommon().hasPermission(permission);
|
||||
final var data = this.user().getCachedData().getPermissionData(this.user().getQueryOptions());
|
||||
return data.checkPermission(permission) == Tristate.TRUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primaryGroup() {
|
||||
// TODO: LuckPerms
|
||||
return this.carbonPlayerCommon().primaryGroup();
|
||||
return this.user().getPrimaryGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> groups() {
|
||||
// TODO: LuckPerms
|
||||
return this.carbonPlayerCommon().groups();
|
||||
final var groups = new ArrayList<String>();
|
||||
|
||||
for (final var group : this.user().getInheritedGroups(this.user().getQueryOptions())) {
|
||||
groups.add(group.getName());
|
||||
}
|
||||
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.5",
|
||||
"fabric": ">=0.31.0",
|
||||
"minecraft": ">=1.17"
|
||||
"minecraft": ">=1.17",
|
||||
"luckperms": ">=5.0.0"
|
||||
}
|
||||
}
|
||||
@@ -52,5 +52,9 @@ sponge {
|
||||
loadOrder(PluginDependency.LoadOrder.AFTER)
|
||||
optional(false)
|
||||
}
|
||||
dependency("luckperms") {
|
||||
version(">=5.0.0")
|
||||
optional(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ import org.spongepowered.api.scheduler.Task;
|
||||
import org.spongepowered.plugin.PluginContainer;
|
||||
import org.spongepowered.plugin.builtin.jvm.Plugin;
|
||||
|
||||
@Plugin("carbonchat")
|
||||
@Plugin("carbonchat") // TODO: hard depend on LuckPerms
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public final class CarbonChatSponge implements CarbonChat {
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.PluginContainer;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
@@ -35,7 +36,8 @@ import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
version = "$[VERSION]",
|
||||
description = "$[DESCRIPTION]",
|
||||
url = "$[URL]",
|
||||
authors = {"Draycia"}
|
||||
authors = {"Draycia"},
|
||||
dependencies = {@Dependency(id = "luckperms")}
|
||||
)
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public class CarbonChatVelocity implements CarbonChat {
|
||||
|
||||
Reference in new issue
Block a user