-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
199 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
dotman-plugin/src/main/java/net/minevn/dotman/config/MilestonesMaster.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.minevn.dotman.config | ||
|
||
import net.minevn.dotman.config.Milestones.Component | ||
import net.minevn.dotman.utils.Utils.Companion.getBarColor | ||
import net.minevn.dotman.utils.Utils.Companion.getBarStyle | ||
import net.minevn.dotman.utils.Utils.Companion.info | ||
import net.minevn.dotman.utils.Utils.Companion.warning | ||
|
||
class MilestonesMaster : FileConfig("mocnaptong") { | ||
private var components: List<Component> = emptyList() | ||
|
||
init { | ||
loadComponents() | ||
} | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
private fun loadComponents() { | ||
var premiumWarning = false | ||
components = (config.getList("mocnaptong") ?: emptyList()).map { | ||
try { | ||
it as Map<*, *> | ||
val bossBar = it.getOrDefault("bossbar", null) as String? | ||
val from = it.getOrDefault("from", 0) as Int | ||
val barColor = getBarColor(it.getOrDefault("bossbar-color", null) as String?) | ||
val barStyle = getBarStyle(it.getOrDefault("bossbar-style", null) as String?) | ||
val component = Component(it["type"] as String, it["amount"] as Int, it["commands"] as List<String>, | ||
bossBar, from, barColor, barStyle) | ||
|
||
if (component.type !in listOf("all", "week", "month")) { | ||
warning("Loại mốc nạp \"${component.type}\" không hợp lệ. Chỉ chấp nhận all, week, month") | ||
return@map null | ||
} | ||
if (component.type != "all") { | ||
if (!premiumWarning) { | ||
premiumWarning = true | ||
warning("Tính năng mốc nạp theo tuần, tháng chỉ có ở phiên bản DotMan premium. " + | ||
"Hãy mua plugin để ủng hộ author nhé!") | ||
} | ||
return@map null | ||
} | ||
|
||
component | ||
} catch (e: Exception) { | ||
e.warning("Có một mốc nạp không hợp lệ, hãy liên hệ developer để được hỗ trợ") | ||
null | ||
} | ||
}.filterNotNull() | ||
|
||
info("Đã nạp ${components.size} mốc nạp tổng.") | ||
} | ||
|
||
override fun reload() { | ||
super.reload() | ||
loadComponents() | ||
} | ||
|
||
fun getAll() = components.toList() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Mốc nạp tổng và các lệnh thực thi khi đạt mốc | ||
# Có thể dùng cho: Server booster, tiến độ nạp, ... | ||
mocnaptong: | ||
- type: all # Toàn thời gian | ||
# Lưu ý: Đối với mốc nạp toàn thời gian, tiền độ donate sẽ tính theo donate của server từ trước đến nay. | ||
#bossbar: 'Donate server: %current%/%target% VNĐ' # Bossbar hiển thị tiến độ (bỏ comment để hiển thị) | ||
#from: 0 # mức hiển bossbar | ||
bossbar-style: GREEN | ||
bossbar-color: SEGMENTED_10 | ||
amount: 10000000 # Giá trị tích lũy | ||
commands: # Các lệnh chạy cho player khi đạt mốc | ||
- 'say Donate của server đã đạt 10 triệu!' | ||
|
||
- type: week # Mốc nạp tuần (tính năng premium) | ||
bossbar-style: GREEN | ||
bossbar-color: SEGMENTED_10 | ||
amount: 1000000 | ||
commands: | ||
- 'say Tuần này donate của server đã đạt 1 triệu!' | ||
|
||
- type: month # Mốc nạp tháng (tính năng premium) | ||
bossbar-style: GREEN | ||
bossbar-color: SEGMENTED_10 | ||
amount: 5000000 | ||
commands: | ||
- 'say Tháng này donate của server đã đạt 5 triệu!' |