This repository has been archived by the owner on Jan 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from reformcloudproject/progress
Version 1.7
- Loading branch information
Showing
65 changed files
with
1,450 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# ReformCloud 1.6 | ||
# ReformCloud 1.7 | ||
|
||
Official Cloud System | ||
|
||
|
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
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
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
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
70 changes: 70 additions & 0 deletions
70
.../reformcloud-api-bungee/src/main/java/systems/reformcloud/permissions/PermissionUtil.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,70 @@ | ||
/* | ||
Copyright © 2019 Pasqual K. | All rights reserved | ||
*/ | ||
|
||
package systems.reformcloud.permissions; | ||
|
||
import net.md_5.bungee.api.CommandSender; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.command.ConsoleCommandSender; | ||
import systems.reformcloud.ReformCloudAPIBungee; | ||
import systems.reformcloud.player.permissions.group.PermissionGroup; | ||
import systems.reformcloud.player.permissions.player.PermissionHolder; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author _Klaro | Pasqual K. / created on 06.05.2019 | ||
*/ | ||
|
||
public final class PermissionUtil implements Serializable { | ||
public static boolean hasPermission(CommandSender commandSender, String permission) { | ||
if (permission == null) | ||
return false; | ||
|
||
if (commandSender instanceof ProxiedPlayer) | ||
return hasPermission0((ProxiedPlayer) commandSender, permission); | ||
|
||
return commandSender instanceof ConsoleCommandSender; | ||
} | ||
|
||
private static boolean hasPermission0(ProxiedPlayer proxiedPlayer, String permission) { | ||
if (proxiedPlayer == null) | ||
return false; | ||
|
||
return hasPermission1(proxiedPlayer.getUniqueId(), permission); | ||
} | ||
|
||
private static boolean hasPermission1(UUID uniqueID, String permission) { | ||
if (uniqueID == null) | ||
return false; | ||
|
||
PermissionHolder permissionHolder = ReformCloudAPIBungee.getInstance().getCachedPermissionHolders().get(uniqueID); | ||
return hasPermission2(permissionHolder, permission); | ||
} | ||
|
||
private static boolean hasPermission2(PermissionHolder permissionHolder, String permission) { | ||
if (permissionHolder == null) | ||
return false; | ||
|
||
List<PermissionGroup> permissionGroups = new ArrayList<>(); | ||
permissionHolder.getPermissionGroups().keySet() | ||
.stream() | ||
.filter(permissionHolder::isPermissionGroupPresent) | ||
.map(g -> ReformCloudAPIBungee.getInstance().getPermissionCache().getGroup(g)) | ||
.filter(Objects::nonNull) | ||
.forEach(permissionGroups::add); | ||
return hasPermission3(permissionHolder, permissionGroups, permission); | ||
} | ||
|
||
private static boolean hasPermission3(PermissionHolder permissionHolder, List<PermissionGroup> permissionGroups, String permission) { | ||
if (permissionGroups == null || permissionGroups.isEmpty()) | ||
return false; | ||
|
||
return permissionHolder.hasPermission(permission, permissionGroups); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
...ot/src/main/java/systems/reformcloud/network/packets/PacketOutDispatchConsoleCommand.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,18 @@ | ||
/* | ||
Copyright © 2018 Pasqual K. | All rights reserved | ||
*/ | ||
|
||
package systems.reformcloud.network.packets; | ||
|
||
import systems.reformcloud.configurations.Configuration; | ||
import systems.reformcloud.network.packet.Packet; | ||
|
||
/** | ||
* @author _Klaro | Pasqual K. / created on 16.12.2018 | ||
*/ | ||
|
||
public final class PacketOutDispatchConsoleCommand extends Packet { | ||
public PacketOutDispatchConsoleCommand(final String command) { | ||
super("DispatchCommandLine", new Configuration().addValue("command", command)); | ||
} | ||
} |
Oops, something went wrong.