Skip to content

Commit ca4c906

Browse files
committed
Update.
1 parent 92723fa commit ca4c906

File tree

9 files changed

+123
-11
lines changed

9 files changed

+123
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![](http://mc3.roselle.vip:602/FastScript/animate_logo.gif)
1+
![](http://mc3.roselle.vip:602/FastScript/big_logo.gif)
22
***
33
### About
44
FastScript is a Spigot plugin, which can run JavaScript-based scripts more efficiently.

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version '0.11'
88
defaultTasks 'clean', 'build', 'test', 'jar'
99

1010
repositories {
11+
jcenter()
1112
mavenCentral()
1213
maven {url 'https://repo.codemc.org/repository/maven-public'}
1314
maven {url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'}
@@ -21,6 +22,7 @@ dependencies {
2122
compile 'commons-io:commons-io:2.7'
2223
compile 'com.alibaba:fastjson:1.2.9'
2324
compile "org.jetbrains.kotlin:kotlin-stdlib"
25+
compile "com.andreapivetta.kolor:kolor:1.0.0"
2426
implementation 'org.yaml:snakeyaml:1.27'
2527
implementation 'org.apache.commons:commons-lang3:3.10'
2628
implementation 'org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

src/main/kotlin/me/scoretwo/fastscript/FastScript.kt

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.scoretwo.fastscript
22

3+
import com.andreapivetta.kolor.*
34
import me.scoretwo.fastscript.api.plugin.FastScriptMain
45
import me.scoretwo.fastscript.api.script.ScriptManager
56
import java.io.File
@@ -16,10 +17,103 @@ class FastScript(val dataFolder: File, private val classLoader: ClassLoader) {
1617
initInternalScripts()
1718
}
1819

20+
/**
21+
* 该创意来源于 TrMenu
22+
* @author Arasple
23+
*/
24+
25+
fun printLogo() = mutableListOf(
26+
"___________ __ _________ .__ __ ",
27+
"\\_ _____/____ _______/ |_/ _____/ ___________|__|______/ |_ ",
28+
" | __) \\__ \\ / ___/\\ __\\_____ \\_/ ___\\_ __ \\ \\____ \\ __\\",
29+
" | \\ / __ \\_\\___ \\ | | / \\ \\___| | \\/ | |_> > | ",
30+
" \\___ / (____ /____ > |__|/_______ /\\___ >__| |__| __/|__| ",
31+
" \\/ \\/ \\/ \\/ \\/ |__| "
32+
).let {
33+
it.forEachIndexed { index, raw ->
34+
if (raw.isNotBlank()) {
35+
val line = raw.toCharArray()
36+
val width = (2..8).random()
37+
var randomIndex: Int
38+
do {
39+
randomIndex = (2..line.size - width).random()
40+
} while (String(line.copyOfRange(randomIndex, randomIndex + width)).isBlank())
41+
val replace = String(line.copyOfRange(randomIndex, randomIndex + width))
42+
it[index] = String(line).replaceFirst(replace, "§${arrayOf('9', 'b', '3').random()}$replace§8")
43+
}
44+
}
45+
printColors(it)
46+
}
47+
1948
companion object {
20-
var instance: FastScript? = null
49+
lateinit var instance: FastScript
2150
lateinit var main: FastScriptMain
2251

52+
@JvmStatic
53+
fun main(args: Array<out String>) {
54+
55+
main = object : FastScriptMain {
56+
override fun getDataFolder(): File {
57+
return File("FastScript")
58+
}
59+
60+
override fun getPluginClassLoader(): ClassLoader {
61+
return javaClass.classLoader
62+
}
63+
64+
override fun setPlaceholder(player: Any, string: String): String {
65+
return string
66+
}
67+
68+
override fun onReload() {}
69+
70+
override fun sendConsoleMessage(message: String) {
71+
println(message.yellow())
72+
}
73+
74+
override fun sendMessage(sender: Any, string: String) {
75+
println(string.yellow())
76+
}
77+
}
78+
79+
instance = FastScript(main.getDataFolder(), main.getPluginClassLoader())
80+
81+
instance.printLogo()
82+
}
83+
84+
fun printColors(list: MutableList<String>) {
85+
list.forEach { printColors(it) }
86+
}
87+
88+
fun printColors(string: String) {
89+
for (s in string.split("§")) {
90+
if (s.isEmpty()) continue
91+
val index = s.substring(0,1)
92+
val rawMessage = s.substring(1)
93+
94+
when(index) {
95+
"a"-> print(rawMessage.lightGreen())
96+
"b"-> print(rawMessage.lightCyan())
97+
"c"-> print(rawMessage.lightRed())
98+
"d"-> print(rawMessage.lightMagenta())
99+
"e"-> print(rawMessage.lightYellow())
100+
"f"-> print(rawMessage.lightWhite())
101+
"0"-> print(rawMessage.black())
102+
"1"-> print(rawMessage.blue())
103+
"2"-> print(rawMessage.green())
104+
"3"-> print(rawMessage.cyan())
105+
"4"-> print(rawMessage.red())
106+
"5"-> print(rawMessage.magenta())
107+
"6"-> print(rawMessage.yellow())
108+
"7"-> print(rawMessage.lightGray())
109+
"8"-> print(rawMessage.lightGray())
110+
"9"-> print(rawMessage.lightBlue())
111+
else-> print(rawMessage.lightGray())
112+
}
113+
}
114+
println()
115+
}
116+
23117
fun setBootstrap(main: FastScriptMain) {
24118
if (instance != null) {
25119
throw UnsupportedOperationException("Cannot redefine instance")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package me.scoretwo.fastscript.api.config
2+
3+
class ScriptImport {
4+
5+
constructor() {
6+
7+
}
8+
9+
10+
}

src/main/kotlin/me/scoretwo/fastscript/bukkit/BukkitSection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BukkitSection: JavaPlugin(), FastScriptMain {
1919
}
2020

2121
override fun onEnable() {
22-
FastScript.instance?.onReload()
22+
FastScript.instance.onReload()
2323

2424
commandMap.register(description.name, object : Command(description.name, "", "/" + description.name, listOf("script","bukkitScript")) {
2525
override fun execute(sender: CommandSender, label: String, args: Array<out String>): Boolean {

src/main/kotlin/me/scoretwo/fastscript/bungee/BungeeSection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BungeeSection: Plugin(), FastScriptMain {
1414
}
1515

1616
override fun onEnable() {
17-
FastScript.instance?.onReload()
17+
FastScript.instance.onReload()
1818
}
1919

2020
override fun getPluginClassLoader(): ClassLoader {

src/main/kotlin/me/scoretwo/fastscript/config/ScriptOption.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ class ScriptOption {
55

66
companion object {
77

8-
interface HasMethod
8+
enum class TYPE { INIT, OBJECT, STATIC }
99

10-
class Object(clazz: String, args: Array<Any?>): HasMethod
1110
class Static(clazz: String)
11+
class Object(clazz: String, args: Array<Any?>)
12+
1213
class Method(name: String, args: Array<Any?>)
1314

1415
}

src/main/resources/scripts/example.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ main: 'main'
77

88
# 导入自定义 object 作为变量
99
import:
10-
# a: 'static|org.bukkit.Bukkit#getServer|args1|args2...'
10+
# demo1 'static|org.bukkit.Bukkit#getServer|args1|args2...'
1111

12-
# b: 'object|org.bukkit.util.Vector|1|2...'
12+
# demo2: 'object|org.bukkit.util.Vector|1|2...'
1313

14-
c:
14+
vector:
1515
init:
1616
class: 'org.bukkit.util.Vector'
1717
args:
1818
- 1
1919
- 100
2020
- 1
21-
d:
21+
vector_length:
2222
object:
2323
class: 'org.bukkit.util.Vector'
2424
args: []
2525
method:
2626
name: 'length'
2727
args: []
2828

29-
e:
29+
server:
3030
static:
3131
class: 'org.bukkit.Bukkit'
3232
method:

0 commit comments

Comments
 (0)