Compare commits
No commits in common. "bdf60785e8b56485e87d7a93fa41c286bf28193a" and "d7705d8904ab720d1bd29162732c37dc5cb4a542" have entirely different histories.
bdf60785e8
...
d7705d8904
@ -11,30 +11,18 @@ import java.util.logging.Logger;
|
||||
*/
|
||||
public class BadCommandUsage extends RuntimeException {
|
||||
|
||||
/** Constructs a new runtime exception with no message or cause.
|
||||
*/
|
||||
public BadCommandUsage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** Constructs a new runtime exception with the specified cause.
|
||||
* @param cause the cause.
|
||||
*/
|
||||
public BadCommandUsage(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/** Constructs a new runtime exception with the specified message.
|
||||
* @param message the message.
|
||||
*/
|
||||
public BadCommandUsage(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/** Constructs a new runtime exception with the specified message and cause.
|
||||
* @param message the message.
|
||||
* @param cause the cause.
|
||||
*/
|
||||
public BadCommandUsage(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* Represents a dummy player in the permission system, that have no specific data, only inheriting from the default
|
||||
* groups.
|
||||
* <p>
|
||||
*
|
||||
* The current implementation provides a player named {@code default.0} with an uuid of
|
||||
* {@code fffdef17-ffff-b0ff-ffff-ffffffffffff}.
|
||||
* Trying to set a permission data for this player will log a warning.
|
||||
|
@ -18,7 +18,7 @@ public final class PermGroup extends PermEntity {
|
||||
super(name, EntityType.Group);
|
||||
}
|
||||
@Override
|
||||
/* package */ CachedGroup getBackendEntity() {
|
||||
protected CachedGroup getBackendEntity() {
|
||||
return Permissions.backendReader.getCachedGroup(name);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public sealed class PermPlayer extends PermEntity permits DefaultPlayer {
|
||||
playerId = id;
|
||||
}
|
||||
@Override
|
||||
/* package */ CachedPlayer getBackendEntity() {
|
||||
protected CachedPlayer getBackendEntity() {
|
||||
return Permissions.backendReader.getCachedPlayer(playerId);
|
||||
}
|
||||
|
||||
|
@ -104,21 +104,9 @@ public class Permissions {
|
||||
return new PermPlayer(playerId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permission object of all players stored in cache.
|
||||
* @return the permission player object.
|
||||
* @throws IllegalStateException if the permission system was not initialized properly.
|
||||
*/
|
||||
public static List<PermPlayer> getCachedPlayers() {
|
||||
checkInitialized();
|
||||
return backendReader.getAllCachedPlayers().stream()
|
||||
.map(cp -> getPlayer(cp.playerId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a dummy permission player object, that have no specific data, only inheriting from the default groups.
|
||||
* <p>
|
||||
*
|
||||
* The current implementation provides a player named {@code default.0} with an uuid of
|
||||
* {@code fffdef17-ffff-b0ff-ffff-ffffffffffff}.
|
||||
* Trying to set a permission data for this player will log a warning.
|
||||
@ -149,16 +137,6 @@ public class Permissions {
|
||||
t.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks the permission system to preventively and asynchronously cache the data of all players.
|
||||
* This method can be called before doing any operation involving most or all the permission data.
|
||||
* @throws IllegalStateException if the permission system was not initialized properly.
|
||||
*/
|
||||
public static void precachePlayers() {
|
||||
checkInitialized();
|
||||
backendReader.precacheAllPlayers();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permission group object.
|
||||
* @param name the name of the group.
|
||||
|
@ -63,31 +63,6 @@ import fr.pandacube.lib.util.log.Log;
|
||||
}
|
||||
}
|
||||
|
||||
/* package */ synchronized List<CachedPlayer> getAllCachedPlayers() {
|
||||
return new ArrayList<>(usersCache.asMap().values());
|
||||
}
|
||||
|
||||
/* package */ synchronized void precacheAllPlayers() {
|
||||
try {
|
||||
DB.getAll(SQLPermissions.class, SQLPermissions.type.eq(EntityType.User.getCode()))
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(el -> el.get(SQLPermissions.name),
|
||||
Collectors.toCollection(() -> new SQLElementList<SQLPermissions>())
|
||||
)
|
||||
)
|
||||
.forEach((idStr, pData) -> {
|
||||
try {
|
||||
UUID pId = UUID.fromString(idStr);
|
||||
usersCache.put(pId, initPlayer(pId, pData));
|
||||
} catch (Exception e) {
|
||||
Log.severe("Error caching player permission data (name=\"" + idStr + "\")", e);
|
||||
}
|
||||
});
|
||||
} catch (DBException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private CachedPlayer initPlayer(UUID playerId) throws DBException {
|
||||
if (playerId.equals(DEFAULT_PLAYER.playerId))
|
||||
return DEFAULT_PLAYER;
|
||||
@ -95,12 +70,7 @@ import fr.pandacube.lib.util.log.Log;
|
||||
SQLElementList<SQLPermissions> playerData = DB.getAll(SQLPermissions.class,
|
||||
SQLPermissions.type.eq(EntityType.User.getCode())
|
||||
.and(SQLPermissions.name.like(playerId.toString()))
|
||||
);
|
||||
|
||||
return initPlayer(playerId, playerData);
|
||||
}
|
||||
|
||||
private CachedPlayer initPlayer(UUID playerId, SQLElementList<SQLPermissions> playerData) {
|
||||
);
|
||||
|
||||
Map<String, List<SQLPermissions>> playerRawData = playerData.stream()
|
||||
.collect(
|
||||
|
Loading…
Reference in New Issue
Block a user