mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Add validation for armor type
This commit is contained in:
parent
c890f064ae
commit
db92184d42
1 changed files with 6 additions and 0 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.geyser.item;
|
package org.geysermc.geyser.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.checkerframework.checker.index.qual.NonNegative;
|
import org.checkerframework.checker.index.qual.NonNegative;
|
||||||
|
@ -43,6 +44,8 @@ import java.util.Set;
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
@ToString
|
@ToString
|
||||||
public class GeyserCustomItemData implements CustomItemData {
|
public class GeyserCustomItemData implements CustomItemData {
|
||||||
|
private static final List<String> VALID_ARMOR_TYPES = List.of("boots", "leggings", "chestplate", "helmet");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final CustomItemOptions customItemOptions;
|
private final CustomItemOptions customItemOptions;
|
||||||
private final String displayName;
|
private final String displayName;
|
||||||
|
@ -318,6 +321,9 @@ public class GeyserCustomItemData implements CustomItemData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Builder armorType(@Nullable String armorType) {
|
public Builder armorType(@Nullable String armorType) {
|
||||||
|
if (!VALID_ARMOR_TYPES.contains(armorType)) {
|
||||||
|
throw new IllegalArgumentException("Invalid armor type " + armorType + "! Can be \"boots\", \"leggings\", \"chestplate\", or \"helmet\"");
|
||||||
|
}
|
||||||
this.armorType = armorType;
|
this.armorType = armorType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue