Search in sources :

Example 1 with ZoneStatus

use of com.skelril.skree.service.internal.zone.ZoneStatus in project Skree by Skelril.

the class ZoneMeCommand method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
    ZoneService service = Sponge.getServiceManager().provide(ZoneService.class).get();
    service.requestZone(args.<String>getOne("zone").get(), (Player) src, () -> {
        src.sendMessage(Text.of(TextColors.YELLOW, "Job completed."));
    }, (clause) -> {
        if (clause.isPresent()) {
            ZoneStatus status = clause.get().getValue();
            src.sendMessage(Text.of(status == ZoneStatus.ADDED ? TextColors.GREEN : TextColors.RED, "Added with status: ", status));
        }
    });
    src.sendMessage(Text.of(TextColors.YELLOW, "Creating requested zone."));
    return CommandResult.success();
}
Also used : ZoneService(com.skelril.skree.service.ZoneService) ZoneStatus(com.skelril.skree.service.internal.zone.ZoneStatus)

Example 2 with ZoneStatus

use of com.skelril.skree.service.internal.zone.ZoneStatus in project Skree by Skelril.

the class ZoneTransitionalOrbListener method onBlockInteract.

@Listener
public void onBlockInteract(InteractBlockEvent.Secondary.MainHand event, @First Player player) {
    Optional<org.spongepowered.api.item.inventory.ItemStack> optItemStack = player.getItemInHand(HandTypes.MAIN_HAND);
    if (!optItemStack.isPresent()) {
        return;
    }
    ItemStack itemStack = tf(optItemStack.get());
    if (itemStack.getItem() != CustomItemTypes.ZONE_TRANSITIONAL_ORB) {
        return;
    }
    Optional<T> optInst = getApplicable(player);
    if (optInst.isPresent()) {
        Clause<Player, ZoneStatus> status = optInst.get().remove(player);
        if (status.getValue() == ZoneStatus.REMOVED) {
            Task.builder().execute(() -> {
                tf(player).inventory.decrStackSize(tf(player).inventory.currentItem, 1);
                tf(player).inventoryContainer.detectAndSendChanges();
            }).delayTicks(1).submit(SkreePlugin.inst());
        }
        event.setUseBlockResult(Tristate.FALSE);
    }
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) ZoneStatus(com.skelril.skree.service.internal.zone.ZoneStatus) ItemStack(net.minecraft.item.ItemStack) Listener(org.spongepowered.api.event.Listener)

Aggregations

ZoneStatus (com.skelril.skree.service.internal.zone.ZoneStatus)2 ZoneService (com.skelril.skree.service.ZoneService)1 ItemStack (net.minecraft.item.ItemStack)1 Player (org.spongepowered.api.entity.living.player.Player)1 Listener (org.spongepowered.api.event.Listener)1