修复了领地管理员权限组可能无法管理领地玩家的问题
All checks were successful
Java CI-CD with Gradle / build (push) Successful in 5m11s
All checks were successful
Java CI-CD with Gradle / build (push) Successful in 5m11s
This commit is contained in:
parent
0cb2ac81d4
commit
150939dc45
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "cn.lunadeer"
|
group = "cn.lunadeer"
|
||||||
version = "2.2.1-beta"
|
version = "2.2.2-beta"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
|
@ -2,8 +2,7 @@ package cn.lunadeer.dominion.controllers;
|
|||||||
|
|
||||||
import cn.lunadeer.dominion.dtos.*;
|
import cn.lunadeer.dominion.dtos.*;
|
||||||
|
|
||||||
import static cn.lunadeer.dominion.utils.ControllerUtils.noAuthToChangeFlags;
|
import static cn.lunadeer.dominion.utils.ControllerUtils.*;
|
||||||
import static cn.lunadeer.dominion.utils.ControllerUtils.notOwner;
|
|
||||||
|
|
||||||
public class MemberController {
|
public class MemberController {
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ public class MemberController {
|
|||||||
operator.setResponse(FAIL.addMessage("玩家 %s 不是领地 %s 的成员", player_name, dominionName));
|
operator.setResponse(FAIL.addMessage("玩家 %s 不是领地 %s 的成员", player_name, dominionName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (privilege.getAdmin() && notOwner(operator, dominion)) {
|
if (isAdmin(privilege) && notOwner(operator, dominion)) {
|
||||||
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法移除一个领地管理员", dominionName));
|
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法移除一个领地管理员", dominionName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -69,7 +68,12 @@ public class MemberController {
|
|||||||
operator.setResponse(FAIL.addMessage("玩家 %s 不是领地 %s 的成员", player_name, dominionName));
|
operator.setResponse(FAIL.addMessage("玩家 %s 不是领地 %s 的成员", player_name, dominionName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((flag.equals("admin") || privilege.getAdmin()) && notOwner(operator, dominion)) {
|
GroupDTO group = GroupDTO.select(privilege.getGroupId());
|
||||||
|
if (group != null) {
|
||||||
|
operator.setResponse(FAIL.addMessage("玩家 %s 属于 %s 权限组,无法单独设置权限", player_name, group.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((flag.equals("admin") || isAdmin(privilege)) && notOwner(operator, dominion)) {
|
||||||
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法修改其他玩家管理员的权限", dominionName));
|
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法修改其他玩家管理员的权限", dominionName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -141,7 +145,7 @@ public class MemberController {
|
|||||||
operator.setResponse(FAIL.addMessage("模板 %s 不存在", templateName));
|
operator.setResponse(FAIL.addMessage("模板 %s 不存在", templateName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (notOwner(operator, dominion) && privilege.getAdmin()) {
|
if (notOwner(operator, dominion) && (isAdmin(privilege) || template.getAdmin())) {
|
||||||
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法修改其他管理员的权限", dominionName));
|
operator.setResponse(FAIL.addMessage("你不是领地 %s 的拥有者,无法修改其他管理员的权限", dominionName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,10 @@ import cn.lunadeer.dominion.Cache;
|
|||||||
import cn.lunadeer.dominion.Dominion;
|
import cn.lunadeer.dominion.Dominion;
|
||||||
import cn.lunadeer.dominion.controllers.AbstractOperator;
|
import cn.lunadeer.dominion.controllers.AbstractOperator;
|
||||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||||
|
import cn.lunadeer.dominion.dtos.GroupDTO;
|
||||||
import cn.lunadeer.dominion.dtos.MemberDTO;
|
import cn.lunadeer.dominion.dtos.MemberDTO;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class ControllerUtils {
|
public class ControllerUtils {
|
||||||
|
|
||||||
@ -51,4 +53,20 @@ public class ControllerUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查一个成员是否是管理员
|
||||||
|
* 此方法会同时尝试搜索玩家所在的权限组是否是管理员
|
||||||
|
*
|
||||||
|
* @param member 成员权限
|
||||||
|
* @return 是否是管理员
|
||||||
|
*/
|
||||||
|
public static boolean isAdmin(@NotNull MemberDTO member) {
|
||||||
|
GroupDTO group = GroupDTO.select(member.getGroupId());
|
||||||
|
if (group == null) {
|
||||||
|
return member.getAdmin();
|
||||||
|
} else {
|
||||||
|
return group.getAdmin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user