31 lines
1.3 KiB
Java
31 lines
1.3 KiB
Java
package net.crankedpvp.customblocks.guis;
|
|
|
|
import dev.triumphteam.gui.guis.GuiItem;
|
|
import dev.triumphteam.gui.guis.PaginatedGui;
|
|
import lombok.Getter;
|
|
import net.crankedpvp.crankedutils.utils.PlayerUtils;
|
|
import net.crankedpvp.customblocks.struct.CustomBlockType;
|
|
import net.crankedpvp.customblocks.struct.abilities.LevelAble;
|
|
import org.bukkit.entity.Player;
|
|
|
|
@Getter
|
|
public class CustomBlocksGui {
|
|
private final PaginatedGui gui;
|
|
|
|
public CustomBlocksGui(Player player) throws IllegalAccessException, InstantiationException {
|
|
this.gui = new PaginatedGui(3, 27, "Cranked CustomBlocks");
|
|
this.gui.setDefaultClickAction(event -> event.setCancelled(true));
|
|
for (CustomBlockType type : CustomBlockType.values()) {
|
|
this.gui.addItem(new GuiItem(type.getCustomBlockClass().newInstance() instanceof LevelAble ? type.build(1) : type.build(0), event -> {
|
|
if (player.isOp()) {
|
|
try {
|
|
PlayerUtils.giveOrDropProtectedItem(player, type.getCustomBlockClass().newInstance() instanceof LevelAble ? type.build(1) : type.build(0), 60);
|
|
} catch (InstantiationException | IllegalAccessException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}));
|
|
}
|
|
}
|
|
}
|