mirror of
https://github.com/jie65535/JDice.git
synced 2025-06-02 17:39:11 +08:00
Add numeric range limit (<=100)
Add gradle-wrapper.properties Fix multiple dice issue
This commit is contained in:
parent
907a30b654
commit
7981ca3fef
@ -7,7 +7,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "top.jie65535"
|
group = "top.jie65535"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven("https://maven.aliyun.com/repository/public")
|
maven("https://maven.aliyun.com/repository/public")
|
||||||
|
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
@ -12,12 +12,12 @@ object JDice : KotlinPlugin(
|
|||||||
JvmPluginDescription(
|
JvmPluginDescription(
|
||||||
id = "top.jie65535.dice",
|
id = "top.jie65535.dice",
|
||||||
name = "J Dice",
|
name = "J Dice",
|
||||||
version = "0.1.1",
|
version = "0.1.2",
|
||||||
) {
|
) {
|
||||||
author("jie65535")
|
author("jie65535")
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
private val regex = Regex("""\b(\d*)[dD](\d+)\b""")
|
private val regex = Regex("""\b(\d{0,3})[dD](\d{1,3})\b""")
|
||||||
private val random = Random(System.currentTimeMillis())
|
private val random = Random(System.currentTimeMillis())
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
@ -27,8 +27,11 @@ object JDice : KotlinPlugin(
|
|||||||
val (c, d) = it.destructured
|
val (c, d) = it.destructured
|
||||||
val count = if (c.isEmpty()) 1 else c.toInt()
|
val count = if (c.isEmpty()) 1 else c.toInt()
|
||||||
val top = d.toInt()
|
val top = d.toInt()
|
||||||
if (count > 0 && top > 1) {
|
if (count > 0 && count <= 100 && top > 1 && top <= 100) {
|
||||||
val value = random.nextInt(count, count * top + 1)
|
var value = 0
|
||||||
|
for (i in 1..count) {
|
||||||
|
value += random.nextInt(1, top + 1)
|
||||||
|
}
|
||||||
subject.sendMessage(message.quote() + value.toString())
|
subject.sendMessage(message.quote() + value.toString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user