mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-29 11:49:08 +00:00
Fix custom model data and add edit option for undiscovered icon
This commit is contained in:
@@ -12,6 +12,7 @@ import net.islandearth.rpgregions.regenerate.Regenerate;
|
||||
import net.islandearth.rpgregions.requirements.RegionRequirement;
|
||||
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
||||
import net.islandearth.rpgregions.translation.Translations;
|
||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -46,6 +47,7 @@ public class ConfiguredRegion {
|
||||
@NeedsGUI private Sound sound;
|
||||
@NeedsGUI private String icon;
|
||||
private int iconModel;
|
||||
private int undiscoveredIconModel;
|
||||
@NeedsGUI private String undiscoveredIcon;
|
||||
private final List<IconCommand> iconCommand;
|
||||
@EditableField(description = "Toggle whether the coordinates of the region are shown", name = "Toggle coordinates")
|
||||
@@ -142,8 +144,8 @@ public class ConfiguredRegion {
|
||||
@Nullable
|
||||
public ItemStack getIcon() {
|
||||
if (icon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||
if (icon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStack(new HeadDatabaseAPI().getItemHead(icon.replace("hdb-", "")));
|
||||
return new ItemStack(Material.valueOf(icon));
|
||||
if (icon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(icon.replace("hdb-", ""))).withModel(iconModel).build();
|
||||
return new ItemStackBuilder(Material.valueOf(icon)).withModel(iconModel).build();
|
||||
}
|
||||
|
||||
public void setIcon(@NotNull Material material) {
|
||||
@@ -161,14 +163,22 @@ public class ConfiguredRegion {
|
||||
@Nullable
|
||||
public ItemStack getUndiscoveredIcon() {
|
||||
if (undiscoveredIcon == null) return new ItemStack(Material.TOTEM_OF_UNDYING);
|
||||
if (undiscoveredIcon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStack(new HeadDatabaseAPI().getItemHead(undiscoveredIcon.replace("hdb-", "")));
|
||||
return new ItemStack(Material.valueOf(undiscoveredIcon));
|
||||
if (undiscoveredIcon.startsWith("hdb-") && RPGRegionsAPI.getAPI().hasHeadDatabase()) return new ItemStackBuilder(new HeadDatabaseAPI().getItemHead(undiscoveredIcon.replace("hdb-", ""))).withModel(undiscoveredIconModel).build();
|
||||
return new ItemStackBuilder(Material.valueOf(undiscoveredIcon)).withModel(undiscoveredIconModel).build();
|
||||
}
|
||||
|
||||
public void setUndiscoveredIcon(@NotNull Material material) {
|
||||
this.undiscoveredIcon = material.name();
|
||||
}
|
||||
|
||||
public int getUndiscoveredIconModel() {
|
||||
return undiscoveredIconModel;
|
||||
}
|
||||
|
||||
public void setUndiscoveredIconModel(int undiscoveredIconModel) {
|
||||
this.undiscoveredIconModel = undiscoveredIconModel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<IconCommand> getIconCommand() {
|
||||
return iconCommand == null ? new ArrayList<>() : iconCommand;
|
||||
|
||||
@@ -136,7 +136,7 @@ public class ItemStackBuilder {
|
||||
|
||||
public ItemStackBuilder withModel(int model) {
|
||||
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||
//meta.setCustomModelData(model);
|
||||
meta.setCustomModelData(model);
|
||||
ITEM_STACK.setItemMeta(meta);
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user