Skip to content

Commit

Permalink
feat(forge): add back button
Browse files Browse the repository at this point in the history
  • Loading branch information
danorris709 committed Oct 2, 2021
1 parent 3456bae commit 93fb771
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public class BetterDexRewardsConfig extends AbstractYamlConfig {
ImmutableMap.of("tooltip", new ConfigItem.NBTValue("string", ""))
);

private PositionableConfigItem backButton = new PositionableConfigItem(
Item.getIdFromItem(PixelmonItems.LtradeHolderLeft) + "",
1, (byte) 0, "&eBack",
Lists.newArrayList(),
0, 5, Collections.emptyMap()
);

private int messageDelaySeconds = 60;

private Map<String, DexCompletion> rewardStages = Maps.newHashMap(ImmutableMap.of(
Expand All @@ -84,6 +91,10 @@ public class BetterDexRewardsConfig extends AbstractYamlConfig {
public BetterDexRewardsConfig() {
}

public PositionableConfigItem getBackButton() {
return this.backButton;
}

public PositionableConfigItem getInfoItem() {
return this.infoItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.envyful.api.config.type.ConfigInterface;
import com.envyful.api.config.type.ConfigItem;
import com.envyful.api.forge.chat.UtilChatColour;
import com.envyful.api.forge.concurrency.UtilForgeConcurrency;
import com.envyful.api.forge.config.UtilConfigItem;
import com.envyful.api.forge.items.ItemBuilder;
import com.envyful.api.gui.factory.GuiFactory;
import com.envyful.api.gui.pane.Pane;
Expand Down Expand Up @@ -53,6 +55,23 @@ public static void open(EnvyPlayer<EntityPlayerMP> player, int page) {
.build());
}

if (BetterDexRewards.getInstance().getConfig().getBackButton().isEnabled()) {
pane.set(
BetterDexRewards.getInstance().getConfig().getBackButton().getXPos(),
BetterDexRewards.getInstance().getConfig().getBackButton().getYPos(),
GuiFactory.displayableBuilder(ItemStack.class)
.itemStack(
UtilConfigItem.fromConfigItem(BetterDexRewards.getInstance().getConfig().getBackButton()))
.clickHandler((envyPlayer, clickType) -> {
((EntityPlayerMP) envyPlayer.getParent()).closeScreen();

UtilForgeConcurrency.runSync(() -> {
DexRewardsMainUI.open(player);
});
}).build()
);
}

DexRewardsAttribute attribute = player.getAttribute(BetterDexRewards.class);

attribute.setPage(page);
Expand Down

0 comments on commit 93fb771

Please sign in to comment.