-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dedicated InventorySize for implementations
- Loading branch information
Showing
7 changed files
with
86 additions
and
65 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
41 changes: 41 additions & 0 deletions
41
bukkit/bukkit-gui/src/main/java/me/hsgamer/hscore/bukkit/gui/object/BukkitInventorySize.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,41 @@ | ||
package me.hsgamer.hscore.bukkit.gui.object; | ||
|
||
import me.hsgamer.hscore.minecraft.gui.object.InventorySize; | ||
import org.bukkit.inventory.Inventory; | ||
|
||
/** | ||
* The {@link InventorySize} of {@link Inventory} | ||
*/ | ||
public class BukkitInventorySize implements InventorySize { | ||
private final Inventory inventory; | ||
|
||
/** | ||
* Create a new instance | ||
* | ||
* @param inventory the inventory | ||
*/ | ||
public BukkitInventorySize(Inventory inventory) { | ||
this.inventory = inventory; | ||
} | ||
|
||
@Override | ||
public int getSize() { | ||
return inventory.getSize(); | ||
} | ||
|
||
@Override | ||
public int getSlotPerRow() { | ||
switch (inventory.getType()) { | ||
case CHEST: | ||
case ENDER_CHEST: | ||
case SHULKER_BOX: | ||
return 9; | ||
case DISPENSER: | ||
case DROPPER: | ||
case HOPPER: | ||
return 3; | ||
default: | ||
return getSize(); | ||
} | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
...nestom-gui/src/main/java/me/hsgamer/hscore/minestom/gui/object/MinestomInventorySize.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,40 @@ | ||
package me.hsgamer.hscore.minestom.gui.object; | ||
|
||
import me.hsgamer.hscore.minecraft.gui.object.InventorySize; | ||
import net.minestom.server.inventory.Inventory; | ||
|
||
/** | ||
* The {@link InventorySize} of {@link Inventory} | ||
*/ | ||
public class MinestomInventorySize implements InventorySize { | ||
private final Inventory inventory; | ||
|
||
/** | ||
* Create a new instance | ||
* | ||
* @param inventory the inventory | ||
*/ | ||
public MinestomInventorySize(Inventory inventory) { | ||
this.inventory = inventory; | ||
} | ||
|
||
@Override | ||
public int getSize() { | ||
return inventory.getSize(); | ||
} | ||
|
||
@Override | ||
public int getSlotPerRow() { | ||
switch (inventory.getInventoryType()) { | ||
case CHEST_1_ROW, CHEST_2_ROW, CHEST_3_ROW, CHEST_4_ROW, CHEST_5_ROW, CHEST_6_ROW, SHULKER_BOX -> { | ||
return 9; | ||
} | ||
case WINDOW_3X3, CRAFTER_3X3 -> { | ||
return 3; | ||
} | ||
default -> { | ||
return getSize(); | ||
} | ||
} | ||
} | ||
} |