修复了不能卸下权限组称号的问题
Some checks failed
Java CI-CD with Gradle / build (push) Failing after 1m31s

This commit is contained in:
zhangyuheng 2024-08-11 12:23:15 +08:00
parent c0fcc2aaa0
commit a37f194d1b
2 changed files with 27 additions and 21 deletions

View File

@ -4,7 +4,7 @@ plugins {
} }
group = "cn.lunadeer" group = "cn.lunadeer"
version = "2.1.6-beta" version = "2.1.7-beta"
java { java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) toolchain.languageVersion.set(JavaLanguageVersion.of(21))

View File

@ -29,28 +29,34 @@ public class Title {
return; return;
} }
try { try {
int id = Integer.parseInt(args[1]);
PlayerDTO player = PlayerDTO.get(bukkit_player); PlayerDTO player = PlayerDTO.get(bukkit_player);
GroupDTO group = Cache.instance.getGroup(Integer.parseInt(args[1])); if (id == -1) {
if (group == null) { player.setUsingGroupTitleID(id);
Notification.error(sender, "权限组不存在"); Notification.info(sender, "成功卸下权限组称号");
return; } else {
GroupDTO group = Cache.instance.getGroup(id);
if (group == null) {
Notification.error(sender, "权限组不存在");
return;
}
DominionDTO dominion = Cache.instance.getDominion(group.getDomID());
if (dominion == null) {
Notification.error(sender, "权限组 %s 所属领地不存在", group.getName());
return;
}
MemberDTO member = Cache.instance.getMember(bukkit_player, dominion);
if (member == null) {
Notification.error(sender, "你不是 %s 的成员,无法使用其称号", dominion.getName());
return;
}
if (!Objects.equals(member.getGroupId(), group.getId())) {
Notification.error(sender, "你不属于权限组 %s无法使用其称号", group.getName());
return;
}
player.setUsingGroupTitleID(group.getId());
Notification.info(sender, "成功使用权限组 %s 称号", group.getName());
} }
DominionDTO dominion = Cache.instance.getDominion(group.getDomID());
if (dominion == null) {
Notification.error(sender, "权限组 %s 所属领地不存在", group.getName());
return;
}
MemberDTO member = Cache.instance.getMember(bukkit_player, dominion);
if (member == null) {
Notification.error(sender, "你不是 %s 的成员,无法使用其称号", dominion.getName());
return;
}
if (!Objects.equals(member.getGroupId(), group.getId())) {
Notification.error(sender, "你不属于权限组 %s无法使用其称号", group.getName());
return;
}
player.setUsingGroupTitleID(group.getId());
Notification.info(sender, "成功使用权限组 %s 称号", group.getName());
int page = getPage(args, 2); int page = getPage(args, 2);
TitleList.show(sender, page); TitleList.show(sender, page);
} catch (Exception e) { } catch (Exception e) {