Compare commits
No commits in common. "721175f965bed40a3e48fbeab849533e52a7328f" and "c4ab62c85739102514d04fd570afc824bb5a24a7" have entirely different histories.
721175f965
...
c4ab62c857
@ -92,14 +92,19 @@ public class ItemStackBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStackBuilder meta(Consumer<ItemMeta> metaUpdater) {
|
public ItemStackBuilder meta(Consumer<ItemMeta> metaUpdater) {
|
||||||
return meta(metaUpdater, ItemMeta.class);
|
metaUpdater.accept(getOrInitMeta());
|
||||||
|
updateMeta();
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends ItemMeta> ItemStackBuilder meta(Consumer<T> metaUpdater, Class<T> metaType) {
|
public <T extends ItemMeta> ItemStackBuilder meta(Consumer<T> metaUpdater, Class<T> metaType) {
|
||||||
stack.editMeta(metaType, m -> {
|
ItemMeta m = getOrInitMeta();
|
||||||
metaUpdater.accept(m);
|
if (!metaType.isInstance(m)) {
|
||||||
cachedMeta = m;
|
Log.warning("Item meta of " + stack.getType() + " is not of type " + metaType.getSimpleName(), new Throwable());
|
||||||
});
|
return this;
|
||||||
|
}
|
||||||
|
metaUpdater.accept(metaType.cast(m));
|
||||||
|
updateMeta();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package fr.pandacube.lib.permissions;
|
package fr.pandacube.lib.permissions;
|
||||||
|
|
||||||
import fr.pandacube.lib.db.DBException;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedGroup;
|
import fr.pandacube.lib.permissions.PermissionsCachedBackendReader.CachedGroup;
|
||||||
import fr.pandacube.lib.permissions.SQLPermissions.EntityType;
|
import fr.pandacube.lib.permissions.SQLPermissions.EntityType;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an group in the permission system.
|
* Represents an group in the permission system.
|
||||||
*/
|
*/
|
||||||
@ -50,23 +47,6 @@ public final class PermGroup extends PermEntity {
|
|||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets all the players that inherits from this group.
|
|
||||||
* This method does not use cached data.
|
|
||||||
* @param recursive true to include players that are in inherited groups.
|
|
||||||
* @return the players that inherits from this group.
|
|
||||||
* @throws DBException if a database error occurs.
|
|
||||||
*/
|
|
||||||
public Set<UUID> getInheritedPlayers(boolean recursive) throws DBException {
|
|
||||||
Set<UUID> players = new HashSet<>(getBackendEntity().getPlayersInGroup());
|
|
||||||
if (recursive) {
|
|
||||||
for (PermGroup inheritedGroups : getInheritedGroups()) {
|
|
||||||
players.addAll(inheritedGroups.getInheritedPlayers(true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells if this group is a default group.
|
* Tells if this group is a default group.
|
||||||
* A player inherits all default groups when they don’t explicitely inherit from at least one group.
|
* A player inherits all default groups when they don’t explicitely inherit from at least one group.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.pandacube.lib.permissions;
|
package fr.pandacube.lib.permissions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -120,13 +119,6 @@ import fr.pandacube.lib.util.Log;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final Map<String, CachedGroup> groupsCache = new LinkedHashMap<>();
|
private final Map<String, CachedGroup> groupsCache = new LinkedHashMap<>();
|
||||||
private boolean cacheIsUpdating = false;
|
private boolean cacheIsUpdating = false;
|
||||||
|
|
||||||
@ -307,19 +299,6 @@ import fr.pandacube.lib.util.Log;
|
|||||||
super(n, p, s, perms);
|
super(n, p, s, perms);
|
||||||
deflt = dflt;
|
deflt = dflt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* package */ Set<UUID> getPlayersInGroup() throws DBException {
|
|
||||||
Set<UUID> ids = new HashSet<>();
|
|
||||||
DB.forEach(SQLPermissions.class,
|
|
||||||
SQLPermissions.type.eq(EntityType.User.getCode())
|
|
||||||
.and(SQLPermissions.key.eq("groups"))
|
|
||||||
.and(SQLPermissions.value.eq(name)),
|
|
||||||
e -> ids.add(UUID.fromString(e.get(SQLPermissions.name)))
|
|
||||||
);
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user