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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
package io.dico.parcels2.util.ext
import org.bukkit.Material
import org.bukkit.Material.*
/*
colors:
WHITE_$, ORANGE_$, MAGENTA_$, LIGHT_BLUE_$, YELLOW_$, LIME_$, PINK_$, GRAY_$, LIGHT_GRAY_$, CYAN_$, PURPLE_$, BLUE_$, BROWN_$, GREEN_$, RED_$, BLACK_$,
wood:
OAK_$, BIRCH_$, SPRUCE_$, JUNGLE_$, ACACIA_$, DARK_OAK_$,
*/
val Material.isBed
get() = when (this) {
WHITE_BED,
ORANGE_BED,
MAGENTA_BED,
LIGHT_BLUE_BED,
YELLOW_BED,
LIME_BED,
PINK_BED,
GRAY_BED,
LIGHT_GRAY_BED,
CYAN_BED,
PURPLE_BED,
BLUE_BED,
BROWN_BED,
GREEN_BED,
RED_BED,
BLACK_BED -> true
else -> false
}
val Material.isWoodDoor
get() = when (this) {
OAK_DOOR,
BIRCH_DOOR,
SPRUCE_DOOR,
JUNGLE_DOOR,
ACACIA_DOOR,
DARK_OAK_DOOR -> true
else -> false
}
val Material.isWoodTrapdoor
get() = when (this) {
OAK_TRAPDOOR,
BIRCH_TRAPDOOR,
SPRUCE_TRAPDOOR,
JUNGLE_TRAPDOOR,
ACACIA_TRAPDOOR,
DARK_OAK_TRAPDOOR -> true
else -> false
}
val Material.isWoodFenceGate
get() = when (this) {
OAK_FENCE_GATE,
BIRCH_FENCE_GATE,
SPRUCE_FENCE_GATE,
JUNGLE_FENCE_GATE,
ACACIA_FENCE_GATE,
DARK_OAK_FENCE_GATE -> true
else -> false
}
val Material.isWoodButton
get() = when (this) {
OAK_BUTTON,
BIRCH_BUTTON,
SPRUCE_BUTTON,
JUNGLE_BUTTON,
ACACIA_BUTTON,
DARK_OAK_BUTTON -> true
else -> false
}
private fun getMaterialPrefixed(prefix: String, name: String): Material {
return Material.getMaterial("${prefix}_$name") ?: throw IllegalArgumentException("Material ${prefix}_$name doesn't exist")
}
fun getMaterialsWithWoodTypePrefix(name: String) = arrayOf(
getMaterialPrefixed("OAK", name),
getMaterialPrefixed("BIRCH", name),
getMaterialPrefixed("SPRUCE", name),
getMaterialPrefixed("JUNGLE", name),
getMaterialPrefixed("ACACIA", name),
getMaterialPrefixed("DARK_OAK", name)
)
fun getMaterialsWithWoolColorPrefix(name: String) = arrayOf(
getMaterialPrefixed("WHITE", name),
getMaterialPrefixed("ORANGE", name),
getMaterialPrefixed("MAGENTA", name),
getMaterialPrefixed("LIGHT_BLUE", name),
getMaterialPrefixed("YELLOW", name),
getMaterialPrefixed("LIME", name),
getMaterialPrefixed("PINK", name),
getMaterialPrefixed("GRAY", name),
getMaterialPrefixed("LIGHT_GRAY", name),
getMaterialPrefixed("CYAN", name),
getMaterialPrefixed("PURPLE", name),
getMaterialPrefixed("BLUE", name),
getMaterialPrefixed("BROWN", name),
getMaterialPrefixed("GREEN", name),
getMaterialPrefixed("RED", name),
getMaterialPrefixed("BLACK", name)
)
|