-
Notifications
You must be signed in to change notification settings - Fork 0
/
!main.sk
93 lines (75 loc) · 2.83 KB
/
!main.sk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# ##############################
# Main file of imagesk
#
# https://github.com/Blueyescat/imagesk
#
# Please don't change this file, write your script in another sk file.
# ##############################
options:
# If changing this is really important for you, you need to change it in all imagesk files.
variable: imagesk # {imagesk::xxx}
import:
java.awt.Color
java.awt.Paint
java.awt.image.BufferedImage
java.lang.Math
java.util.Base64
org.bukkit.Bukkit
ch.njol.skript.Skript
ch.njol.skript.util.Color as SkriptColor
ch.njol.skript.variables.Variables
on load:
set {{@variable}::Logger} to Bukkit.getServer().getLogger()
set {{@variable}::Decoder} to Base64.getDecoder()
set {{@variable}::Encoder} to Base64.getEncoder()
# Workaround for a skript-mirror limitation
delete {{@variable}::useFloatColorMethod}
set {_color} to try new Color(255, 255, 255)
if "%last java error%" contains "Color parameter outside of expected range":
set {{@variable}::useFloatColorMethod} to true
on skript unload:
loop {{@variable}::*}:
if loop-index is not "lastImage":
delete {{@variable}::%loop-index%} and {{@variable}::%loop-index%::*}
expression [the] [last[ly]] [(created|generated|received|taken)] (image|img):
get:
return {{@variable}::lastImage}
delete:
delete {{@variable}::lastImage}
# Do not use the syntaxes below in your scripts
effect imagesk [(1¦parse)] error %string%:
trigger:
if parse mark is 1:
Skript.error(expression-1)
else:
{{@variable}::Logger}.severe("[imagesk] %expression-1%")
effect imagesk warning %string%:
trigger:
{{@variable}::Logger}.warning("[imagesk] %expression-1%")
effect imagesk set variable %object% to %object% in %event%:
trigger:
set {_variable} to expression-1
set {_name} to {_variable}.getName().toString(expression-3)
Variables.setVariable({_name}, expression-2, expression-3, {_variable}.isLocal())
function imagesk_paintFrom(color: object) :: object:
if {_color} is instance of SkriptColor:
return new Color({_color}.getBukkitColor().asRGB())
if {_color} is instance of Paint:
return {_color}
function imagesk_areColors(paints: objects) :: boolean:
loop {_paints::*}:
if loop-value is not instance of Color:
return false
return true
function imagesk_toRadians(degrees: number) :: number:
return Math.toRadians({_degrees})
function imagesk_pixelColor(image: object, x: number, y: number) :: object:
set {_rgb} to {_image}.getRGB({_x}, {_y})
return new Color({_rgb})
function imagesk_setPixelColor(image: object, x: number, y: number, rgb: number):
{_image}.setRGB({_x}, {_y}, {_rgb})
function imagesk_copiedImage(image: object) :: object:
return new BufferedImage({_image}.getColorModel(), {_image}.copyData(null), {_image}.isAlphaPremultiplied(), null)
function imagesk_skriptColor(color: object) :: color:
return {_color}
# Do not use the syntaxes above in your scripts