丰富了api的相关文档 javadoc,优化了部分api接口命名

This commit is contained in:
ZhangYuheng 2024-10-10 15:21:19 +08:00
parent a53733a0fb
commit 5732fe0182
19 changed files with 316 additions and 159 deletions

View File

@ -5,6 +5,8 @@ plugins {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
withJavadocJar()
withSourcesJar()
}
// utf-8
@ -12,19 +14,14 @@ tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
tasks.withType<Javadoc> {
options.encoding = "UTF-8"
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
}
tasks.jar {
archiveClassifier.set("sources")
}
tasks.register<Jar>("doc") {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
@ -33,9 +30,6 @@ publishing {
version = "2.0-SNAPSHOT"
// 添加组件
from(components["java"])
// 添加Javadoc JAR
artifact(tasks["doc"])
}
}
repositories {

View File

@ -1,6 +1,7 @@
package cn.lunadeer.dominion.api;
import cn.lunadeer.dominion.api.dtos.DominionDTO;
import cn.lunadeer.dominion.api.dtos.Flag;
import cn.lunadeer.dominion.api.dtos.GroupDTO;
import cn.lunadeer.dominion.api.dtos.MemberDTO;
import org.bukkit.Location;
@ -77,4 +78,26 @@ public interface DominionAPI {
* @return 权限组对象 如果玩家没有使用任何权限组则返回null
*/
@Nullable GroupDTO getPlayerUsingGroupTitle(@NotNull UUID uuid);
/**
* 获取 flags.yml 中启用的所有环境权限对象environment部分
*
* @return 环境权限列表
*/
@NotNull List<Flag> getEnvironmentFlagsEnabled();
/**
* 获取 flags.yml 中启用的所有玩家权限对象privilege部分
*
* @return 玩家权限列表
*/
@NotNull List<Flag> getPrivilegeFlagsEnabled();
/**
* 通过权限名称获取权限对象即使权限没有启用此方法也会返回权限对象
*
* @param flagName 权限名称 displayName
* @return 权限对象 如果权限不存在则返回null
*/
@Nullable Flag getFlagByName(@NotNull String flagName);
}

View File

@ -2,8 +2,10 @@ package cn.lunadeer.dominion.api.dtos;
import org.bukkit.Location;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.UUID;
public interface DominionDTO {
@ -12,101 +14,138 @@ public interface DominionDTO {
*
* @return 领地 ID
*/
Integer getId();
@NotNull Integer getId();
/**
* 获取领地所有者 UUID
*
* @return 领地所有者 UUID
*/
UUID getOwner();
@NotNull UUID getOwner();
/**
* 获取领地名称
*
* @return 领地名称
*/
String getName();
@NotNull String getName();
/**
* 获取领地所在世界
* 获取领地所在世界如果世界不存在则返回null
*
* @return 领地所在世界 如果世界不存在则返回null
* @return 领地所在世界
*/
@Nullable World getWorld();
/**
* 获取领地所在世界 UUID
* 获取领地所在世界 UUID该接口返回的 UUID 一定不为 null但是不保证世界一定存在
* 如果需要判断世界是否存在请使用 {@link #getWorld()} 方法
*
* @return 领地所在世界 UUID
*/
UUID getWorldUid();
@NotNull UUID getWorldUid();
Integer getX1();
/**
* 获取领地角点坐标1小角点的X坐标X1 &lt; X2
*
* @return 领地角点坐标1小角点的X坐标
*/
@NotNull Integer getX1();
Integer getY1();
/**
* 获取领地角点坐标1小角点的Y坐标Y1 &lt; Y2
*
* @return 领地角点坐标1小角点的Y坐标
*/
@NotNull Integer getY1();
Integer getZ1();
/**
* 获取领地角点坐标1小角点的Z坐标Z1 &lt; Z2
*
* @return 领地角点坐标1小角点的Z坐标
*/
@NotNull Integer getZ1();
Integer getX2();
/**
* 获取领地角点坐标2大角点的X坐标X2 &gt; X1
*
* @return 领地角点坐标2大角点的X坐标
*/
@NotNull Integer getX2();
Integer getY2();
/**
* 获取领地角点坐标2大角点的Y坐标Y2 &gt; Y1
*
* @return 领地角点坐标2大角点的Y坐标
*/
@NotNull Integer getY2();
Integer getZ2();
/**
* 获取领地角点坐标2大角点的Z坐标Z2 &gt; Z1
*
* @return 领地角点坐标2大角点的Z坐标
*/
@NotNull Integer getZ2();
/**
* 获取领地面积
*
* @return 领地面积
*/
Integer getSquare();
@NotNull Integer getSquare();
/**
* 获取领地体积
*
* @return 领地体积
*/
Integer getVolume();
@NotNull Integer getVolume();
/**
* 获取领地X轴向东西向宽度
*
* @return 领地X轴向东西向宽度
*/
Integer getWidthX();
@NotNull Integer getWidthX();
/**
* 获取领地Y轴向上下向高度
*
* @return 领地Y轴向上下向高度
*/
Integer getHeight();
@NotNull Integer getHeight();
/**
* 获取领地Z轴向南北向宽度
*
* @return 领地Z轴向南北向宽度
*/
Integer getWidthZ();
@NotNull Integer getWidthZ();
/**
* 获取父领地 ID
*
* @return 父领地 ID 如果没有父领地则返回 -1
*/
Integer getParentDomId();
@NotNull Integer getParentDomId();
String getJoinMessage();
@NotNull String getJoinMessage();
String getLeaveMessage();
@NotNull String getLeaveMessage();
/**
* 获取领地某个权限的值
* 获取领地环境配置
*
* @param flag 权限
* @return 权限值
* @return 领地环境权限配置
*/
Boolean getFlagValue(Flag flag);
@NotNull Map<Flag, Boolean> getEnvironmentFlagValue();
/**
* 获取领地访客权限配置
*
* @return 领地访客权限配置
*/
@NotNull Map<Flag, Boolean> getGuestPrivilegeFlagValue();
/**
* 获取领地传送点坐标
@ -115,9 +154,19 @@ public interface DominionDTO {
*/
@Nullable Location getTpLocation();
Location getLocation1();
/**
* 领地角点坐标1小角点小角点的xyz小于大角点的xyz
*
* @return 领地角点坐标1
*/
@NotNull Location getLocation1();
Location getLocation2();
/**
* 领地角点坐标2大角点大角点的xyz大于小角点的xyz
*
* @return 领地角点坐标2
*/
@NotNull Location getLocation2();
int getColorR();
@ -125,7 +174,7 @@ public interface DominionDTO {
int getColorB();
String getColor();
@NotNull String getColor();
int getColorHex();
}

View File

@ -1,12 +1,14 @@
package cn.lunadeer.dominion.api.dtos;
import org.jetbrains.annotations.NotNull;
public interface Flag {
/**
* 权限名称英文
*
* @return 权限名称
*/
String getFlagName();
@NotNull String getFlagName();
/**
* 权限显示名称中文
@ -14,7 +16,7 @@ public interface Flag {
*
* @return 权限显示名称
*/
String getDisplayName();
@NotNull String getDisplayName();
/**
* 权限描述
@ -22,19 +24,26 @@ public interface Flag {
*
* @return 权限描述
*/
String getDescription();
@NotNull String getDescription();
/**
* 获取权限默认值
*
* @return 权限默认值
*/
Boolean getDefaultValue();
@NotNull Boolean getDefaultValue();
/**
* 获取权限是否启用
*
* @return 权限是否启用
*/
Boolean getEnable();
@NotNull Boolean getEnable();
/**
* 获取权限是否为环境设置
*
* @return 权限是否为环境设置
*/
@NotNull Boolean isEnvironmentFlag();
}

View File

@ -1,6 +1,9 @@
package cn.lunadeer.dominion.api.dtos;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
public interface GroupDTO {
/**
@ -8,48 +11,63 @@ public interface GroupDTO {
*
* @return 权限组 ID
*/
Integer getId();
@NotNull Integer getId();
/**
* 获取权限组所属领地 ID
*
* @return 权限组所属领地 ID
*/
Integer getDomID();
@NotNull Integer getDomID();
/**
* 获取权限组名称
* 获取权限组名称普通字符不含颜色代码
* 绝大多数情况下应该使用该方法获取权限组名称
*
* @return 权限组名称
*/
String getName();
@NotNull String getNamePlain();
/**
* 获取权限组名称带颜色 kyori.adventure.text.Component
* 获取权限组名称原始字符包含颜色代码
*
* @return 权限组名称
*/
@NotNull String getNameRaw();
/**
* 获取权限组名称带颜色 kyori.adventure.text.Component 类型
*
* @return 权限组名称带颜色
*/
Component getNameColoredComponent();
@NotNull Component getNameColoredComponent();
/**
* 获取权限组名称带颜色 Bukkit
* 获取权限组名称带颜色 Bukkit类型
*
* @return 权限组名称带颜色
*/
String getNameColoredBukkit();
@NotNull String getNameColoredBukkit();
/**
* 获取权限组是否为管理员组
*
* @return 是否为管理员组
*/
Boolean getAdmin();
@NotNull Boolean getAdmin();
/**
* 获取权限组某个权限配置
*
* @param flag 权限
* @return 权限配置值
* @return 权限配置值如果权限不存在则返回默认值
*/
Boolean getFlagValue(Flag flag);
@NotNull Boolean getFlagValue(@NotNull Flag flag);
/**
* 获取权限组所有权限配置
*
* @return 权限配置
*/
@NotNull Map<Flag, Boolean> getFlagsValue();
}

View File

@ -1,5 +1,8 @@
package cn.lunadeer.dominion.api.dtos;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import java.util.UUID;
public interface MemberDTO {
@ -42,7 +45,14 @@ public interface MemberDTO {
* 获取成员某个权限配置
*
* @param flag 权限
* @return 权限配置值如果权限不存在则返回默认值
*/
@NotNull Boolean getFlagValue(Flag flag);
/**
* 获取成员所有权限配置
*
* @return 权限配置值
*/
Boolean getFlagValue(Flag flag);
@NotNull Map<Flag, Boolean> getFlagsValue();
}

View File

@ -1,13 +1,18 @@
package cn.lunadeer.dominion;
import cn.lunadeer.dominion.api.DominionAPI;
import cn.lunadeer.dominion.dtos.*;
import cn.lunadeer.dominion.dtos.DominionDTO;
import cn.lunadeer.dominion.dtos.Flag;
import cn.lunadeer.dominion.dtos.GroupDTO;
import cn.lunadeer.dominion.dtos.MemberDTO;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class DominionInterface implements DominionAPI {
@ -52,4 +57,20 @@ public class DominionInterface implements DominionAPI {
public @Nullable GroupDTO getPlayerUsingGroupTitle(@NotNull UUID uuid) {
return Cache.instance.getPlayerUsingGroupTitle(uuid);
}
@Override
public @NotNull List<cn.lunadeer.dominion.api.dtos.Flag> getEnvironmentFlagsEnabled() {
return new ArrayList<>(Flag.getEnvironmentFlagsEnabled());
}
@Override
public @NotNull List<cn.lunadeer.dominion.api.dtos.Flag> getPrivilegeFlagsEnabled() {
return new ArrayList<>(Flag.getPrivilegeFlagsEnabled());
}
@Override
public cn.lunadeer.dominion.api.dtos.@Nullable Flag getFlagByName(@NotNull String flagName) {
return Flag.getFlag(flagName);
}
}

View File

@ -44,7 +44,7 @@ public class Helper {
if (dominion == null) return groups_name;
List<GroupDTO> groups = GroupDTO.selectByDominionId(dominion.getId());
for (GroupDTO group : groups) {
groups_name.add(group.getName());
groups_name.add(group.getNamePlain());
}
return groups_name;
}

View File

@ -43,7 +43,7 @@ public class Title {
}
DominionDTO dominion = Cache.instance.getDominion(group.getDomID());
if (dominion == null) {
Notification.error(sender, Translation.Commands_Title_GroupDominionNotExist, group.getName());
Notification.error(sender, Translation.Commands_Title_GroupDominionNotExist, group.getNamePlain());
return;
}
if (!dominion.getOwner().equals(bukkit_player.getUniqueId())) {
@ -53,12 +53,12 @@ public class Title {
return;
}
if (!Objects.equals(member.getGroupId(), group.getId())) {
Notification.error(sender, Translation.Commands_Title_NotGroupMember, group.getName());
Notification.error(sender, Translation.Commands_Title_NotGroupMember, group.getNamePlain());
return;
}
}
player.setUsingGroupTitleID(group.getId());
Notification.info(sender, Translation.Commands_Title_UseTitleSuccess, group.getName());
Notification.info(sender, Translation.Commands_Title_UseTitleSuccess, group.getNamePlain());
}
int page = getPage(args, 2);
TitleList.show(sender, page);

View File

@ -71,7 +71,7 @@ public class MemberController {
}
GroupDTO group = GroupDTO.select(privilege.getGroupId());
if (group != null) {
operator.setResponse(FAIL.addMessage(Translation.Messages_PlayerBelongToGroup, player_name, group.getName()));
operator.setResponse(FAIL.addMessage(Translation.Messages_PlayerBelongToGroup, player_name, group.getNamePlain()));
return;
}
if ((flag.equals("admin") || isAdmin(privilege)) && notOwner(operator, dominion)) {

View File

@ -220,12 +220,12 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
// getters and setters
@Override
public Integer getId() {
public @NotNull Integer getId() {
return (Integer) id.value;
}
@Override
public UUID getOwner() {
public @NotNull UUID getOwner() {
return UUID.fromString((String) owner.value);
}
@ -250,7 +250,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public String getName() {
public @NotNull String getName() {
return (String) name.value;
}
@ -265,12 +265,12 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public UUID getWorldUid() {
public @NotNull UUID getWorldUid() {
return UUID.fromString((String) world_uid.value);
}
@Override
public Integer getX1() {
public @NotNull Integer getX1() {
return (Integer) x1.value;
}
@ -280,7 +280,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getY1() {
public @NotNull Integer getY1() {
return (Integer) y1.value;
}
@ -290,7 +290,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getZ1() {
public @NotNull Integer getZ1() {
return (Integer) z1.value;
}
@ -300,7 +300,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getX2() {
public @NotNull Integer getX2() {
return (Integer) x2.value;
}
@ -310,7 +310,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getY2() {
public @NotNull Integer getY2() {
return (Integer) y2.value;
}
@ -320,7 +320,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getZ2() {
public @NotNull Integer getZ2() {
return (Integer) z2.value;
}
@ -330,37 +330,37 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Integer getSquare() {
public @NotNull Integer getSquare() {
return getWidthX() * getWidthZ();
}
@Override
public Integer getVolume() {
public @NotNull Integer getVolume() {
return getSquare() * getHeight();
}
@Override
public Integer getWidthX() {
public @NotNull Integer getWidthX() {
return getX2() - getX1();
}
@Override
public Integer getHeight() {
public @NotNull Integer getHeight() {
return getY2() - getY1();
}
@Override
public Integer getWidthZ() {
public @NotNull Integer getWidthZ() {
return getZ2() - getZ1();
}
@Override
public Integer getParentDomId() {
public @NotNull Integer getParentDomId() {
return (Integer) parentDomId.value;
}
@Override
public String getJoinMessage() {
public @NotNull String getJoinMessage() {
return (String) joinMessage.value;
}
@ -370,7 +370,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public String getLeaveMessage() {
public @NotNull String getLeaveMessage() {
return (String) leaveMessage.value;
}
@ -379,12 +379,25 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
return doUpdate(new UpdateRow().field(this.leaveMessage));
}
@Override
public Boolean getFlagValue(Flag flag) {
if (!flags.containsKey(flag)) return flag.getDefaultValue();
return flags.get(flag);
}
@Override
public @NotNull Map<Flag, Boolean> getEnvironmentFlagValue() {
return flags.entrySet().stream()
.filter(e -> e.getKey().isEnvironmentFlag())
.collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll);
}
@Override
public @NotNull Map<Flag, Boolean> getGuestPrivilegeFlagValue() {
return flags.entrySet().stream()
.filter(e -> !e.getKey().isEnvironmentFlag())
.collect(HashMap::new, (m, e) -> m.put(e.getKey(), e.getValue()), HashMap::putAll);
}
public DominionDTO setFlagValue(Flag flag, Boolean value) {
flags.put(flag, value);
Field flagField = new Field(flag.getFlagName(), value);
@ -435,12 +448,12 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public Location getLocation1() {
public @NotNull Location getLocation1() {
return new Location(getWorld(), getX1(), getY1(), getZ1());
}
@Override
public Location getLocation2() {
public @NotNull Location getLocation2() {
return new Location(getWorld(), getX2(), getY2(), getZ2());
}
@ -465,7 +478,7 @@ public class DominionDTO implements cn.lunadeer.dominion.api.dtos.DominionDTO {
}
@Override
public String getColor() {
public @NotNull String getColor() {
return (String) color.value;
}

View File

@ -7,6 +7,7 @@ import cn.lunadeer.minecraftpluginutils.XLogger;
import cn.lunadeer.minecraftpluginutils.i18n.Localization;
import com.alibaba.fastjson.JSONObject;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
@ -102,30 +103,35 @@ public enum Flag implements cn.lunadeer.dominion.api.dtos.Flag {
}
@Override
public String getFlagName() {
public @NotNull String getFlagName() {
return flag_name;
}
@Override
public String getDisplayName() {
public @NotNull String getDisplayName() {
return display_name;
}
@Override
public String getDescription() {
public @NotNull String getDescription() {
return description;
}
@Override
public Boolean getDefaultValue() {
public @NotNull Boolean getDefaultValue() {
return default_value;
}
@Override
public Boolean getEnable() {
public @NotNull Boolean getEnable() {
return enable;
}
@Override
public @NotNull Boolean isEnvironmentFlag() {
return dominion_only;
}
public void setDisplayName(String displayName) {
this.display_name = displayName;
}
@ -154,7 +160,24 @@ public enum Flag implements cn.lunadeer.dominion.api.dtos.Flag {
return Arrays.asList(Flag.values());
}
public static List<Flag> getDominionOnlyFlagsEnabled() {
public static List<Flag> getDominionFlagsEnabled() {
List<Flag> flags = new ArrayList<>();
for (Flag flag : Flag.values()) {
if (!flag.enable) {
continue;
}
flags.add(flag);
}
Comparator<Object> comparator = Collator.getInstance(java.util.Locale.CHINA);
flags.sort((o1, o2) -> comparator.compare(o1.getDisplayName(), o2.getDisplayName()));
return flags;
}
public static boolean isDominionOnlyFlag(String flagName) {
return getFlag(flagName).dominion_only;
}
public static List<Flag> getEnvironmentFlagsEnabled() {
List<Flag> flags = new ArrayList<>();
for (Flag flag : Flag.values()) {
if (!flag.dominion_only) {
@ -170,28 +193,6 @@ public enum Flag implements cn.lunadeer.dominion.api.dtos.Flag {
return flags;
}
public static boolean isDominionOnlyFlag(String flagName) {
return getFlag(flagName).dominion_only;
}
public static List<Flag> getDominionFlagsEnabled() {
List<Flag> flags = new ArrayList<>();
for (Flag flag : Flag.values()) {
if (!flag.enable) {
continue;
}
flags.add(flag);
}
Comparator<Object> comparator = Collator.getInstance(java.util.Locale.CHINA);
flags.sort((o1, o2) -> comparator.compare(o1.getDisplayName(), o2.getDisplayName()));
return flags;
}
public static List<Flag> getAllDominionFlags() {
return new ArrayList<>(Arrays.asList(Flag.values()));
}
public static List<Flag> getPrivilegeFlagsEnabled() {
List<Flag> flags = new ArrayList<>();
for (Flag flag : Flag.values()) {
@ -208,6 +209,10 @@ public enum Flag implements cn.lunadeer.dominion.api.dtos.Flag {
return flags;
}
public static List<Flag> getAllDominionFlags() {
return new ArrayList<>(Arrays.asList(Flag.values()));
}
public static List<Flag> getAllPrivilegeFlags() {
List<Flag> flags = new ArrayList<>();
for (Flag flag : Flag.values()) {

View File

@ -10,6 +10,7 @@ import cn.lunadeer.minecraftpluginutils.databse.FieldType;
import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
import cn.lunadeer.minecraftpluginutils.databse.syntax.UpdateRow;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import java.sql.ResultSet;
import java.util.ArrayList;
@ -21,62 +22,72 @@ public class GroupDTO implements cn.lunadeer.dominion.api.dtos.GroupDTO {
Field id = new Field("id", FieldType.INT);
Field domID = new Field("dom_id", FieldType.INT);
Field name = new Field("name", FieldType.STRING);
Field name_raw = new Field("name", FieldType.STRING);
Field admin = new Field("admin", FieldType.BOOLEAN);
Field name_colored = new Field("name_colored", FieldType.STRING);
Field name_color = new Field("name_colored", FieldType.STRING);
private final Map<Flag, Boolean> flags = new HashMap<>();
@Override
public Integer getId() {
public @NotNull Integer getId() {
return (Integer) id.value;
}
@Override
public Integer getDomID() {
public @NotNull Integer getDomID() {
return (Integer) domID.value;
}
@Override
public String getName() {
return (String) name.value;
public @NotNull String getNameRaw() {
return (String) name_color.value;
}
@Override
public Component getNameColoredComponent() {
public @NotNull String getNamePlain() {
return (String) name_raw.value;
}
@Override
public @NotNull Component getNameColoredComponent() {
String with_pre_suf = "&#ffffff" +
Dominion.config.getGroupTitlePrefix() +
(String) name_colored.value +
(String) name_color.value +
"&#ffffff" +
Dominion.config.getGroupTitleSuffix();
return ColorParser.getComponentType(with_pre_suf);
}
@Override
public String getNameColoredBukkit() {
public @NotNull String getNameColoredBukkit() {
String with_pre_suf = "&#ffffff" +
Dominion.config.getGroupTitlePrefix() +
(String) name_colored.value +
(String) name_color.value +
"&#ffffff" +
Dominion.config.getGroupTitleSuffix();
return ColorParser.getBukkitType(with_pre_suf);
}
@Override
public Boolean getAdmin() {
public @NotNull Boolean getAdmin() {
return (Boolean) admin.value;
}
@Override
public Boolean getFlagValue(Flag flag) {
public @NotNull Boolean getFlagValue(@NotNull Flag flag) {
if (!flags.containsKey(flag)) return flag.getDefaultValue();
return flags.get(flag);
}
@Override
public @NotNull Map<Flag, Boolean> getFlagsValue() {
return flags;
}
public GroupDTO setName(String name) {
this.name_colored.value = name;
this.name.value = ColorParser.getPlainText(name);
UpdateRow updateRow = new UpdateRow().field(this.name).field(this.name_colored);
this.name_color.value = name;
this.name_raw.value = ColorParser.getPlainText(name);
UpdateRow updateRow = new UpdateRow().field(this.name_raw).field(this.name_color);
return doUpdate(updateRow);
}
@ -98,9 +109,9 @@ public class GroupDTO implements cn.lunadeer.dominion.api.dtos.GroupDTO {
InsertRow insertRow = new InsertRow().returningAll().onConflictDoNothing(new Field("id", null));
insertRow.table("dominion_group")
.field(group.domID)
.field(group.name)
.field(group.name_raw)
.field(group.admin)
.field(group.name_colored);
.field(group.name_color);
for (Flag f : cn.lunadeer.dominion.dtos.Flag.getPrivilegeFlagsEnabled()) {
insertRow.field(new Field(f.getFlagName(), dominionDTO.getFlagValue(f)));
}
@ -155,8 +166,8 @@ public class GroupDTO implements cn.lunadeer.dominion.api.dtos.GroupDTO {
private GroupDTO(String name, Integer domID) {
this.domID.value = domID;
this.name.value = ColorParser.getPlainText(name);
this.name_colored.value = name;
this.name_raw.value = ColorParser.getPlainText(name);
this.name_color.value = name;
this.admin.value = false;
for (Flag f : cn.lunadeer.dominion.dtos.Flag.getPrivilegeFlagsEnabled()) {
flags.put(f, f.getDefaultValue());
@ -166,10 +177,10 @@ public class GroupDTO implements cn.lunadeer.dominion.api.dtos.GroupDTO {
private GroupDTO(Integer id, Integer domID, String name, Boolean admin, Map<Flag, Boolean> flags, String nameColored) {
this.id.value = id;
this.domID.value = domID;
this.name.value = name;
this.name_raw.value = name;
this.admin.value = admin;
this.flags.putAll(flags);
this.name_colored.value = nameColored;
this.name_color.value = nameColored;
}
private static List<GroupDTO> getDTOFromRS(ResultSet rs) {

View File

@ -7,6 +7,7 @@ import cn.lunadeer.minecraftpluginutils.databse.Field;
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
import cn.lunadeer.minecraftpluginutils.databse.syntax.UpdateRow;
import org.jetbrains.annotations.NotNull;
import java.sql.ResultSet;
import java.util.*;
@ -155,11 +156,16 @@ public class MemberDTO implements cn.lunadeer.dominion.api.dtos.MemberDTO {
private final Map<Flag, Boolean> flags = new HashMap<>();
@Override
public Boolean getFlagValue(Flag flag) {
public @NotNull Boolean getFlagValue(Flag flag) {
if (!flags.containsKey(flag)) return flag.getDefaultValue();
return flags.get(flag);
}
@Override
public @NotNull Map<Flag, Boolean> getFlagsValue() {
return flags;
}
public MemberDTO setFlagValue(Flag flag, Boolean value) {
flags.put(flag, value);
Field f = new Field(flag.getFlagName(), value);
@ -203,9 +209,7 @@ public class MemberDTO implements cn.lunadeer.dominion.api.dtos.MemberDTO {
this.playerUUID.value = playerUUID.toString();
this.admin.value = false;
this.domID.value = dom.getId();
for (Flag f : cn.lunadeer.dominion.dtos.Flag.getPrivilegeFlagsEnabled()) {
this.flags.put(f, dom.getFlagValue(f));
}
this.flags.putAll(dom.getGuestPrivilegeFlagValue());
}
}

View File

@ -36,7 +36,7 @@ public class EnvSetting {
.append(Button.create(Translation.TUI_Navigation_DominionList).setExecuteCommand("/dominion list").build())
.append(Button.create(Translation.TUI_Navigation_Manage).setExecuteCommand("/dominion manage " + dominion.getName()).build())
.append(Translation.TUI_Navigation_EnvSetting));
for (Flag flag : Flag.getDominionOnlyFlagsEnabled()) {
for (Flag flag : Flag.getEnvironmentFlagsEnabled()) {
view.add(createOption(flag, dominion.getFlagValue(flag), dominion.getName(), page));
}
view.showOn(player, page);

View File

@ -63,14 +63,14 @@ public class GroupList {
for (GroupDTO group : groups) {
Line line = new Line();
Button del = Button.createRed(Translation.TUI_DeleteButton)
.setHoverText(String.format(Translation.TUI_GroupList_DeleteDescription.trans(), group.getName()))
.setExecuteCommand("/dominion group delete " + dominion.getName() + " " + group.getName());
.setHoverText(String.format(Translation.TUI_GroupList_DeleteDescription.trans(), group.getNamePlain()))
.setExecuteCommand("/dominion group delete " + dominion.getName() + " " + group.getNamePlain());
Button edit = Button.create(Translation.TUI_EditButton)
.setHoverText(String.format(Translation.TUI_GroupList_EditDescription.trans(), group.getName()))
.setExecuteCommand("/dominion group setting " + dominion.getName() + " " + group.getName());
.setHoverText(String.format(Translation.TUI_GroupList_EditDescription.trans(), group.getNamePlain()))
.setExecuteCommand("/dominion group setting " + dominion.getName() + " " + group.getNamePlain());
Button add = Button.createGreen("+")
.setHoverText(String.format(Translation.TUI_GroupList_AddMemberDescription.trans(), group.getName()))
.setExecuteCommand("/dominion group select_member " + dominion.getName() + " " + group.getName() + " " + page);
.setHoverText(String.format(Translation.TUI_GroupList_AddMemberDescription.trans(), group.getNamePlain()))
.setExecuteCommand("/dominion group select_member " + dominion.getName() + " " + group.getNamePlain() + " " + page);
line.append(del.build()).append(edit.build()).append(group.getNameColoredComponent()).append(add.build());
view.add(line);
List<MemberDTO> players = MemberDTO.selectByGroupId(group.getId());
@ -80,9 +80,9 @@ public class GroupList {
if (p == null) continue;
Button remove = Button.createRed("-")
.setHoverText(
String.format(Translation.TUI_GroupList_RemoveMemberDescription.trans(), p.getLastKnownName(), group.getName())
String.format(Translation.TUI_GroupList_RemoveMemberDescription.trans(), p.getLastKnownName(), group.getNamePlain())
)
.setExecuteCommand("/dominion group remove_member " + dominion.getName() + " " + group.getName() + " " + p.getLastKnownName() + " " + page);
.setExecuteCommand("/dominion group remove_member " + dominion.getName() + " " + group.getNamePlain() + " " + p.getLastKnownName() + " " + page);
Line playerLine = new Line().setDivider("");
playerLine.append(Component.text(" "));
playerLine.append(remove.build()).append(" | " + p.getLastKnownName());

View File

@ -45,7 +45,7 @@ public class GroupSetting {
return;
}
ListView view = ListView.create(10, "/dominion group setting " + dominion.getName() + " " + group.getName());
ListView view = ListView.create(10, "/dominion group setting " + dominion.getName() + " " + group.getNamePlain());
view.title(Component.text(Translation.TUI_GroupSetting_TitleL.trans())
.append(group.getNameColoredComponent())
.append(Component.text(Translation.TUI_GroupSetting_TitleR.trans())));
@ -58,31 +58,31 @@ public class GroupSetting {
.append(Translation.TUI_Navigation_GroupSetting)
);
Button rename_btn = Button.create(Translation.TUI_GroupSetting_RenameButton)
.setHoverText(String.format(Translation.TUI_GroupSetting_RenameDescription.trans(), group.getName()))
.setExecuteCommand("/dominion cui_rename_group " + dominion.getName() + " " + group.getName());
.setHoverText(String.format(Translation.TUI_GroupSetting_RenameDescription.trans(), group.getNamePlain()))
.setExecuteCommand("/dominion cui_rename_group " + dominion.getName() + " " + group.getNamePlain());
view.add(Line.create().append(rename_btn.build()));
if (group.getAdmin()) {
view.add(Line.create()
.append(Button.createGreen("")
.setExecuteCommand(parseCommand(dominion.getName(), group.getName(), "admin", false, page))
.setExecuteCommand(parseCommand(dominion.getName(), group.getNamePlain(), "admin", false, page))
.build())
.append(
Component.text(Translation.Flags_admin_DisplayName.trans())
.hoverEvent(Component.text(Translation.Flags_admin_Description.trans()))
));
view.add(createOption(Flag.GLOW, group.getFlagValue(Flag.GLOW), dominion.getName(), group.getName(), page));
view.add(createOption(Flag.GLOW, group.getFlagValue(Flag.GLOW), dominion.getName(), group.getNamePlain(), page));
} else {
view.add(Line.create()
.append(Button.createRed("")
.setExecuteCommand(parseCommand(dominion.getName(), group.getName(), "admin", true, page))
.setExecuteCommand(parseCommand(dominion.getName(), group.getNamePlain(), "admin", true, page))
.build())
.append(
Component.text(Translation.Flags_admin_DisplayName.trans())
.hoverEvent(Component.text(Translation.Flags_admin_Description.trans()))
));
for (Flag flag : Flag.getPrivilegeFlagsEnabled()) {
view.add(createOption(flag, group.getFlagValue(flag), dominion.getName(), group.getName(), page));
view.add(createOption(flag, group.getFlagValue(flag), dominion.getName(), group.getNamePlain(), page));
}
}
view.showOn(player, page);

View File

@ -39,9 +39,9 @@ public class SelectMember {
}
int backPage = getPage(args, 4);
int page = getPage(args, 5);
ListView view = ListView.create(10, "/dominion group select_member " + dominion.getName() + " " + group.getName() + " " + backPage);
ListView view = ListView.create(10, "/dominion group select_member " + dominion.getName() + " " + group.getNamePlain() + " " + backPage);
view.title(Translation.TUI_SelectMember_Title);
Line sub = Line.create().append(String.format(Translation.TUI_SelectMember_Description.trans(), group.getName()))
Line sub = Line.create().append(String.format(Translation.TUI_SelectMember_Description.trans(), group.getNamePlain()))
.append(Button.create(Translation.TUI_BackButton).setExecuteCommand("/dominion group list " + dominion.getName() + " " + backPage).build());
view.subtitle(sub);
List<MemberDTO> members = MemberDTO.selectByDomGroupId(dominion.getId(), -1);
@ -50,7 +50,7 @@ public class SelectMember {
if (p == null) continue;
view.add(Line.create()
.append(Button.create(p.getLastKnownName())
.setExecuteCommand("/dominion group add_member " + dominion.getName() + " " + group.getName() + " " + p.getLastKnownName() + " " + backPage)
.setExecuteCommand("/dominion group add_member " + dominion.getName() + " " + group.getNamePlain() + " " + p.getLastKnownName() + " " + backPage)
.build()));
}
view.showOn(player, page);

View File

@ -99,7 +99,7 @@ public class MemberList {
}
}
if (group != null) {
prev.setDisabled(String.format(Translation.TUI_MemberList_BelongToGroup.trans(), group.getName()));
prev.setDisabled(String.format(Translation.TUI_MemberList_BelongToGroup.trans(), group.getNamePlain()));
}
line.append(remove.build());
line.append(prev.build());