Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
復活生日插件?
Browse files Browse the repository at this point in the history
  • Loading branch information
RICE0707 authored Sep 12, 2024
1 parent eddc69e commit 33b935a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BirthdayPlugin : JavaPlugin() {
LOGGER.severe("Command btd is not found")
} else {
birthdayCommand.setExecutor(BirthdayCommandExecutor())
birthdayCommand.description = "輝煌伺服器生日系統指令 (btd /help)"
birthdayCommand.description = "輝煌伺服器生日系統指令(/btd help"
LOGGER.info("Register btd command successful")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import org.bukkit.entity.Player

class GiftCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
if (sender !is Player) return Util.sendSystemMessage(sender, "&c此指令只能在遊戲內使用")
if (sender !is Player) return Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7此指令只能在遊戲內使用")

val birthday = BirthdayStorage.get(sender)

if (birthday.todayIsBirthday()) {
if (birthday.canGiveGift(sender.isOp)) {
birthday.giveGift(sender, false)
} else {
Util.sendSystemMessage(sender, "&c您已經領取過生日禮包囉~")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7您已經領取過生日禮包囉~")
}
} else {
if (birthday.calendar != null) {
Util.sendSystemMessage(sender, "&c領取生日禮包失敗,今天不是您的生日喔~")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7領取生日禮包失敗,今天不是您的生日喔~")
} else {
Util.sendSystemMessage(sender, "&c領取生日禮包失敗,您尚未設定生日")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7領取生日禮包失敗,您尚未設定生日")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ class HelpCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
val components = ComponentBuilder()
if (sender.isOp) {
components.append("§7[§6系統§7] §f飯娘:§7/btd set <ID> <YYYY> <MM> <DD> - 設定指定玩家的生日\n")
components.append("§7§6系統§7§f飯娘:§7/btd set <ID> <YYYY> <MM> <DD> - 設定指定玩家的生日\n")
} else {
components.append("§7[§6系統§7] §f飯娘:§7/btd set <YYYY> <MM> <DD> - 設定您的生日 (設定後不能再重設)\n")
components.append("§7§6系統§7§f飯娘:§7/btd set <YYYY> <MM> <DD> - 設定您的生日 (設定後不能再重設)\n")
}

components.append("§7[§6系統§7] §f飯娘:§7/btd gs off - 關閉個人生日祝福(預設開啟)\n")
components.append("§7[§6系統§7] §f飯娘:§7/btd gs on - 開啟個人生日祝福(預設開啟)\n")
components.append("§7[§6系統§7] §f飯娘:§7/btd at off - 關閉全伺服器生日祝福(預設開啟)\n")
components.append("§7[§6系統§7] §f飯娘:§7/btd at on - 開啟全伺服器生日祝福(預設開啟)\n")
components.append("§7[§6系統§7] §f飯娘:§7/btd gift - 領取生日禮包(預設自動領取,只能領取一次)\n")
components.append("§7§6系統§7§f飯娘:§7/btd gs off - 關閉個人生日祝福(預設開啟)\n")
components.append("§7§6系統§7§f飯娘:§7/btd gs on - 開啟個人生日祝福(預設開啟)\n")
components.append("§7§6系統§7§f飯娘:§7/btd at off - 關閉全伺服器生日祝福(預設開啟)\n")
components.append("§7§6系統§7§f飯娘:§7/btd at on - 開啟全伺服器生日祝福(預設開啟)\n")
components.append("§7§6系統§7§f飯娘:§7/btd gift - 領取生日禮包(預設自動領取,只能領取一次)\n")

components.append("§7[§6系統§7] §f飯娘:§7/btd help - 顯示生日指令幫助列表 (就是此頁面)")
components.append("§7§6系統§7§f飯娘:§7/btd help - 顯示生日指令幫助列表 (就是此頁面)")

sender.spigot().sendMessage(*components.create())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import org.bukkit.command.CommandSender
class ReloadCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
if (sender.isOp) {
Util.sendSystemMessage(sender, "&7正在重新載入生日插件資料...")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7正在重新載入生日插件資料...")
BirthdayStorage.reload()
BirthdayConfig.reload()
Util.sendSystemMessage(sender, "&7成功重新載入生日插件資料!")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7成功重新載入生日插件資料!")
} else {
Util.sendSystemMessage(sender, "&c您沒有權限執行此指令")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7您沒有權限執行此指令。")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import org.bukkit.entity.Player

class SetCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
if (sender !is Player) return Util.sendSystemMessage(sender, "&c此指令只能在遊戲內使用")
if (sender !is Player) return Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7此指令只能在遊戲內使用。")

if (sender.isOp && args.size == 5) {
val player = sender.server.offlinePlayers.find { it.name == args[1] || it.uniqueId.toString() == args[1] }

if (player != null) {
setBirthday(sender, player, args, 2)
} else {
Util.sendSystemMessage(sender, "找不到此玩家:${args[1]}")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7找不到此玩家:${args[1]}")
}
} else if (!sender.isOp && args.size == 4) {
val oldBirthday = BirthdayStorage.get(sender)
if (oldBirthday.calendar != null) {
Util.sendSystemMessage(sender, "您已經設定過生日了,生日只能設定一次!")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7您已經設定過生日了,生日只能設定一次!")
return
}

setBirthday(sender, sender, args, 1)
} else {
Util.sendSystemMessage(sender, "設定生日失敗,請檢查輸入的日期格式是否正確 (請輸入 [/btd help] 查看用法)")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7設定生日失敗,請檢查輸入的日期格式是否正確請輸入 [/btd help] 查看用法")
}
}

Expand All @@ -44,7 +44,7 @@ class SetCommand : CommandHandler() {
calendar.set(year, month - 1, day)

if (calendar.after(Util.getTaipeiCalendar())) {
Util.sendSystemMessage(sender, "設定生日失敗,你不是未來人 ._.")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7設定生日失敗,你不是未來人 ._.")
return
}

Expand All @@ -55,15 +55,15 @@ class SetCommand : CommandHandler() {
player,
oldData.copy(calendar = calendar)
)
Util.sendSystemMessage(sender, "成功設定生日${player.name} 的生日為:$year$month$day")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7成功設定生日${player.name} 的生日為:$year$month$day")
} catch (e: Exception) {
Util.sendSystemMessage(
sender,
"設定生日失敗,請檢查輸入的日期格式是否正確 (請輸入 [/btd help] 查看用法)"
"§7|§6系統§7|§f飯娘:§7設定生日失敗,請檢查輸入的日期格式是否正確請輸入 [/btd help] 查看用法"
)
}
} else {
Util.sendSystemMessage(sender, "設定生日失敗,請檢查輸入的日期格式是否正確 (請輸入 [/btd help] 查看用法)")
Util.sendSystemMessage(sender, §7|§6系統§7|§f飯娘:§7"設定生日失敗,請檢查輸入的日期格式是否正確請輸入 [/btd help] 查看用法")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import org.bukkit.entity.Player

class SwitchAnnouncementCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
if (sender !is Player) return Util.sendSystemMessage(sender, "&c此指令只能在遊戲內使用")
if (sender !is Player) return Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7此指令只能在遊戲內使用。")

val value = args.getOrNull(1)
val birthday = BirthdayStorage.get(sender)

when (value) {
"on" -> {
BirthdayStorage.set(sender, birthday.copy(announcement = true))
Util.sendSystemMessage(sender, "已啟用全伺服器生日祝福")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§a已啟用§7全伺服器生日祝福。")
}

"off" -> {
BirthdayStorage.set(sender, birthday.copy(announcement = false))
Util.sendSystemMessage(sender, "已停用全伺服器生日祝福")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§c已停用§7全伺服器生日祝福。")
}

else -> Util.sendSystemMessage(sender, "生日指令格式錯誤 (請輸入 [/btd help] 查看用法)")
else -> Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7生日指令格式錯誤(請輸入 [/btd help] 查看用法")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import org.bukkit.entity.Player

class SwitchGreetingsCommand : CommandHandler() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<String>) {
if (sender !is Player) return Util.sendSystemMessage(sender, "&c此指令只能在遊戲內使用")
if (sender !is Player) return Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7此指令只能在遊戲內使用。")

val value = args.getOrNull(1)
val birthday = BirthdayStorage.get(sender)

when (value) {
"on" -> {
BirthdayStorage.set(sender, birthday.copy(greetings = true))
Util.sendSystemMessage(sender, "已啟用個人生日祝福")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§a已啟用§7個人生日祝福。")
}

"off" -> {
BirthdayStorage.set(sender, birthday.copy(greetings = false))
Util.sendSystemMessage(sender, "已停用個人生日祝福")
Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§c已停用§7個人生日祝福。")
}

else -> Util.sendSystemMessage(sender, "生日指令格式錯誤 (請輸入 [/btd help] 查看用法)")
else -> Util.sendSystemMessage(sender, "§7|§6系統§7|§f飯娘:§7生日指令格式錯誤(請輸入 [/btd help] 查看用法")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Util {
}

private fun getSystemMessage(message: String): Array<BaseComponent> {
return ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "&7[&6系統&7] &f飯娘:&7$message")).create()
return ComponentBuilder(ChatColor.translateAlternateColorCodes('&', "§7|§6系統§7|§f飯娘:§7$message")).create()
}

fun sendSystemMessage(sender: CommandSender, message: String) {
Expand Down

0 comments on commit 33b935a

Please sign in to comment.