Commits

Parker Hawke authored and md_5 committed eb4b416d2b2
#822: Add experimental armor trim API
No tags

src/main/java/org/bukkit/inventory/meta/trim/ArmorTrim.java

Added
1 +package org.bukkit.inventory.meta.trim;
2 +
3 +import com.google.common.base.Preconditions;
4 +import java.util.Objects;
5 +import org.bukkit.MinecraftExperimental;
6 +import org.bukkit.inventory.meta.ArmorMeta;
7 +import org.jetbrains.annotations.ApiStatus;
8 +import org.jetbrains.annotations.NotNull;
9 +
10 +/**
11 + * Represents an armor trim that may be applied to an item.
12 + *
13 + * @see ArmorMeta#setTrim(ArmorTrim)
14 + * @apiNote Armor trims are part of an experimental feature of Minecraft and
15 + * hence subject to change.
16 + */
17 +@MinecraftExperimental
18 +@ApiStatus.Experimental
19 +public class ArmorTrim {
20 +
21 + private final TrimMaterial material;
22 + private final TrimPattern pattern;
23 +
24 + /**
25 + * Create a new {@link ArmorTrim} given a {@link TrimMaterial} and
26 + * {@link TrimPattern}.
27 + *
28 + * @param material the material
29 + * @param pattern the pattern
30 + */
31 + public ArmorTrim(@NotNull TrimMaterial material, @NotNull TrimPattern pattern) {
32 + Preconditions.checkArgument(material != null, "material must not be null");
33 + Preconditions.checkArgument(pattern != null, "pattern must not be null");
34 +
35 + this.material = material;
36 + this.pattern = pattern;
37 + }
38 +
39 + /**
40 + * Get the {@link TrimMaterial} for this armor trim.
41 + *
42 + * @return the material
43 + */
44 + @NotNull
45 + public TrimMaterial getMaterial() {
46 + return material;
47 + }
48 +
49 + /**
50 + * Get the {@link TrimPattern} for this armor trim.
51 + *
52 + * @return the pattern
53 + */
54 + @NotNull
55 + public TrimPattern getPattern() {
56 + return pattern;
57 + }
58 +
59 + @Override
60 + public int hashCode() {
61 + int hash = 7;
62 + hash = 31 * hash + Objects.hashCode(material);
63 + hash = 31 * hash + Objects.hashCode(pattern);
64 + return hash;
65 + }
66 +
67 + @Override
68 + public boolean equals(Object obj) {
69 + if (obj == this) {
70 + return true;
71 + }
72 +
73 + if (!(obj instanceof ArmorTrim)) {
74 + return false;
75 + }
76 +
77 + ArmorTrim other = (ArmorTrim) obj;
78 + return material == other.material && pattern == other.pattern;
79 + }
80 +}

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut