Skip to content

Commit

Permalink
更新并支持新邮件系统
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhangup committed Apr 16, 2024
1 parent 7c4ce1c commit 2d35302
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 136 deletions.
34 changes: 18 additions & 16 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import io.izzel.taboolib.gradle.*

plugins {
`java-library`
`maven-publish`
id("io.izzel.taboolib") version "1.56"
id("org.jetbrains.kotlin.jvm") version "1.7.21"
id("io.izzel.taboolib") version "2.0.11"
id("org.jetbrains.kotlin.jvm") version "1.8.22"
}

taboolib {
install("common")
install("common-5")
install("module-configuration")
install("module-database")
install("platform-velocity")
install("expansion-command-helper")
classifier = null
version = "6.0.10-114"
env {
install(UNIVERSAL, VELOCITY)
install(
DATABASE,
CONFIGURATION
)

version {
taboolib = "6.1.1-beta17"
}
}
}

repositories {
mavenLocal()
maven {
url = uri("https://papermc.io/repo/repository/maven-public/")
}
maven {
url = uri("https://jitpack.io")
}
mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://jitpack.io")
}

dependencies {
compileOnly("com.velocitypowered:velocity-api:3.1.1")
compileOnly("mysql:mysql-connector-java:8.0.30")
compileOnly("net.kyori:adventure-text-minimessage:4.12.0")

compileOnly(kotlin("stdlib"))
compileOnly(fileTree("libs"))
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/me/xiaozhangup/picturelogin/PictureUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,18 @@ public ImageMessage getMessage(List<String> messages, BufferedImage image, Playe
.replace("%player_name%", player.getUsername())
.replace("%online%", String.valueOf(PictureLoginJava.server.getPlayerCount()));

int note = DatabaseManager.getTableNote().getByTo(player.getUniqueId().toString());
int note = DatabaseManager.getTableMailbox().byReceiver(player.getUniqueId(), MailType.NOTE);
if (note > 0) {
message = message.replace("%note%", "<click:run_command:'/note all'><hover:show_text:'<color:#99d1db>单击阅读</color>'>单击阅读 " + note + " 条留言</hover></click>");
message = message.replace("%note%", "<click:run_command:'/note'><hover:show_text:'<color:#99d1db>单击阅读</color>'>单击阅读 " + note + " 件信封</hover></click>");
} else {
message = message.replace("%note%", "没有未读的留言");
message = message.replace("%note%", "没有未读的信封");
}

int mail = DatabaseManager.getTableMail().getByTo(player.getUniqueId().toString());
int mail = DatabaseManager.getTableMailbox().byReceiver(player.getUniqueId(), MailType.MAIL);
if (mail > 0) {
message = message.replace("%mail%", "<click:run_command:'/mail all'><hover:show_text:'<color:#e5c890>单击查收</color>'>单击查收 " + mail + " 条邮件</hover></click>");
message = message.replace("%mail%", "<click:run_command:'/mail'><hover:show_text:'<color:#e5c890>单击查收</color>'>单击查收 " + mail + " 件包裹</hover></click>");
} else {
message = message.replace("%mail%", "没有未读的邮件");
message = message.replace("%mail%", "没有未收的包裹");
}

msg[count++] = MiniMessage.miniMessage().deserialize(message);
Expand Down
9 changes: 9 additions & 0 deletions src/main/kotlin/me/xiaozhangup/picturelogin/MailType.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package me.xiaozhangup.picturelogin

enum class MailType(
val display: String
) {
MAIL("包裹"),
NOTE("信封"),
RICH("邮件")
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package me.xiaozhangup.picturelogin.data

import me.xiaozhangup.picturelogin.PictureLogin
import me.xiaozhangup.picturelogin.data.table.TableMail
import me.xiaozhangup.picturelogin.data.table.TableNote
import me.xiaozhangup.picturelogin.data.table.TableMailbox
import taboolib.common.LifeCycle
import taboolib.common.platform.Awake
import taboolib.common.platform.SkipTo
Expand All @@ -18,11 +17,7 @@ object DatabaseManager {
private set

@JvmStatic
lateinit var tableNote: TableNote
private set

@JvmStatic
lateinit var tableMail: TableMail
lateinit var tableMailbox: TableMailbox
private set

private val databaseConfig: taboolib.library.configuration.ConfigurationSection by lazy {
Expand All @@ -36,8 +31,7 @@ object DatabaseManager {
host = HostSQL(databaseConfig)
dataSource = host.createDataSource()

tableNote = TableNote().apply { createTable() }
tableMail = TableMail().apply { createTable() }
tableMailbox = TableMailbox().apply { createTable() }
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package me.xiaozhangup.picturelogin.data.table

import me.xiaozhangup.picturelogin.MailType
import me.xiaozhangup.picturelogin.data.DatabaseManager
import me.xiaozhangup.picturelogin.data.DatabaseManager.dataSource
import taboolib.module.database.*
import java.util.*

class TableMailbox : SQLTable {

override val table: Table<Host<SQL>, SQL> = Table("mailbox", DatabaseManager.host) {
add("uuid") {
type(ColumnTypeSQL.VARCHAR, 36) {
options(ColumnOptionSQL.KEY)
}
}

add("type") {
type(ColumnTypeSQL.TINYTEXT)
}

add("title") {
type(ColumnTypeSQL.TINYTEXT)
}

add("sender") {
type(ColumnTypeSQL.VARCHAR, 36)
}

add("receiver") {
type(ColumnTypeSQL.VARCHAR, 36)
}

add("context") {
type(ColumnTypeSQL.TEXT)
}
}

fun bySender(sender: UUID, type: MailType? = null): Int {
return table.select(dataSource) {
where {
"sender" eq sender.toString()
if (type != null) "type" eq type.name
}
}.map { }.size
}

fun byReceiver(receiver: UUID, type: MailType? = null): Int {
return table.select(dataSource) {
where {
"receiver" eq receiver.toString()
if (type != null) "type" eq type.name
}
}.map { }.size
}
}

This file was deleted.

0 comments on commit 2d35302

Please sign in to comment.