use of gg.projecteden.nexus.features.menus.api.content.SlotPos in project Nexus by ProjectEdenGG.
the class ShipColorMenu method init.
@Override
public void init() {
user = service.get(player);
int row = 1;
int col = 1;
addCloseItem();
for (ColorType colorType : ColorType.values()) {
if (colorType.getDyeColor() == null)
continue;
Material concrete = colorType.getConcrete();
if (concrete != null) {
ItemStack color = new ItemBuilder(concrete).name(StringUtils.camelCase(colorType.name())).build();
contents.set(new SlotPos(row, col), ClickableItem.of(color, e -> {
user.setShipColor(colorType.getBukkitColor());
service.save(user);
e.getPlayer().closeInventory();
ClientsideBlocks.update(player);
}));
if (++col == 8) {
col = 1;
++row;
}
}
}
}
use of gg.projecteden.nexus.features.menus.api.content.SlotPos in project Nexus by ProjectEdenGG.
the class SwipeCardTask method init.
@Override
public void init() {
Runnable reset = () -> {
player.setItemOnCursor(null);
init();
};
SlotPos cardPos = SlotPos.of(1, 1);
contents.fill(ClickableItem.empty(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).name(" ").build()));
AtomicReference<LocalDateTime> time = new AtomicReference<>();
contents.set(cardPos, ClickableItem.of(KEY_CARD.get(), click -> {
if (!click.isLeftClick() || !KEY_CARD.get().isSimilar(click.getItem()) || !(click.getPlayer().getItemOnCursor().getType() == Material.AIR || click.getPlayer().getItemOnCursor().isSimilar(KEY_CARD.get()))) {
reset.run();
} else {
time.set(LocalDateTime.now());
ClickableItem item = contents.get(cardPos).orElse(null);
if (item != null)
contents.set(cardPos, item.clone(new ItemBuilder(Material.LIGHT_GRAY_STAINED_GLASS_PANE).name(" ").build()));
click.getPlayer().setItemOnCursor(KEY_CARD.get());
}
}));
SlotPos destination = SlotPos.of(1, 7);
contents.set(destination, ClickableItem.of(new ItemBuilder(Material.GREEN_STAINED_GLASS_PANE).name(" ").build(), click -> {
if (time.get() == null || !KEY_CARD.get().isSimilar(click.getPlayer().getItemOnCursor())) {
reset.run();
return;
}
Duration duration = Duration.between(time.get(), LocalDateTime.now());
double sec = duration.getSeconds() + (duration.getNano() / 1000000000d);
if (!(sec >= .9d && sec <= 1.2d)) {
reset.run();
String fmt = sec < .9d ? "fast" : "slow";
contents.set(destination, contents.get(destination).get().clone(new ItemBuilder(Material.RED_STAINED_GLASS_PANE).name("Too " + fmt + ", try again").build()));
new SoundBuilder(Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO).receiver(player).category(SoundCategory.MASTER).volume(2f).play();
} else {
getTask().partCompleted(PlayerManager.get(player));
close();
}
}));
}
use of gg.projecteden.nexus.features.menus.api.content.SlotPos in project Nexus by ProjectEdenGG.
the class AdventMenu method loadHeads.
public static void loadHeads() {
// Specific Heads
origin.getRelative(0, 0, 2).getDrops().stream().findFirst().ifPresent(skull -> lockedHead = new ItemBuilder(skull));
origin.getRelative(0, 0, 3).getDrops().stream().findFirst().ifPresent(skull -> missedHead = new ItemBuilder(skull));
origin.getRelative(0, 0, 4).getDrops().stream().findFirst().ifPresent(skull -> toFindHead = new ItemBuilder(skull));
// Advent menu
String[] days = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturaday" };
for (int z = 0; z <= 4; z++) {
// 0-4 col
for (int x = 1; x <= 7; x++) {
// 1-7 row
Block block = origin.getRelative(x, 0, z);
if (!isNullOrAir(block)) {
ItemStack drop = block.getDrops().stream().findFirst().orElse(null);
if (!isNullOrAir(drop)) {
ItemBuilder skull = new ItemBuilder(drop);
int size = adventHeadMap.size();
if (size <= 6)
skull.name(days[size]);
adventHeadMap.put(new SlotPos(z, x), skull);
}
}
}
}
}
Aggregations