Skip to content

Commit

Permalink
Fix icon types not being properly replaced
Browse files Browse the repository at this point in the history
  • Loading branch information
virustotalop committed Sep 22, 2024
1 parent c000dc4 commit 25020d6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.clubobsidian.dynamicgui.api.inventory.ItemStackWrapper;
import com.clubobsidian.dynamicgui.api.manager.ModelManager;
import com.clubobsidian.dynamicgui.api.manager.inventory.ItemStackManager;
import com.clubobsidian.dynamicgui.api.manager.material.MaterialManager;
import com.clubobsidian.dynamicgui.api.manager.replacer.AnimationReplacerManager;
import com.clubobsidian.dynamicgui.api.manager.replacer.ReplacerManager;
import com.clubobsidian.dynamicgui.api.model.ModelProvider;
Expand Down Expand Up @@ -184,23 +185,26 @@ public FunctionTree getFunctions() {
public ItemStackWrapper<?> buildItemStack(@NotNull PlayerWrapper<?> playerWrapper) {
Objects.requireNonNull(playerWrapper);
ItemStackWrapper<?> builderItem = this.itemStack;
String updatedIcon = MaterialManager
.get()
.normalizeMaterial(ReplacerManager.get().replace(this.icon, playerWrapper));
if (builderItem == null) {
builderItem = ItemStackManager.get().createItemStackWrapper(this.icon, this.amount);
builderItem = ItemStackManager.get().createItemStackWrapper(updatedIcon, this.amount);
} else {
builderItem.setType(this.icon);
builderItem.setType(updatedIcon);
builderItem.setAmount(this.amount);
}
if (builderItem == null) {
DynamicGui.get().getLogger().error(
"Invalid material type '%s' for slot '%d' in gui '%s'",
this.icon,
updatedIcon,
this.index,
this.getOwner().getName()
);
return null;
}

if (!this.icon.equalsIgnoreCase(IGNORE_MATERIAL)) {
if (!updatedIcon.equalsIgnoreCase(IGNORE_MATERIAL)) {
if (this.data != 0) {
builderItem.setDurability(this.data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ private List<Slot> createSlots(GuiToken guiToken) {
int index = next.getKey();
SlotToken slotToken = next.getValue();

String icon = MaterialManager.get().normalizeMaterial(slotToken.getIcon());
String icon = slotToken.getIcon();
String name = slotToken.getName();

if (name != null) {
Expand Down

0 comments on commit 25020d6

Please sign in to comment.