Search in sources :

Example 1 with InventoryStorageStateException

use of com.skelril.skree.service.internal.playerstate.InventoryStorageStateException in project Skree by Skelril.

the class TempleOfFateInstance method add.

@Override
public Clause<Player, ZoneStatus> add(Player player) {
    player.setLocation(startingPoint);
    Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
    if (optService.isPresent()) {
        PlayerStateService service = optService.get();
        try {
            service.storeInventory(player);
            service.releaseInventory(player);
            player.offer(Keys.POTION_EFFECTS, new ArrayList<>());
            player.getInventory().clear();
        } catch (InventoryStorageStateException e) {
            e.printStackTrace();
            return new Clause<>(player, ZoneStatus.ERROR);
        }
    }
    participants.add(player);
    return new Clause<>(player, ZoneStatus.ADDED);
}
Also used : PlayerStateService(com.skelril.skree.service.PlayerStateService) InventoryStorageStateException(com.skelril.skree.service.internal.playerstate.InventoryStorageStateException) Clause(com.skelril.nitro.Clause)

Example 2 with InventoryStorageStateException

use of com.skelril.skree.service.internal.playerstate.InventoryStorageStateException in project Skree by Skelril.

the class SkyWarsInstance method add.

@Override
public Clause<Player, ZoneStatus> add(Player player) {
    if (state != SkyWarsState.LOBBY) {
        return new Clause<>(player, ZoneStatus.NO_REJOIN);
    }
    player.setLocation(startingLocation);
    Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
    if (optService.isPresent()) {
        PlayerStateService service = optService.get();
        try {
            service.storeInventory(player);
            service.releaseInventory(player);
            giveTeamHoods(player);
        } catch (InventoryStorageStateException e) {
            e.printStackTrace();
            return new Clause<>(player, ZoneStatus.ERROR);
        }
    }
    playerDataMapping.put(player, new SkyWarsPlayerData());
    return new Clause<>(player, ZoneStatus.ADDED);
}
Also used : PlayerStateService(com.skelril.skree.service.PlayerStateService) InventoryStorageStateException(com.skelril.skree.service.internal.playerstate.InventoryStorageStateException) Clause(com.skelril.nitro.Clause)

Example 3 with InventoryStorageStateException

use of com.skelril.skree.service.internal.playerstate.InventoryStorageStateException in project Skree by Skelril.

the class GoldRushInstance method tryToStart.

public void tryToStart() {
    BigDecimal coffersNeeded = getCoffersNeeded();
    if (coffersNeeded.compareTo(BigDecimal.ZERO) >= 0) {
        MessageChannel channel = getPlayerMessageChannel(PlayerClassifier.SPECTATOR);
        channel.send(Text.of(TextColors.RED, "Your party doesn't have a high enough coffer risk!"));
        channel.send(Text.of(TextColors.RED, "At least ", coffersNeeded, " more coffers must be risked."));
        return;
    }
    Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
    for (Player player : getPlayers(PlayerClassifier.PARTICIPANT)) {
        if (optService.isPresent()) {
            PlayerStateService service = optService.get();
            try {
                service.storeInventory(player);
                service.releaseInventory(player);
                player.getInventory().clear();
            } catch (InventoryStorageStateException e) {
                e.printStackTrace();
                player.sendMessage(Text.of(TextColors.RED, "An error occurred while saving your inventory, contact an admin!"));
                return;
            }
        } else {
            if (player.getInventory().query(PlayerInventory.class, EquipmentInventory.class).size() > 0) {
                getPlayerMessageChannel(PlayerClassifier.SPECTATOR).send(Text.of(TextColors.RED, "All players inventories must be empty."));
                return;
            }
        }
    }
    readyPlayers();
    calculateLootSplit();
    // Reset tryToStart clock
    startTime = System.currentTimeMillis();
    // Add content
    populateChest();
    runLavaChance();
    setFloodStartTime();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PlayerStateService(com.skelril.skree.service.PlayerStateService) MessageChannel(org.spongepowered.api.text.channel.MessageChannel) InventoryStorageStateException(com.skelril.skree.service.internal.playerstate.InventoryStorageStateException) BigDecimal(java.math.BigDecimal)

Example 4 with InventoryStorageStateException

use of com.skelril.skree.service.internal.playerstate.InventoryStorageStateException in project Skree by Skelril.

the class JungleRaidInstance method add.

@Override
public Clause<Player, ZoneStatus> add(Player player) {
    if (state != JungleRaidState.LOBBY) {
        return new Clause<>(player, ZoneStatus.NO_REJOIN);
    }
    player.setLocation(lobbySpawnLocation);
    Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
    if (optService.isPresent()) {
        PlayerStateService service = optService.get();
        try {
            service.storeInventory(player);
            service.releaseInventory(player);
            giveBaseEquipment(player, JungleRaidClass.BALANCED);
        } catch (InventoryStorageStateException e) {
            e.printStackTrace();
            return new Clause<>(player, ZoneStatus.ERROR);
        }
    }
    participants.add(player);
    return new Clause<>(player, ZoneStatus.ADDED);
}
Also used : PlayerStateService(com.skelril.skree.service.PlayerStateService) InventoryStorageStateException(com.skelril.skree.service.internal.playerstate.InventoryStorageStateException) Clause(com.skelril.nitro.Clause)

Example 5 with InventoryStorageStateException

use of com.skelril.skree.service.internal.playerstate.InventoryStorageStateException in project Skree by Skelril.

the class ZoneWaitingLobby method add.

public void add(Player player) {
    Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
    if (optService.isPresent()) {
        PlayerStateService service = optService.get();
        try {
            service.storeInventory(player);
            service.releaseInventory(player);
            player.getInventory().clear();
            player.getInventory().offer(newItemStack(ItemTypes.COOKED_BEEF, 64));
        } catch (InventoryStorageStateException e) {
            e.printStackTrace();
        }
    }
    player.setLocation(entryPointSupplier.get());
    player.sendMessage(Text.of(TextColors.YELLOW, "Your instance is building..."));
    player.sendMessage(Text.of(TextColors.YELLOW, "You will automatically be teleported when it's finished."));
    player.sendMessage(Text.of(TextColors.YELLOW, "For now have a snowball fight!"));
    playingPlayers.put(player, 0);
}
Also used : PlayerStateService(com.skelril.skree.service.PlayerStateService) InventoryStorageStateException(com.skelril.skree.service.internal.playerstate.InventoryStorageStateException)

Aggregations

PlayerStateService (com.skelril.skree.service.PlayerStateService)5 InventoryStorageStateException (com.skelril.skree.service.internal.playerstate.InventoryStorageStateException)5 Clause (com.skelril.nitro.Clause)3 BigDecimal (java.math.BigDecimal)1 Player (org.spongepowered.api.entity.living.player.Player)1 MessageChannel (org.spongepowered.api.text.channel.MessageChannel)1