mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Permission check fix
This commit is contained in:
parent
686a6c499f
commit
35ebc8c830
@ -102,6 +102,11 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return this.player.isPermissionSet(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
|
@ -61,6 +61,11 @@ public class ConsolePlayer extends PlotPlayer {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
PS.log(message);
|
||||
|
@ -60,7 +60,12 @@ public class Permissions {
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasPermission(CommandCaller caller, String permission) {
|
||||
if (caller.hasPermission(permission) || caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
if (caller.hasPermission(permission)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(permission)) {
|
||||
return false;
|
||||
}
|
||||
if (caller.hasPermission(C.PERMISSION_ADMIN.s())) {
|
||||
return true;
|
||||
}
|
||||
permission = permission.toLowerCase().replaceAll("^[^a-z|0-9|\\.|_|-]", "");
|
||||
@ -68,9 +73,12 @@ public class Permissions {
|
||||
StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i <= (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ".");
|
||||
if (!permission.equals(n + C.PERMISSION_STAR.s())) {
|
||||
if (caller.hasPermission(n + C.PERMISSION_STAR.s())) {
|
||||
String combined = n + C.PERMISSION_STAR.s();
|
||||
if (!permission.equals(combined)) {
|
||||
if (caller.hasPermission(combined)) {
|
||||
return true;
|
||||
} else if (caller.isPermissionSet(combined)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +16,7 @@ public interface CommandCaller {
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
boolean isPermissionSet(String permission);
|
||||
|
||||
RequiredType getSuperCaller();
|
||||
}
|
||||
|
@ -97,6 +97,11 @@ public class NukkitPlayer extends PlotPlayer {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
return this.player.isPermissionSet(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
|
@ -20,6 +20,7 @@ import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
||||
import org.spongepowered.api.service.ban.BanService;
|
||||
import org.spongepowered.api.text.chat.ChatTypes;
|
||||
import org.spongepowered.api.text.serializer.TextSerializers;
|
||||
import org.spongepowered.api.util.Tristate;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -73,6 +74,12 @@ public class SpongePlayer extends PlotPlayer {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
Tristate state = this.player.getPermissionValue(this.player.getActiveContexts(), permission);
|
||||
return state != Tristate.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
|
Loading…
Reference in New Issue
Block a user