Skip to content

Commit

Permalink
Merge pull request #79 from DongShaoNB/feat/support-papi
Browse files Browse the repository at this point in the history
[FEATURE] support papi
  • Loading branch information
DongShaoNB authored Aug 22, 2024
2 parents 85c5244 + 7877989 commit cce7727
Show file tree
Hide file tree
Showing 21 changed files with 210 additions and 191 deletions.
7 changes: 7 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ repositories {
name = "codemc-repo"
url = uri("https://repo.codemc.org/repository/maven-public/")
}
maven {
// PlaceholderAPI
name = "placeholderapi"
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
}
maven {
// UniversalScheduler
name = "jitpack"
Expand Down Expand Up @@ -68,6 +73,8 @@ dependencies {
compileOnly(files("lib/NexEngine.jar"))
// NexAuth
compileOnly(files("lib/NexAuth-2.0.5.jar"))
// PlaceholderAPI
compileOnly("me.clip:placeholderapi:2.11.6")
// bStats
implementation("org.bstats:bstats-bukkit:3.0.3")
// DazzleConf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import cc.dsnb.bedrockplayersupport.util.UpdateUtil
import com.github.Anon8281.universalScheduler.UniversalScheduler
import com.github.Anon8281.universalScheduler.scheduling.schedulers.TaskScheduler
import net.kyori.adventure.text.minimessage.MiniMessage
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import org.bstats.bukkit.Metrics
import org.bstats.charts.SimplePie
import org.bukkit.Bukkit
Expand Down Expand Up @@ -46,6 +47,7 @@ class BedrockPlayerSupport : JavaPlugin() {
lateinit var sunlightForm: SunLightForm
lateinit var floodgateApi: FloodgateApi
val miniMessage = MiniMessage.miniMessage()
val legacySection = LegacyComponentSerializer.legacySection()
const val PREFIX = "[BedrockPlayerSupport] "
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
Expand All @@ -11,13 +12,19 @@ import org.bukkit.entity.Player
*/
class HomeFormCommand : CommandExecutor {

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
override fun onCommand(
sender: CommandSender,
command: Command,
label: String,
args: Array<String>,
): Boolean {
if (sender is Player) {
if (BedrockPlayerSupport.floodgateApi.isFloodgatePlayer(sender.uniqueId)) {
BedrockPlayerSupport.mainForm.openBedrockHomeForm(sender)
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
StringUtil.formatTextToComponent(
sender,
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player

class KitFormCommand : CommandExecutor {

override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>): Boolean {
override fun onCommand(
sender: CommandSender,
command: Command,
label: String,
args: Array<String>,
): Boolean {
if (sender is Player) {
if (BedrockPlayerSupport.floodgateApi.isFloodgatePlayer(sender.uniqueId)) {
BedrockPlayerSupport.mainForm.openBedrockKitForm(sender)
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
StringUtil.formatTextToComponent(
sender,
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import cc.dsnb.bedrockplayersupport.util.TimeUtil
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
Expand Down Expand Up @@ -44,15 +45,15 @@ class MainCommand : CommandExecutor {
}
if (sender is Player) {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
langConfig.reloadSuccessfully()
StringUtil.formatTextToComponent(
sender, langConfig.reloadSuccessfully()
.replace("%time%", time.toString())
)
)
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
BedrockPlayerSupport.PREFIX +
StringUtil.formatTextToComponent(
null, BedrockPlayerSupport.PREFIX +
langConfig.reloadSuccessfully()
.replace("%time%", time.toString())
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
Expand All @@ -20,16 +21,16 @@ class MsgFormCommand : CommandExecutor {
return true
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage
.deserialize(
BedrockPlayerSupport.langConfigManager.getConfigData()
.noOtherOnlinePlayer()
)
StringUtil.formatTextToComponent(
sender, BedrockPlayerSupport.langConfigManager.getConfigData()
.noOtherOnlinePlayer()
)
)
}
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
StringUtil.formatTextToComponent(
sender,
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
Expand All @@ -20,18 +21,16 @@ class TpFormCommand : CommandExecutor {
return true
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage
.deserialize(
BedrockPlayerSupport.langConfigManager.getConfigData()
.noOtherOnlinePlayer()
)
StringUtil.formatTextToComponent(
sender, BedrockPlayerSupport.langConfigManager.getConfigData()
.noOtherOnlinePlayer()
)
)
}
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
StringUtil.formatTextToComponent(
sender,
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cc.dsnb.bedrockplayersupport.command

import cc.dsnb.bedrockplayersupport.BasicPlugin.*
import cc.dsnb.bedrockplayersupport.BedrockPlayerSupport
import cc.dsnb.bedrockplayersupport.util.StringUtil
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
Expand All @@ -18,7 +18,8 @@ class WarpFormCommand : CommandExecutor {
BedrockPlayerSupport.mainForm.openBedrockWarpForm(sender)
} else {
sender.sendMessage(
BedrockPlayerSupport.miniMessage.deserialize(
StringUtil.formatTextToComponent(
sender,
BedrockPlayerSupport.langConfigManager.getConfigData().notBedrockPlayer()
)
)
Expand Down
37 changes: 24 additions & 13 deletions src/main/kotlin/cc/dsnb/bedrockplayersupport/config/MainConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,23 @@ interface MainConfig {
@Order(30)
fun authPlugin(): String

@ConfKey("plugin.support-papi")
@ConfComments(
"启用表单支持 PlaceholderAPI",
"启用后可以在表单内使用 PlaceholderAPI",
"Enable form support PlaceholderAPI",
"Enable to use PlaceholderAPI within form"
)
@DefaultBoolean(true)
@Order(40)
fun enableSupportPAPI(): Boolean

@ConfKey("form.teleport.enable")
@ConfComments(
"启用基岩版TP表单(/tpgui)", "Enable bedrock TP form (/tpgui)"
)
@DefaultBoolean(true)
@Order(40)
@Order(100)
fun enableTeleportForm(): Boolean

@ConfKey("form.teleport.cross-server")
Expand All @@ -78,23 +89,23 @@ interface MainConfig {
"Enable support cross server teleport of form"
)
@DefaultBoolean(false)
@Order(41)
@Order(101)
fun enableCrossServer(): Boolean

@ConfKey("form.msg.enable")
@ConfComments(
"启用基岩版消息表单(/msggui)", "Enable bedrock msg form (/msggui)"
)
@DefaultBoolean(true)
@Order(50)
@Order(110)
fun enableMsgForm(): Boolean

@ConfKey("form.home.enable")
@ConfComments(
"启用基岩版家表单(/homegui)", "Enable bedrock home form (/homegui)"
)
@DefaultBoolean(true)
@Order(60)
@Order(120)
fun enableHomeForm(): Boolean

@ConfKey("form.back.enable")
Expand All @@ -103,7 +114,7 @@ interface MainConfig {
"Enable bedrock back death location form (Automatically open form after player's death and respawn)"
)
@DefaultBoolean(true)
@Order(70)
@Order(130)
fun enableBackDeathLocForm(): Boolean

@ConfKey("form.back.command")
Expand All @@ -114,7 +125,7 @@ interface MainConfig {
"If the command of back death location is /dback or other command, please replace it here",
)
@DefaultString("/back")
@Order(71)
@Order(131)
fun backDeathLocCommand(): String

@ConfKey("form.back.open-delay-time")
Expand All @@ -127,15 +138,15 @@ interface MainConfig {
"If the form does not open after player respawn, please try increasing this value"
)
@DefaultLong(20)
@Order(72)
@Order(132)
fun backDeathLocFormOpenDelayTick(): Long

@ConfKey("form.warp.enable")
@ConfComments(
"启用基岩版传送点表单(/warpgui)", "Enable bedrock warp form (/warpgui)"
)
@DefaultBoolean(true)
@Order(80)
@Order(140)
fun enableWarpForm(): Boolean

@ConfKey("form.kit.enable")
Expand All @@ -146,31 +157,31 @@ interface MainConfig {
"Only CMI / EssentialsX / SunLight is available",
)
@DefaultBoolean(true)
@Order(90)
@Order(150)
fun enableKitForm(): Boolean

@ConfKey("auth.register.enable")
@ConfComments(
"启用基岩版玩家自动注册功能", "Enable bedrock player automatic register function"
)
@DefaultBoolean(false)
@Order(100)
@Order(200)
fun enableRegister(): Boolean

@ConfKey("auth.register.password-length")
@ConfComments(
"随机的密码的长度", "The length of random password"
)
@DefaultInteger(16)
@Order(101)
@Order(201)
fun passwordLength(): Int

@ConfKey("auth.login.enable")
@ConfComments(
"启用基岩版玩家自动登录功能", "Enable bedrock player automatic login function"
)
@DefaultBoolean(false)
@Order(110)
@Order(210)
fun enableLogin(): Boolean

@ConfKey("auth.login.command")
Expand All @@ -185,7 +196,7 @@ interface MainConfig {
"Available variable: %playerName% player name"
)
@DefaultString("forcelogin %playerName%")
@Order(111)
@Order(211)
fun forceLoginCommand(): String

}
Loading

0 comments on commit cce7727

Please sign in to comment.