mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-02-05 15:11:56 +01:00
Fix primary group not loading and Vault support with EssentialsChat
This commit is contained in:
parent
1b09488859
commit
d35774b401
@ -12,6 +12,9 @@ import me.lucko.luckperms.runnables.UpdateTask;
|
||||
import me.lucko.luckperms.users.BukkitUserManager;
|
||||
import me.lucko.luckperms.users.UserManager;
|
||||
import me.lucko.luckperms.utils.LPConfiguration;
|
||||
import me.lucko.luckperms.vaulthooks.VaultChatHook;
|
||||
import me.lucko.luckperms.vaulthooks.VaultPermissionHook;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@ -84,8 +87,10 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
// Provide vault support
|
||||
try {
|
||||
if (getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
getServer().getServicesManager().register(Permission.class, new VaultHook(this), this, ServicePriority.High);
|
||||
getLogger().info("Registered Vault permission hook.");
|
||||
final VaultPermissionHook permsHook = new VaultPermissionHook(this);
|
||||
getServer().getServicesManager().register(Permission.class, permsHook, this, ServicePriority.High);
|
||||
getServer().getServicesManager().register(Chat.class, new VaultChatHook(permsHook), this, ServicePriority.Lowest);
|
||||
getLogger().info("Registered Vault permission & chat hook.");
|
||||
} else {
|
||||
getLogger().info("Vault not found.");
|
||||
}
|
||||
|
@ -0,0 +1,127 @@
|
||||
package me.lucko.luckperms.vaulthooks;
|
||||
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
/**
|
||||
* Dummy class for hooking with Vault plugins that need both Chat + Perms
|
||||
* This doesn't return anything useful, or change anything internally
|
||||
*
|
||||
* Registered on the lowest priority so other plugins can override
|
||||
*/
|
||||
public class VaultChatHook extends Chat {
|
||||
|
||||
public VaultChatHook(Permission perms) {
|
||||
super(perms);
|
||||
}
|
||||
|
||||
private void throwNotSupported() {
|
||||
// throw new UnsupportedOperationException("LuckPerms cannot perform this operation.");
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "LuckPerms";
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getPlayerPrefix(String world, String player) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setPlayerPrefix(String world, String player, String prefix) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public String getPlayerSuffix(String world, String player) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setPlayerSuffix(String world, String player, String suffix) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public String getGroupPrefix(String world, String group) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setGroupPrefix(String world, String group, String prefix) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public String getGroupSuffix(String world, String group) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setGroupSuffix(String world, String group, String suffix) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public int getPlayerInfoInteger(String world, String player, String node, int defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setPlayerInfoInteger(String world, String player, String node, int value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public int getGroupInfoInteger(String world, String group, String node, int defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setGroupInfoInteger(String world, String group, String node, int value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public double getPlayerInfoDouble(String world, String player, String node, double defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setPlayerInfoDouble(String world, String player, String node, double value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public double getGroupInfoDouble(String world, String group, String node, double defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setGroupInfoDouble(String world, String group, String node, double value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public boolean getPlayerInfoBoolean(String world, String player, String node, boolean defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setPlayerInfoBoolean(String world, String player, String node, boolean value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public boolean getGroupInfoBoolean(String world, String group, String node, boolean defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setGroupInfoBoolean(String world, String group, String node, boolean value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public String getPlayerInfoString(String world, String player, String node, String defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setPlayerInfoString(String world, String player, String node, String value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
public String getGroupInfoString(String world, String group, String node, String defaultValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setGroupInfoString(String world, String group, String node, String value) {
|
||||
throwNotSupported();
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package me.lucko.luckperms;
|
||||
package me.lucko.luckperms.vaulthooks;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import me.lucko.luckperms.LPBukkitPlugin;
|
||||
import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.exceptions.ObjectLacksPermissionException;
|
||||
import me.lucko.luckperms.groups.Group;
|
||||
@ -8,7 +9,7 @@ import me.lucko.luckperms.users.User;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
@AllArgsConstructor
|
||||
class VaultHook extends Permission {
|
||||
public class VaultPermissionHook extends Permission {
|
||||
private final LPBukkitPlugin plugin;
|
||||
|
||||
@Override
|
@ -161,7 +161,7 @@ public class FlatfileDatastore extends Datastore {
|
||||
reader.nextName(); // name record
|
||||
reader.nextString(); // name
|
||||
reader.nextName(); // primaryGroup record
|
||||
reader.nextString(); // primaryGroup
|
||||
user.setPrimaryGroup(reader.nextString()); // primaryGroup
|
||||
reader.nextName(); //perms
|
||||
reader.beginObject();
|
||||
while (reader.hasNext()) {
|
||||
|
@ -184,6 +184,7 @@ abstract class SQLDatastore extends Datastore {
|
||||
});
|
||||
} else {
|
||||
user.getNodes().putAll(gson.fromJson(resultSet.getString("perms"), NM_TYPE));
|
||||
user.setPrimaryGroup(resultSet.getString("primary_group"));
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user