DREAMFIRE Docs ← Back to site
Loading...
Searching...
No Matches
DreamfireArmorStandBuilder.java
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 Dreamfire Studio
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24package com.dreamfirestudios.dreamcore.DreamArmorStand;
25
26import com.dreamfirestudios.dreamcore.DreamChat.DreamMessageFormatter;
27import com.dreamfirestudios.dreamcore.DreamChat.DreamMessageSettings;
28import net.kyori.adventure.text.Component;
29import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
30import org.bukkit.Location;
31import org.bukkit.entity.ArmorStand;
32import org.bukkit.entity.EntityType;
33import org.bukkit.Bukkit;
34
45 private final Location location;
46 private boolean isVisible = true;
47 private boolean customNameVisible = false;
48 private String customName = "";
49 private boolean canPickupItems = false;
50 private boolean gravity = true;
51 private boolean arms = false;
52 private boolean basePlate = true;
53 private boolean small = false;
54 private boolean marker = false;
55 private boolean glowing = false;
56
62 public DreamfireArmorStandBuilder(Location location) {
63 if (location == null || location.getWorld() == null) {
64 throw new IllegalArgumentException("Location or World cannot be null");
65 }
66 this.location = location;
67 }
68
72 public DreamfireArmorStandBuilder visible(boolean isVisible) {
73 this.isVisible = isVisible;
74 return this;
75 }
76
80 public DreamfireArmorStandBuilder customNameVisible(boolean customNameVisible) {
81 this.customNameVisible = customNameVisible;
82 return this;
83 }
84
88 public DreamfireArmorStandBuilder customName(String customName) {
89 this.customName = PlainTextComponentSerializer.plainText().serialize(
90 DreamMessageFormatter.format(customName, DreamMessageSettings.all())
91 );
92 return this;
93 }
94
98 public DreamfireArmorStandBuilder canPickupItems(boolean canPickupItems) {
99 this.canPickupItems = canPickupItems;
100 return this;
101 }
102
106 public DreamfireArmorStandBuilder gravity(boolean gravity) {
107 this.gravity = gravity;
108 return this;
109 }
110
114 public DreamfireArmorStandBuilder arms(boolean arms) {
115 this.arms = arms;
116 return this;
117 }
118
122 public DreamfireArmorStandBuilder basePlate(boolean basePlate) {
123 this.basePlate = basePlate;
124 return this;
125 }
126
130 public DreamfireArmorStandBuilder small(boolean small) {
131 this.small = small;
132 return this;
133 }
134
138 public DreamfireArmorStandBuilder marker(boolean marker) {
139 this.marker = marker;
140 return this;
141 }
142
146 public DreamfireArmorStandBuilder glowing(boolean glowing) {
147 this.glowing = glowing;
148 return this;
149 }
150
158 public ArmorStand build() {
159 ArmorStand armorStand = (ArmorStand) location.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);
160 armorStand.setVisible(isVisible);
161 armorStand.setCustomNameVisible(customNameVisible);
162 armorStand.customName(Component.text(customName));
163 armorStand.setCanPickupItems(canPickupItems);
164 armorStand.setGravity(gravity);
165 armorStand.setArms(arms);
166 armorStand.setBasePlate(basePlate);
167 armorStand.setSmall(small);
168 armorStand.setMarker(marker);
169 armorStand.setGlowing(glowing);
170
172 armorStand, location, isVisible, customNameVisible, customName, canPickupItems, gravity
173 );
174 Bukkit.getPluginManager().callEvent(event);
175
176 return armorStand;
177 }
178}
A builder class for creating and configuring ArmorStand instances.
DreamfireArmorStandBuilder customNameVisible(boolean customNameVisible)
Sets whether the armor stand's custom name is visible.
DreamfireArmorStandBuilder canPickupItems(boolean canPickupItems)
Sets whether the armor stand can pick up items.
DreamfireArmorStandBuilder glowing(boolean glowing)
Sets whether the armor stand is glowing.
DreamfireArmorStandBuilder gravity(boolean gravity)
Sets whether gravity is applied to the armor stand.
DreamfireArmorStandBuilder arms(boolean arms)
Sets whether the armor stand has arms.
DreamfireArmorStandBuilder small(boolean small)
Sets whether the armor stand is small.
DreamfireArmorStandBuilder basePlate(boolean basePlate)
Sets whether the armor stand has a base plate.
DreamfireArmorStandBuilder visible(boolean isVisible)
Sets the visibility of the armor stand.
DreamfireArmorStandBuilder(Location location)
Creates a new DreamfireArmorStandBuilder at the given location.
DreamfireArmorStandBuilder marker(boolean marker)
Sets whether the armor stand is a marker (no hitbox).
DreamfireArmorStandBuilder customName(String customName)
Sets the custom name of the armor stand, applying DreamMessage formatting.
ArmorStand build()
Builds and spawns the configured ArmorStand at the location.