reformatted project

This commit is contained in:
2025-10-16 00:58:52 +02:00
parent cf0499df44
commit 794dc1dbb1
150 changed files with 1594 additions and 1771 deletions

View File

@@ -15,24 +15,19 @@ import java.util.function.Consumer;
public class InteractableInventory extends Inventory {
/**
* Defines an Inventory with direct callbacks for ItemSlots
* @param inventoryType
* @param title
*/
protected InteractableInventory(@NotNull InventoryType inventoryType, @NotNull Component title) {
super(inventoryType, title);
addInventoryCondition(this::onClick);
this.addInventoryCondition(this::onClick);
}
/**
* Set Item with Callback
* @param item
* @param slot
* @param callback
*/
protected void setClickableItem(ItemStack item, int slot, Consumer<ItemClick> callback, boolean closeAfter) {
setItemStack(slot, item);
addInventoryCondition((player, clickedSlot, clickType, inventoryConditionResult) -> {
this.setItemStack(slot, item);
this.addInventoryCondition((player, clickedSlot, clickType, inventoryConditionResult) -> {
if(clickedSlot == slot) {
if(closeAfter) player.closeInventory();
callback.accept(new ItemClick(player, this, clickedSlot, item, clickType));
@@ -47,30 +42,25 @@ public class InteractableInventory extends Inventory {
/**
* Set Item without handler
* @param item
* @param slot
*/
protected void setDummyItem(ItemStack item, int slot) {
this.setClickableItem(
item,
slot,
itemClick -> {}
item,
slot,
itemClick -> {
}
);
}
protected void setDummyItem(Material material, int slot) {
this.setDummyItem(
ItemStack.builder(material).customName(Component.text("")).build(),
slot
ItemStack.builder(material).customName(Component.text("")).build(),
slot
);
}
/**
* You may want to Override this method to get more generic click events
* @param player
* @param slot
* @param clickType
* @param inventoryConditionResult
*/
protected void onClick(Player player, int slot, ClickType clickType, InventoryConditionResult inventoryConditionResult) {

View File

@@ -14,11 +14,6 @@ public class ItemClick {
/**
* Describes a click on an Item from an IntractableInventory
* @param player
* @param inventory
* @param clickedSlot
* @param item
* @param clickType
*/
public ItemClick(Player player, InteractableInventory inventory, int clickedSlot, ItemStack item, ClickType clickType) {
this.player = player;
@@ -29,22 +24,22 @@ public class ItemClick {
}
public Player getPlayer() {
return player;
return this.player;
}
public Inventory getInventory() {
return inventory;
return this.inventory;
}
public int getClickedSlot() {
return clickedSlot;
return this.clickedSlot;
}
public ItemStack getItem() {
return item;
return this.item;
}
public ClickType getClickType() {
return clickType;
return this.clickType;
}
}