-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
fe76057
commit e5329c5
Showing
6 changed files
with
194 additions
and
9 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
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
49 changes: 49 additions & 0 deletions
49
core/src/main/java/me/huanmeng/opensource/bukkit/gui/slot/PlayerSlot.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,49 @@ | ||
package me.huanmeng.opensource.bukkit.gui.slot; | ||
|
||
import me.huanmeng.opensource.bukkit.gui.AbstractGui; | ||
import me.huanmeng.opensource.bukkit.gui.button.Button; | ||
import me.huanmeng.opensource.bukkit.gui.enums.Result; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.inventory.ClickType; | ||
import org.bukkit.event.inventory.InventoryAction; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
import org.bukkit.event.inventory.InventoryType; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
/** | ||
* 代表玩家背包中的槽位 | ||
* | ||
* @author huanmeng_qwq | ||
*/ | ||
public class PlayerSlot implements Slot { | ||
@NonNull | ||
private final Slot slot; | ||
|
||
public PlayerSlot(@NonNull Slot slot) { | ||
this.slot = slot; | ||
} | ||
|
||
@Override | ||
public int getIndex() { | ||
return slot.getIndex(); | ||
} | ||
|
||
@Override | ||
public @NonNull Result onClick(@NonNull AbstractGui<?> gui, @NonNull Button button, @NonNull Player player, @NonNull ClickType click, @NonNull InventoryAction action, InventoryType.@NonNull SlotType slotType, int slot, int hotBarKey, @NonNull InventoryClickEvent e) { | ||
return this.slot.onClick(gui, button, player, click, action, slotType, slot, hotBarKey, e); | ||
} | ||
|
||
@Override | ||
public boolean tryPlace(@NonNull Button button, @NonNull Player player) { | ||
return slot.tryPlace(button, player); | ||
} | ||
|
||
@Override | ||
public PlayerSlot toPlayerSlot() { | ||
return this; | ||
} | ||
|
||
public Slot getSlot() { | ||
return slot; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/java/me/huanmeng/opensource/bukkit/gui/slot/PlayerSlots.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,36 @@ | ||
package me.huanmeng.opensource.bukkit.gui.slot; | ||
|
||
import me.huanmeng.opensource.bukkit.gui.AbstractGui; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* 2024/12/28<br> | ||
* Bukkit-Gui-pom<br> | ||
* | ||
* @author huanmeng_qwq | ||
*/ | ||
public class PlayerSlots implements Slots { | ||
@NonNull | ||
private final Slots slots; | ||
|
||
public PlayerSlots(@NotNull Slots slots) { | ||
this.slots = slots; | ||
} | ||
|
||
@Override | ||
public @NotNull <G extends AbstractGui<@NonNull G>> @NonNull Slot[] slots(@NonNull G gui) { | ||
return Arrays.stream(slots.slots(gui)).map(Slot::toPlayerSlot).toArray(PlayerSlot[]::new); | ||
} | ||
|
||
@Override | ||
public PlayerSlots toPlayerSlots() { | ||
return this; | ||
} | ||
|
||
public Slots getSlots() { | ||
return slots; | ||
} | ||
} |
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
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