-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved offline permission query system
- Loading branch information
Showing
9 changed files
with
71 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
bungee/src/main/java/me/leoko/advancedban/bungee/utils/LuckPermsOfflineUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package me.leoko.advancedban.bungee.utils; | ||
|
||
import me.leoko.advancedban.utils.Permissionable; | ||
import net.luckperms.api.LuckPermsProvider; | ||
import net.luckperms.api.model.user.User; | ||
import net.luckperms.api.model.user.UserManager; | ||
|
||
import java.util.UUID; | ||
|
||
public class LuckPermsOfflineUser implements Permissionable { | ||
private User permissionUser; | ||
|
||
public LuckPermsOfflineUser(String name) { | ||
final UserManager userManager = LuckPermsProvider.get().getUserManager(); | ||
final UUID uuid = userManager.lookupUniqueId(name).join(); | ||
if (uuid != null) { | ||
this.permissionUser = userManager.loadUser(uuid).join(); | ||
} | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(String permission) { | ||
return permissionUser != null && permissionUser.getCachedData().getPermissionData().checkPermission(permission).asBoolean(); | ||
} | ||
} |
42 changes: 0 additions & 42 deletions
42
bungee/src/main/java/me/leoko/advancedban/bungee/utils/LuckPermsPermissionProvider.java
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
bungee/src/main/java/me/leoko/advancedban/bungee/utils/OfflinePermissionProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
core/src/main/java/me/leoko/advancedban/utils/Permissionable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.leoko.advancedban.utils; | ||
|
||
/** | ||
* The Permissionable interface defines a way to query whether the implementing object has a certain permission. | ||
*/ | ||
@FunctionalInterface | ||
public interface Permissionable { | ||
/** | ||
* Checks whether the implementing object has the given permission | ||
* | ||
* @param permission the permission to check | ||
* @return the result | ||
*/ | ||
boolean hasPermission(String permission); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters