-
-
Notifications
You must be signed in to change notification settings - Fork 103
/
EntityText.java
46 lines (37 loc) · 1.35 KB
/
EntityText.java
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
package com.denizenscript.denizen.objects.properties.entity;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.PaperAPITools;
import com.denizenscript.denizencore.objects.Mechanism;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.TextDisplay;
public class EntityText extends EntityProperty<ElementTag> {
// <--[property]
// @object EntityTag
// @name text
// @input ElementTag
// @description
// A text display entity's text, supports new lines.
// -->
public static boolean describes(EntityTag entity) {
return entity.getBukkitEntity() instanceof TextDisplay;
}
@Override
public ElementTag getPropertyValue() {
return new ElementTag(PaperAPITools.instance.getText(as(TextDisplay.class)));
}
@Override
public boolean isDefaultValue(ElementTag value) {
return value.asString().isEmpty();
}
@Override
public void setPropertyValue(ElementTag value, Mechanism mechanism) {
PaperAPITools.instance.setText(as(TextDisplay.class), value.asString());
}
@Override
public String getPropertyId() {
return "text";
}
public static void register() {
autoRegister("text", EntityText.class, ElementTag.class, false);
}
}