Skip to content

Commit

Permalink
Add GuiButton that allows to switch MobHeads vs MobEggs...
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Jan 28, 2019
1 parent 21c5704 commit f1f9072
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import java.util.*;

import world.bentobox.bentobox.api.panels.PanelItem;
Expand Down Expand Up @@ -61,6 +60,7 @@ public void build()

panelBuilder.item(3, this.createButton(Button.ADD));
panelBuilder.item(5, this.createButton(Button.REMOVE));
panelBuilder.item(8, this.createButton(Button.SWITCH));

final int MAX_ELEMENTS = 21;

Expand Down Expand Up @@ -119,7 +119,7 @@ private PanelItem createButton(Button button)
builder.name(this.user.getTranslation("challenges.gui.button.add"));
builder.icon(Material.BUCKET);
builder.clickHandler((panel, user1, clickType, slot) -> {
new SelectEntityGUI(this.user, (status, entity) -> {
new SelectEntityGUI(this.user, Collections.emptySet(), this.asEggs, (status, entity) -> {
if (status)
{
if (!this.requiredEntities.containsKey(entity))
Expand All @@ -144,6 +144,15 @@ private PanelItem createButton(Button button)
return true;
});
break;
case SWITCH:
builder.name(this.user.getTranslation("challenges.gui.button.show-eggs"));
builder.icon(this.asEggs ? Material.EGG : Material.PLAYER_HEAD);
builder.clickHandler((panel, user1, clickType, slot) -> {
this.asEggs = !this.asEggs;
this.build();
return true;
});
break;
}

return builder.build();
Expand Down Expand Up @@ -204,7 +213,8 @@ private PanelItem createEntityButton(EntityType entity)
private enum Button
{
ADD,
REMOVE
REMOVE,
SWITCH
}


Expand Down
1 change: 1 addition & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ challenges:
button:
add: Add
remove-selected: Remove Selected
show-eggs: Toogle Mob View
buttons:
back: Return
next: Next
Expand Down

0 comments on commit f1f9072

Please sign in to comment.