mirror of
https://github.com/MilkBowl/Vault.git
synced 2024-11-23 19:16:31 +01:00
adjust starburst hook for player groups to simplify massively.
This commit is contained in:
parent
6a73a6d1c5
commit
301371aa32
@ -1,5 +1,7 @@
|
|||||||
package net.milkbowl.vault.permission.plugins;
|
package net.milkbowl.vault.permission.plugins;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.milkbowl.vault.Vault;
|
import net.milkbowl.vault.Vault;
|
||||||
@ -8,11 +10,13 @@ import net.milkbowl.vault.permission.Permission;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.Event.Type;
|
import org.bukkit.event.Event.Type;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
import org.bukkit.event.server.ServerListener;
|
import org.bukkit.event.server.ServerListener;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.dthielke.starburst.Group;
|
import com.dthielke.starburst.Group;
|
||||||
@ -196,6 +200,11 @@ public class Permission_Starburst extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean playerInGroup(String world, String player, String group) {
|
public boolean playerInGroup(String world, String player, String group) {
|
||||||
|
Player p = Bukkit.getServer().getPlayer(player);
|
||||||
|
if (p != null) {
|
||||||
|
return p.hasPermission("group." + group);
|
||||||
|
}
|
||||||
|
|
||||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
||||||
if (op == null) {
|
if (op == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -261,28 +270,17 @@ public class Permission_Starburst extends Permission {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getPlayerGroups(String world, String player) {
|
public String[] getPlayerGroups(String world, String player) {
|
||||||
OfflinePlayer op = Bukkit.getOfflinePlayer(player);
|
Player p = Bukkit.getServer().getPlayer(player);
|
||||||
if (op == null) {
|
if (p == null)
|
||||||
return null;
|
throw new UnsupportedOperationException(getName() + " does not support offline player resolution.");
|
||||||
|
|
||||||
|
List<String> groups = new ArrayList<String>();
|
||||||
|
for (PermissionAttachmentInfo pai : p.getEffectivePermissions()) {
|
||||||
|
if (!pai.getPermission().startsWith("group.") || !pai.getValue())
|
||||||
|
continue;
|
||||||
|
groups.add(pai.getPermission().substring(6));
|
||||||
}
|
}
|
||||||
GroupSet set;
|
return groups.toArray(new String[0]);
|
||||||
World w = Bukkit.getWorld(world);
|
|
||||||
if (w != null) {
|
|
||||||
set = perms.getGroupManager().getDefaultGroupSet();
|
|
||||||
} else {
|
|
||||||
set = perms.getGroupManager().getWorldSet(w);
|
|
||||||
}
|
|
||||||
User u = set.getUser(op);
|
|
||||||
if (u == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String[] s = new String[u.getChildren().size()];
|
|
||||||
int i = 0;
|
|
||||||
for (Group g : u.getChildren()) {
|
|
||||||
s[i] = g.getName();
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user