forked from SkriptLang/Skript
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExprBeaconTier.java
More file actions
45 lines (38 loc) · 1.01 KB
/
ExprBeaconTier.java
File metadata and controls
45 lines (38 loc) · 1.01 KB
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
package ch.njol.skript.expressions;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Example;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.expressions.base.SimplePropertyExpression;
import org.bukkit.block.Beacon;
import org.bukkit.block.Block;
import org.jetbrains.annotations.Nullable;
@Name("Beacon Tier")
@Description({
"The tier of a beacon. Ranges from 0 to 4."
})
@Example("""
if the beacon tier of the clicked block is 4:
send "This is a max tier beacon!"
"""
)
@Since("2.10")
public class ExprBeaconTier extends SimplePropertyExpression<Block, Integer> {
static {
register(ExprBeaconTier.class, Integer.class, "beacon tier", "blocks");
}
@Override
public @Nullable Integer convert(Block block) {
if (block.getState() instanceof Beacon beacon)
return beacon.getTier();
return null;
}
@Override
public Class<Integer> getReturnType() {
return Integer.class;
}
@Override
protected String getPropertyName() {
return "beacon tier";
}
}