Skip to content

Commit

Permalink
初步完成API定义
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdeZhang committed Sep 22, 2024
1 parent bc2c66b commit 5bdd15f
Show file tree
Hide file tree
Showing 44 changed files with 1,087 additions and 852 deletions.
16 changes: 16 additions & 0 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
id("java")
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}

// utf-8
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
}
71 changes: 71 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/Cache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package cn.lunadeer.dominion.api;

import cn.lunadeer.dominion.api.dtos.DominionDTO;
import cn.lunadeer.dominion.api.dtos.GroupDTO;
import cn.lunadeer.dominion.api.dtos.MemberDTO;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;

public interface Cache {
/**
* 获取玩家当前所在领地
*
* @param player 玩家
* @return 玩家当前所在领地 如果玩家不在任何领地内,则返回null
*/
@Nullable DominionDTO getPlayerCurrentDominion(@NotNull Player player);

/**
* 获取指定位置的领地信息
*
* @param loc 位置
* @return 领地信息 如果位置不在任何领地内,则返回null
*/
@Nullable DominionDTO getDominionByLoc(@NotNull Location loc);

/**
* 根据 ID 获取权限组对象
*
* @param id 权限组 ID
* @return 权限组对象 如果权限组不存在,则返回null
*/
@Nullable GroupDTO getGroup(@NotNull Integer id);

/**
* 获取玩家在指定领地的成员信息
*
* @param player 玩家
* @param dominion 领地
* @return 玩家在指定领地的成员信息 如果玩家不属于领地成员,则返回null
*/
@Nullable MemberDTO getMember(@NotNull Player player, @NotNull DominionDTO dominion);

/**
* 获取玩家在指定领地的成员信息
*
* @param player_uuid 玩家 UUID
* @param dominion 领地
* @return 玩家在指定领地的成员信息 如果玩家不属于领地成员,则返回null
*/
@Nullable MemberDTO getMember(@NotNull UUID player_uuid, @NotNull DominionDTO dominion);

/**
* 获取指定 ID 的领地信息
*
* @param id 领地 ID
* @return 领地信息 如果领地不存在,则返回null
*/
@Nullable DominionDTO getDominion(@NotNull Integer id);

/**
* 获取玩家当前正在使用的权限组称号
*
* @param uuid 玩家 UUID
* @return 权限组对象 如果玩家没有使用任何权限组,则返回null
*/
@Nullable GroupDTO getPlayerUsingGroupTitle(@NotNull UUID uuid);
}
9 changes: 9 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/Dominion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cn.lunadeer.dominion.api;

public interface Dominion {

static Cache getInstance() throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
// Cache.instance is a static field in the Cache class
return (Cache) Class.forName("cn.lunadeer.dominion.Cache").getDeclaredField("instance").get(null);
}
}
66 changes: 66 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/dtos/DominionDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package cn.lunadeer.dominion.api.dtos;

import org.bukkit.Location;
import org.bukkit.World;
import org.jetbrains.annotations.Nullable;

import java.util.UUID;

public interface DominionDTO {
// getters and setters
Integer getId();

UUID getOwner();

String getName();

@Nullable World getWorld();

UUID getWorldUid();

Integer getX1();

Integer getY1();

Integer getZ1();

Integer getX2();

Integer getY2();

Integer getZ2();

Integer getSquare();

Integer getVolume();

Integer getWidthX();

Integer getHeight();

Integer getWidthZ();

Integer getParentDomId();

String getJoinMessage();

String getLeaveMessage();

Boolean getFlagValue(Flag flag);

Location getTpLocation();

Location getLocation1();

Location getLocation2();

int getColorR();

int getColorG();

int getColorB();

String getColor();

int getColorHex();
}
13 changes: 13 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/dtos/Flag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cn.lunadeer.dominion.api.dtos;

public interface Flag {
String getFlagName();

String getDisplayName();

String getDescription();

Boolean getDefaultValue();

Boolean getEnable();
}
19 changes: 19 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/dtos/GroupDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cn.lunadeer.dominion.api.dtos;

import net.kyori.adventure.text.Component;

public interface GroupDTO {
Integer getId();

Integer getDomID();

String getName();

Component getNameColoredComponent();

String getNameColoredBukkit();

Boolean getAdmin();

Boolean getFlagValue(Flag flag);
}
17 changes: 17 additions & 0 deletions api/src/main/java/cn/lunadeer/dominion/api/dtos/MemberDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cn.lunadeer.dominion.api.dtos;

import java.util.UUID;

public interface MemberDTO {
Integer getId();

UUID getPlayerUUID();

Boolean getAdmin();

Integer getDomID();

Integer getGroupId();

Boolean getFlagValue(Flag flag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package cn.lunadeer.dominion.api.dtos;

import java.util.UUID;

public interface PrivilegeTemplateDTO {
Integer getId();

UUID getCreator();

String getName();

Boolean getAdmin();

Boolean getFlagValue(Flag flag);
}
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ tasks.withType<JavaCompile> {
}

dependencies {
implementation(project(":api"))
compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT")
}
Loading

0 comments on commit 5bdd15f

Please sign in to comment.