-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Over2Craft-mc
committed
Aug 18, 2021
1 parent
ec47860
commit dc5b941
Showing
8 changed files
with
170 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/fr/quentin/searchquickshop/Menu/AbstractPreviousInventory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package fr.quentin.searchquickshop.Menu; | ||
|
||
import fr.minuskube.inv.ClickableItem; | ||
import fr.minuskube.inv.content.InventoryProvider; | ||
import fr.quentin.searchquickshop.Menu.utils.ItemStackUtils; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
|
||
public abstract class AbstractPreviousInventory implements InventoryProvider, InventoryBuilderProviderInterface { | ||
|
||
private final InventoryProvider previousInventory; | ||
|
||
public AbstractPreviousInventory(InventoryProvider previousInventory) { | ||
this.previousInventory = previousInventory; | ||
} | ||
|
||
public InventoryProvider getPreviousInventory() { | ||
return previousInventory; | ||
} | ||
|
||
public boolean hasPreviousInventory() { | ||
return previousInventory != null; | ||
} | ||
|
||
public ClickableItem getItemPreviousInventory() { | ||
|
||
if (!hasPreviousInventory()) { | ||
throw new NullPointerException("Can't an item to go back to previous Inventory if there is no previous inventory."); | ||
} | ||
|
||
return ItemStackUtils.clickableItemWithItem( | ||
e -> ((InventoryBuilderProviderInterface) getPreviousInventory()).getBuilder(previousInventory).open((Player) e.getWhoClicked()), | ||
Material.ARROW, | ||
"Retour" | ||
); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/main/java/fr/quentin/searchquickshop/Menu/CategoriesInventory.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
src/main/java/fr/quentin/searchquickshop/Menu/Inventories/CategoriesInventoryAbstract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package fr.quentin.searchquickshop.Menu.Inventories; | ||
|
||
import fr.minuskube.inv.SmartInventory; | ||
import fr.minuskube.inv.content.InventoryContents; | ||
import fr.minuskube.inv.content.InventoryProvider; | ||
import fr.quentin.searchquickshop.Configuration.Config; | ||
import fr.quentin.searchquickshop.Menu.AbstractPreviousInventory; | ||
import fr.quentin.searchquickshop.Menu.InventoriesBuilder; | ||
import fr.quentin.searchquickshop.Menu.InventoryBuilderProviderInterface; | ||
import fr.quentin.searchquickshop.Menu.utils.ItemStackUtils; | ||
import fr.quentin.searchquickshop.Shop.ShopFilters; | ||
import org.bukkit.entity.Player; | ||
|
||
|
||
public class CategoriesInventoryAbstract extends AbstractPreviousInventory implements InventoryProvider, InventoryBuilderProviderInterface { | ||
|
||
private final Config config; | ||
|
||
public CategoriesInventoryAbstract(Config config) { | ||
super(null); | ||
this.config = config; | ||
} | ||
|
||
public CategoriesInventoryAbstract(Config config, InventoryProvider previousInventory) { | ||
super(previousInventory); | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public void init(Player player, InventoryContents contents) { | ||
|
||
config.getCategories().forEach(category -> contents.set( | ||
category.getPositionRow(), category.getPositionColumn(), | ||
ItemStackUtils.clickableItemWithItem( | ||
e -> InventoriesBuilder.getItemInventory(ShopFilters.allItems().filterCategory(category.getName()), this).open(player), | ||
category.getIcon(), | ||
category.getName(), | ||
category.getLore() | ||
))); | ||
|
||
if (this.hasPreviousInventory()) { | ||
contents.set(5, 0, this.getItemPreviousInventory()); | ||
} | ||
} | ||
|
||
@Override | ||
public void update(Player player, InventoryContents contents) { | ||
|
||
} | ||
|
||
@Override | ||
public SmartInventory getBuilder(InventoryProvider inventoryProvider) { | ||
return SmartInventory.builder() | ||
.provider(inventoryProvider) | ||
.size(6, 9) | ||
.title("Shops") | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/fr/quentin/searchquickshop/Menu/InventoriesBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package fr.quentin.searchquickshop.Menu; | ||
|
||
import fr.minuskube.inv.SmartInventory; | ||
import fr.minuskube.inv.content.InventoryProvider; | ||
import fr.quentin.searchquickshop.Configuration.Config; | ||
import fr.quentin.searchquickshop.Menu.Inventories.CategoriesInventoryAbstract; | ||
import fr.quentin.searchquickshop.Menu.Inventories.ShopsInventoryAbstract; | ||
import fr.quentin.searchquickshop.Shop.ShopFilters; | ||
|
||
public class InventoriesBuilder { | ||
|
||
public static SmartInventory getItemInventory(ShopFilters shopFilters, InventoryProvider previousInventory) { | ||
InventoryBuilderProviderInterface inventoryProvider = new ShopsInventoryAbstract(shopFilters, previousInventory); | ||
return inventoryProvider.getBuilder((InventoryProvider) inventoryProvider); | ||
} | ||
|
||
public static SmartInventory getItemInventory(ShopFilters shopFilters) { | ||
return getItemInventory(shopFilters, null); | ||
} | ||
|
||
public static SmartInventory getCategoryInventory(Config config, InventoryProvider previousInventory) { | ||
InventoryBuilderProviderInterface inventoryProvider = new CategoriesInventoryAbstract(config, previousInventory); | ||
return inventoryProvider.getBuilder((InventoryProvider) inventoryProvider); | ||
} | ||
|
||
public static SmartInventory getCategoryInventory(Config config) { | ||
return getCategoryInventory(config, null); | ||
} | ||
|
||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/fr/quentin/searchquickshop/Menu/InventoryBuilderProviderInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package fr.quentin.searchquickshop.Menu; | ||
|
||
import fr.minuskube.inv.SmartInventory; | ||
import fr.minuskube.inv.content.InventoryProvider; | ||
|
||
public interface InventoryBuilderProviderInterface { | ||
|
||
SmartInventory getBuilder(InventoryProvider inventoryProvider); | ||
|
||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/fr/quentin/searchquickshop/Menu/SmartInv.java
This file was deleted.
Oops, something went wrong.