Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `billboard` -> `EntityPivot` * `brightness_*` -> `EntityBrightness` * `EntityPivot` - minor fixes * `glow_color` -> `EntityGlowColor` * `width`/`height` -> `EntityCullingWidth/Height` * `interpolation_delay` > `EntityInterpolationDelay` * `EntityInterpolationDuration` * `shadow_radius` -> `EntityShadowRadius` * `shadow_strength` -> `EntityShadowStrength` * `transformation_scale` -> `EntityScale` * `transformation_translation` > `EntityTranslation` * Better `DisplayEntityData` transformation handling * `view_range` -> `EntityViewRange` * `item_transform` -> `EntityDisplay` * `text_alignment` -> `EntityDisplay` * `text_line_width` -> `EntityLineWidth` * `text` -> `EntityText` * `text_opacity` -> `EntityOpacity` * `EntityDefaultBackground` * `text_is_see_through` -> `EntitySeeThrough` * `text_is_shadowed` -> `EntityTextShadowed` * Cleanup `EntityDisplayEntityData` * Fix `EntityGlowColor` typo * `interpolation_delay` -> `interpolation_start` * `interpolation_duration` meta fix * Properly handle signed->unsigned in `EntityOpacity` * Improve `EntityViewRange` meta * `EntityCullingWidth/Height` > `EntityWidth/Height` * Document what values can be interpolated * Minor `PropertyRegistry` ordering fix * Minor meta fix * `DisplayEntityData` - comment out background color * Meta fixes * `PaperAPITools#getText` (Spigot): `null` -> `""` * Minor meta fixes & code cleanup * `synonyms` and typo fix * Add interpolation language doc * Reference interpolation lang in mechs * Document `opacity` edge-case * Copypasta fix * `EntityLeft/RightRotation` * `left/right_rotation` -> `primary/secondary` * Revert "`left/right_rotation` -> `primary/secondary`" This reverts commit bcaafa5. * Document `left/right_rotation`
- Loading branch information
Showing
25 changed files
with
1,132 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...n/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityBrightness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.core.MapTag; | ||
import org.bukkit.entity.Display; | ||
|
||
public class EntityBrightness extends EntityProperty<MapTag> { | ||
|
||
// <--[property] | ||
// @object EntityTag | ||
// @name brightness | ||
// @input MapTag | ||
// @description | ||
// A map of the display entity's brightness override (if any), containing "block" and "sky" keys, each with a brightness level between 0 and 15. | ||
// For the mechanism: provide no input to remove the brightness override. | ||
// --> | ||
|
||
public static boolean describes(EntityTag entity) { | ||
return entity.getBukkitEntity() instanceof Display; | ||
} | ||
|
||
@Override | ||
public MapTag getPropertyValue() { | ||
Display.Brightness brightness = as(Display.class).getBrightness(); | ||
if (brightness == null) { | ||
return null; | ||
} | ||
MapTag brightnessMap = new MapTag(); | ||
brightnessMap.putObject("block", new ElementTag(brightness.getBlockLight())); | ||
brightnessMap.putObject("sky", new ElementTag(brightness.getSkyLight())); | ||
return brightnessMap; | ||
} | ||
|
||
@Override | ||
public void setPropertyValue(MapTag value, Mechanism mechanism) { | ||
if (value == null) { | ||
as(Display.class).setBrightness(null); | ||
return; | ||
} | ||
Display.Brightness brightness = as(Display.class).getBrightness(); | ||
ElementTag blockLightInput = value.getElement("block"); | ||
int blockLight = blockLightInput != null ? | ||
blockLightInput.isInt() ? blockLightInput.asInt() : -1 | ||
: brightness != null ? brightness.getBlockLight() : 0; | ||
if (blockLight < 0 || blockLight > 15) { | ||
mechanism.echoError("Invalid 'block' brightness, must be a number between 0 and 15."); | ||
return; | ||
} | ||
ElementTag skyLightInput = value.getElement("sky"); | ||
int skyLight = skyLightInput != null ? | ||
skyLightInput.isInt() ? skyLightInput.asInt() : -1 | ||
: brightness != null ? brightness.getSkyLight() : 0; | ||
if (skyLight < 0 || skyLight > 15) { | ||
mechanism.echoError("Invalid 'sky' brightness, must be a number between 0 and 15."); | ||
return; | ||
} | ||
as(Display.class).setBrightness(new Display.Brightness(blockLight, skyLight)); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "brightness"; | ||
} | ||
|
||
public static void register() { | ||
autoRegisterNullable("brightness", EntityBrightness.class, MapTag.class, false); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...ain/java/com/denizenscript/denizen/objects/properties/entity/EntityDefaultBackground.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import org.bukkit.entity.TextDisplay; | ||
|
||
public class EntityDefaultBackground extends EntityProperty<ElementTag> { | ||
|
||
// TODO: reference the background color property here, once that's created. | ||
// <--[property] | ||
// @object EntityTag | ||
// @name default_background | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// Whether a text display entity's background is default (same as the chat window), or custom set. | ||
// --> | ||
|
||
public static boolean describes(EntityTag entity) { | ||
return entity.getBukkitEntity() instanceof TextDisplay; | ||
} | ||
|
||
@Override | ||
public ElementTag getPropertyValue() { | ||
return new ElementTag(as(TextDisplay.class).isDefaultBackground()); | ||
} | ||
|
||
@Override | ||
public boolean isDefaultValue(ElementTag value) { | ||
return !value.asBoolean(); | ||
} | ||
|
||
@Override | ||
public void setPropertyValue(ElementTag value, Mechanism mechanism) { | ||
if (mechanism.requireBoolean()) { | ||
as(TextDisplay.class).setDefaultBackground(value.asBoolean()); | ||
} | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "default_background"; | ||
} | ||
|
||
public static void register() { | ||
autoRegister("default_background", EntityDefaultBackground.class, ElementTag.class, false); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
plugin/src/main/java/com/denizenscript/denizen/objects/properties/entity/EntityDisplay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.denizenscript.denizen.objects.properties.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import org.bukkit.entity.ItemDisplay; | ||
import org.bukkit.entity.TextDisplay; | ||
|
||
public class EntityDisplay extends EntityProperty<ElementTag> { | ||
|
||
// <--[property] | ||
// @object EntityTag | ||
// @name display | ||
// @input ElementTag | ||
// @synonyms EntityTag.display_transform, EntityTag.text_alignment | ||
// @description | ||
// For an item display entity this is the model transform it will display, can be any of <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/ItemDisplay.ItemDisplayTransform.html>. | ||
// For a text display entity this is its text alignment, can be any of <@link url https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/TextDisplay.html>. | ||
// --> | ||
|
||
public static boolean describes(EntityTag entity) { | ||
return entity.getBukkitEntity() instanceof ItemDisplay || entity.getBukkitEntity() instanceof TextDisplay; | ||
} | ||
|
||
@Override | ||
public ElementTag getPropertyValue() { | ||
if (getEntity() instanceof ItemDisplay itemDisplay) { | ||
return new ElementTag(itemDisplay.getItemDisplayTransform()); | ||
} | ||
return new ElementTag(as(TextDisplay.class).getAlignment()); | ||
} | ||
|
||
@Override | ||
public boolean isDefaultValue(ElementTag value) { | ||
if (getEntity() instanceof ItemDisplay) { | ||
return value.asEnum(ItemDisplay.ItemDisplayTransform.class) == ItemDisplay.ItemDisplayTransform.NONE; | ||
} | ||
return value.asEnum(TextDisplay.TextAlignment.class) == TextDisplay.TextAlignment.CENTER; | ||
} | ||
|
||
@Override | ||
public void setPropertyValue(ElementTag value, Mechanism mechanism) { | ||
if (getEntity() instanceof ItemDisplay itemDisplay) { | ||
if (mechanism.requireEnum(ItemDisplay.ItemDisplayTransform.class)) { | ||
itemDisplay.setItemDisplayTransform(value.asEnum(ItemDisplay.ItemDisplayTransform.class)); | ||
} | ||
} | ||
else if (mechanism.requireEnum(TextDisplay.TextAlignment.class)) { | ||
as(TextDisplay.class).setAlignment(value.asEnum(TextDisplay.TextAlignment.class)); | ||
} | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "display"; | ||
} | ||
|
||
public static void register() { | ||
autoRegister("display", EntityDisplay.class, ElementTag.class, false); | ||
} | ||
} |
Oops, something went wrong.