use of com.skelril.skree.service.PlayerStateService 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);
}
use of com.skelril.skree.service.PlayerStateService in project Skree by Skelril.
the class JungleRaidInstance method tryInventoryRestore.
public void tryInventoryRestore(Player player) {
Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
if (optService.isPresent()) {
PlayerStateService service = optService.get();
service.loadInventoryIfStored(player);
}
}
use of com.skelril.skree.service.PlayerStateService in project Skree by Skelril.
the class SkyWarsInstance method remove.
@Override
public Clause<Player, ZoneStatus> remove(Player player) {
player.offer(Keys.FALL_DISTANCE, 0F);
playerLost(player);
Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
if (optService.isPresent()) {
PlayerStateService service = optService.get();
service.loadInventoryIfStored(player);
}
return super.remove(player);
}
use of com.skelril.skree.service.PlayerStateService in project Skree by Skelril.
the class TempleOfFateInstance method tryInventoryRestore.
public void tryInventoryRestore(Player player) {
Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
if (optService.isPresent()) {
PlayerStateService service = optService.get();
service.loadInventoryIfStored(player);
}
}
use of com.skelril.skree.service.PlayerStateService in project Skree by Skelril.
the class GameModeCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
Optional<PlayerStateService> optService = Sponge.getServiceManager().provide(PlayerStateService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The player state service is not currently running."));
return CommandResult.empty();
}
PlayerStateService service = optService.get();
GameMode mode = args.<GameMode>getOne("mode").get();
Player target = args.<Player>getOne("target").get();
if (service.hasInventoryStored(target) && !args.hasAny("f")) {
src.sendMessage(Text.of(TextColors.RED, "Player has an omni-state stored, action denied."));
src.sendMessage(Text.of(TextColors.RED, "This can be overwritten using -f."));
return CommandResult.empty();
}
service.save(target, target.get(Keys.GAME_MODE).get().getId());
target.offer(Keys.FALL_DISTANCE, 0F);
target.offer(Keys.GAME_MODE, mode);
service.load(target, mode.getId());
target.sendMessage(Text.of(TextColors.YELLOW, "Changed game mode to " + mode.getName() + '.'));
return CommandResult.success();
}
Aggregations