初步实现了权限组称号功能

This commit is contained in:
zhangyuheng 2024-08-11 11:56:40 +08:00
parent bb32f085ac
commit c0fcc2aaa0
7 changed files with 17 additions and 12 deletions

View File

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

View File

@ -5,6 +5,7 @@ import cn.lunadeer.dominion.controllers.GroupController;
import cn.lunadeer.dominion.tuis.dominion.manage.group.GroupList;
import cn.lunadeer.dominion.tuis.dominion.manage.group.GroupSetting;
import cn.lunadeer.dominion.tuis.dominion.manage.group.SelectMember;
import cn.lunadeer.minecraftpluginutils.ColorParser;
import cn.lunadeer.minecraftpluginutils.Notification;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@ -39,7 +40,7 @@ public class Group {
BukkitPlayerOperator operator = BukkitPlayerOperator.create(sender);
String dominionName = args[2];
String groupName = args[3];
GroupController.createGroup(operator, dominionName, groupName);
GroupController.createGroup(operator, dominionName, ColorParser.getPlainText(groupName), groupName);
GroupList.show(sender, dominionName);
} catch (Exception e) {
Notification.error(sender, e.getMessage());
@ -90,7 +91,7 @@ public class Group {
String dominionName = args[2];
String oldGroupName = args[3];
String newGroupName = args[4];
GroupController.renameGroup(operator, dominionName, oldGroupName, newGroupName);
GroupController.renameGroup(operator, dominionName, oldGroupName, ColorParser.getPlainText(newGroupName), newGroupName);
GroupSetting.show(sender, dominionName, newGroupName);
} catch (Exception e) {
Notification.error(sender, e.getMessage());

View File

@ -9,7 +9,7 @@ import static cn.lunadeer.dominion.controllers.Apis.notOwner;
public class GroupController {
public static void createGroup(AbstractOperator operator, String domName, String groupName) {
public static void createGroup(AbstractOperator operator, String domName, String groupName, String nameColored) {
AbstractOperator.Result FAIL = new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "创建权限组 %s 失败", groupName);
AbstractOperator.Result SUCCESS = new AbstractOperator.Result(AbstractOperator.Result.SUCCESS, "创建权限组 %s 成功", groupName);
if (groupName.contains(" ")) {
@ -30,7 +30,7 @@ public class GroupController {
operator.setResponse(FAIL.addMessage("领地 %s 已存在名为 %s 的权限组", domName, groupName));
return;
}
group = GroupDTO.create(groupName, dominion);
group = GroupDTO.create(nameColored, dominion);
if (group == null) {
operator.setResponse(FAIL.addMessage("请联系服务器管理员"));
return;
@ -96,7 +96,7 @@ public class GroupController {
operator.setResponse(SUCCESS);
}
public static void renameGroup(AbstractOperator operator, String domName, String oldName, String newName) {
public static void renameGroup(AbstractOperator operator, String domName, String oldName, String newName, String nameColored) {
AbstractOperator.Result FAIL = new AbstractOperator.Result(AbstractOperator.Result.FAILURE, "重命名权限组 %s 为 %s 失败", oldName, newName);
AbstractOperator.Result SUCCESS = new AbstractOperator.Result(AbstractOperator.Result.SUCCESS, "重命名权限组 %s 为 %s 成功", oldName, newName);
if (newName.contains(" ")) {
@ -117,7 +117,7 @@ public class GroupController {
operator.setResponse(FAIL.addMessage("领地 %s 不存在名为 %s 的权限组", domName, oldName));
return;
}
group = group.setName(newName);
group = group.setName(nameColored);
if (group == null) {
operator.setResponse(FAIL.addMessage("请联系服务器管理员"));
return;

View File

@ -4,6 +4,7 @@ import cn.lunadeer.dominion.controllers.BukkitPlayerOperator;
import cn.lunadeer.dominion.controllers.GroupController;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.tuis.dominion.manage.group.GroupList;
import cn.lunadeer.minecraftpluginutils.ColorParser;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.XLogger;
import cn.lunadeer.minecraftpluginutils.scui.CuiTextInput;
@ -28,7 +29,7 @@ public class CreateGroup {
public void handleData(String input) {
XLogger.debug("createGroupCB.run: %s", input);
BukkitPlayerOperator operator = BukkitPlayerOperator.create(sender);
GroupController.createGroup(operator, dominionName, input);
GroupController.createGroup(operator, dominionName, ColorParser.getPlainText(input), input);
GroupList.show(sender, dominionName);
}
}

View File

@ -4,6 +4,7 @@ import cn.lunadeer.dominion.controllers.BukkitPlayerOperator;
import cn.lunadeer.dominion.controllers.GroupController;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.tuis.dominion.manage.group.GroupSetting;
import cn.lunadeer.minecraftpluginutils.ColorParser;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.minecraftpluginutils.XLogger;
import cn.lunadeer.minecraftpluginutils.scui.CuiTextInput;
@ -30,8 +31,8 @@ public class RenameGroup {
public void handleData(String input) {
XLogger.debug("renameGroupCB.run: %s", input);
BukkitPlayerOperator operator = BukkitPlayerOperator.create(sender);
GroupController.renameGroup(operator, dominionName, oldName, input);
GroupSetting.show(sender, dominionName, input);
GroupController.renameGroup(operator, dominionName, oldName, ColorParser.getPlainText(input), input);
GroupSetting.show(sender, dominionName, ColorParser.getPlainText(input));
}
}

View File

@ -1,6 +1,7 @@
package cn.lunadeer.dominion.tuis;
import cn.lunadeer.dominion.Cache;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.GroupDTO;
import cn.lunadeer.minecraftpluginutils.stui.ListView;
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
@ -32,13 +33,14 @@ public class TitleList {
GroupDTO using = Cache.instance.getPlayerUsingGroupTitle(player.getUniqueId());
for (GroupDTO group : groups) {
DominionDTO dominion = Cache.instance.getDominion(group.getDomID());
Line line = Line.create();
if (using != null && using.getId().equals(group.getId())) {
line.append(Button.createRed("卸下").setExecuteCommand("/dominion use_title -1").build());
} else {
line.append(Button.createGreen("使用").setExecuteCommand("/dominion use_title " + group.getId()).build());
}
line.append(group.getNameColoredComponent());
line.append(group.getNameColoredComponent()).append("来自领地:" + dominion.getName());
view.add(line);
}

View File

@ -45,7 +45,7 @@ public class GroupSetting {
}
ListView view = ListView.create(10, "/dominion group setting " + dominion.getName() + " " + group.getName());
view.title("权限组 " + group.getNameColoredBukkit() + " 管理");
view.title(Component.text("权限组 ").append(group.getNameColoredComponent()).append(Component.text(" 管理")));
view.navigator(
Line.create()
.append(Button.create("主菜单").setExecuteCommand("/dominion menu").build())