|
19 | 19 | package net.thenextlvl.gopaint.brush.setting; |
20 | 20 |
|
21 | 21 | import core.paper.gui.AbstractGUI; |
| 22 | +import io.papermc.paper.datacomponent.DataComponentTypes; |
| 23 | +import io.papermc.paper.datacomponent.item.ItemLore; |
22 | 24 | import lombok.Getter; |
23 | 25 | import net.kyori.adventure.key.Key; |
24 | 26 | import net.kyori.adventure.text.Component; |
|
29 | 31 | import net.thenextlvl.gopaint.api.brush.setting.ItemBrushSettings; |
30 | 32 | import net.thenextlvl.gopaint.api.brush.setting.PlayerBrushSettings; |
31 | 33 | import net.thenextlvl.gopaint.api.model.SurfaceMode; |
32 | | -import net.thenextlvl.gopaint.brush.standard.*; |
| 34 | +import net.thenextlvl.gopaint.brush.standard.AngleBrush; |
| 35 | +import net.thenextlvl.gopaint.brush.standard.DiskBrush; |
| 36 | +import net.thenextlvl.gopaint.brush.standard.FractureBrush; |
| 37 | +import net.thenextlvl.gopaint.brush.standard.GradientBrush; |
| 38 | +import net.thenextlvl.gopaint.brush.standard.OverlayBrush; |
| 39 | +import net.thenextlvl.gopaint.brush.standard.PaintBrush; |
| 40 | +import net.thenextlvl.gopaint.brush.standard.SplatterBrush; |
| 41 | +import net.thenextlvl.gopaint.brush.standard.SprayBrush; |
| 42 | +import net.thenextlvl.gopaint.brush.standard.UnderlayBrush; |
33 | 43 | import net.thenextlvl.gopaint.menu.BrushesMenu; |
34 | 44 | import net.thenextlvl.gopaint.menu.MainMenu; |
35 | 45 | import org.bukkit.Axis; |
@@ -238,62 +248,63 @@ public PatternBrush getPreviousBrush(@Nullable PatternBrush brush) { |
238 | 248 | @Override |
239 | 249 | public boolean exportSettings(ItemStack itemStack) { |
240 | 250 | if (itemStack.getType().equals(plugin.config().brushConfig().defaultBrushType())) return false; |
241 | | - return !itemStack.getType().isBlock() && itemStack.editMeta(itemMeta -> { |
242 | | - var lore = new ArrayList<Component>(); |
243 | | - lore.add(Component.empty()); |
244 | | - lore.add(plugin.bundle().component(player, "brush.exported.size", |
245 | | - Placeholder.parsed("size", String.valueOf(getBrushSize())))); |
246 | | - if (getBrush() instanceof SprayBrush) { |
247 | | - lore.add(plugin.bundle().component(player, "brush.exported.chance", |
248 | | - Placeholder.parsed("chance", String.valueOf(getChance())))); |
249 | | - } else if (getBrush() instanceof OverlayBrush || getBrush() instanceof UnderlayBrush) { |
250 | | - lore.add(plugin.bundle().component(player, "brush.exported.thickness", |
251 | | - Placeholder.parsed("thickness", String.valueOf(getThickness())))); |
252 | | - } else if (getBrush() instanceof DiskBrush) { |
253 | | - lore.add(plugin.bundle().component(player, "brush.exported.axis", |
254 | | - Placeholder.parsed("axis", getAxis().name()))); |
255 | | - } else if (getBrush() instanceof AngleBrush) { |
256 | | - lore.add(plugin.bundle().component(player, "brush.exported.angle.distance", |
257 | | - Placeholder.parsed("distance", String.valueOf(getAngleDistance())))); |
258 | | - lore.add(plugin.bundle().component(player, "brush.exported.angle.height", |
259 | | - Placeholder.parsed("height", String.valueOf(getAngleHeightDifference())))); |
260 | | - } else if (getBrush() instanceof SplatterBrush || getBrush() instanceof PaintBrush) { |
261 | | - lore.add(plugin.bundle().component(player, "brush.exported.falloff", |
262 | | - Placeholder.parsed("falloff", String.valueOf(getFalloffStrength())))); |
263 | | - } else if (getBrush() instanceof GradientBrush) { |
264 | | - lore.add(plugin.bundle().component(player, "brush.exported.mixing", |
265 | | - Placeholder.parsed("mixing", String.valueOf(getMixingStrength())))); |
266 | | - lore.add(plugin.bundle().component(player, "brush.exported.falloff", |
267 | | - Placeholder.parsed("falloff", String.valueOf(getFalloffStrength())))); |
268 | | - } else if (getBrush() instanceof FractureBrush) { |
269 | | - lore.add(plugin.bundle().component(player, "brush.exported.fracture", |
270 | | - Placeholder.parsed("fracture", String.valueOf(getFractureStrength())))); |
271 | | - } |
272 | | - if (!blocks.isEmpty()) { |
273 | | - var blocks = getBlocks().stream() |
274 | | - .map(Material::translationKey) |
275 | | - .map(Component::translatable) |
276 | | - .toList(); |
277 | | - lore.add(plugin.bundle().component(player, "brush.exported.blocks", |
278 | | - Placeholder.component("blocks", Component.join(JoinConfiguration.commas(true), blocks)))); |
279 | | - } |
280 | | - |
281 | | - if (isMaskEnabled()) { |
282 | | - lore.add(plugin.bundle().component(player, "brush.exported.mask", |
283 | | - Placeholder.component("mask", Component.translatable(getMask().translationKey())))); |
284 | | - } |
285 | | - |
286 | | - if (!getSurfaceMode().equals(SurfaceMode.DISABLED)) { |
287 | | - var mode = plugin.bundle().component(player, getSurfaceMode().translationKey()); |
288 | | - lore.add(plugin.bundle().component(player, "brush.exported.surface-mode", |
289 | | - Placeholder.component("mode", mode))); |
290 | | - } |
291 | | - |
292 | | - itemMeta.itemName(plugin.bundle().component(player, "brush.exported.name", |
293 | | - Placeholder.component("brush", getBrush().getName(player)))); |
294 | | - itemMeta.lore(lore); |
295 | | - itemMeta.setEnchantmentGlintOverride(true); |
296 | 251 |
|
| 252 | + var lines = new ArrayList<Component>(); |
| 253 | + lines.add(Component.empty()); |
| 254 | + lines.add(plugin.bundle().component(player, "brush.exported.size", |
| 255 | + Placeholder.parsed("size", String.valueOf(getBrushSize())))); |
| 256 | + if (getBrush() instanceof SprayBrush) { |
| 257 | + lines.add(plugin.bundle().component(player, "brush.exported.chance", |
| 258 | + Placeholder.parsed("chance", String.valueOf(getChance())))); |
| 259 | + } else if (getBrush() instanceof OverlayBrush || getBrush() instanceof UnderlayBrush) { |
| 260 | + lines.add(plugin.bundle().component(player, "brush.exported.thickness", |
| 261 | + Placeholder.parsed("thickness", String.valueOf(getThickness())))); |
| 262 | + } else if (getBrush() instanceof DiskBrush) { |
| 263 | + lines.add(plugin.bundle().component(player, "brush.exported.axis", |
| 264 | + Placeholder.parsed("axis", getAxis().name()))); |
| 265 | + } else if (getBrush() instanceof AngleBrush) { |
| 266 | + lines.add(plugin.bundle().component(player, "brush.exported.angle.distance", |
| 267 | + Placeholder.parsed("distance", String.valueOf(getAngleDistance())))); |
| 268 | + lines.add(plugin.bundle().component(player, "brush.exported.angle.height", |
| 269 | + Placeholder.parsed("height", String.valueOf(getAngleHeightDifference())))); |
| 270 | + } else if (getBrush() instanceof SplatterBrush || getBrush() instanceof PaintBrush) { |
| 271 | + lines.add(plugin.bundle().component(player, "brush.exported.falloff", |
| 272 | + Placeholder.parsed("falloff", String.valueOf(getFalloffStrength())))); |
| 273 | + } else if (getBrush() instanceof GradientBrush) { |
| 274 | + lines.add(plugin.bundle().component(player, "brush.exported.mixing", |
| 275 | + Placeholder.parsed("mixing", String.valueOf(getMixingStrength())))); |
| 276 | + lines.add(plugin.bundle().component(player, "brush.exported.falloff", |
| 277 | + Placeholder.parsed("falloff", String.valueOf(getFalloffStrength())))); |
| 278 | + } else if (getBrush() instanceof FractureBrush) { |
| 279 | + lines.add(plugin.bundle().component(player, "brush.exported.fracture", |
| 280 | + Placeholder.parsed("fracture", String.valueOf(getFractureStrength())))); |
| 281 | + } |
| 282 | + if (!blocks.isEmpty()) { |
| 283 | + var blocks = getBlocks().stream() |
| 284 | + .map(Material::translationKey) |
| 285 | + .map(Component::translatable) |
| 286 | + .toList(); |
| 287 | + lines.add(plugin.bundle().component(player, "brush.exported.blocks", |
| 288 | + Placeholder.component("blocks", Component.join(JoinConfiguration.commas(true), blocks)))); |
| 289 | + } |
| 290 | + |
| 291 | + if (isMaskEnabled()) { |
| 292 | + lines.add(plugin.bundle().component(player, "brush.exported.mask", |
| 293 | + Placeholder.component("mask", Component.translatable(getMask().translationKey())))); |
| 294 | + } |
| 295 | + |
| 296 | + if (!getSurfaceMode().equals(SurfaceMode.DISABLED)) { |
| 297 | + var mode = plugin.bundle().component(player, getSurfaceMode().translationKey()); |
| 298 | + lines.add(plugin.bundle().component(player, "brush.exported.surface-mode", |
| 299 | + Placeholder.component("mode", mode))); |
| 300 | + } |
| 301 | + |
| 302 | + itemStack.setData(DataComponentTypes.ENCHANTMENT_GLINT_OVERRIDE, true); |
| 303 | + itemStack.setData(DataComponentTypes.ITEM_NAME, plugin.bundle().component(player, "brush.exported.name", |
| 304 | + Placeholder.component("brush", getBrush().getName(player)))); |
| 305 | + itemStack.setData(DataComponentTypes.LORE, ItemLore.lore(lines)); |
| 306 | + |
| 307 | + return !itemStack.getType().isBlock() && itemStack.editMeta(itemMeta -> { |
297 | 308 | var container = itemMeta.getPersistentDataContainer(); |
298 | 309 |
|
299 | 310 | container.set(new NamespacedKey("gopaint", "size"), PersistentDataType.INTEGER, getBrushSize()); |
|
0 commit comments