@Override public void setGameMode(PlotGameMode gameMode) { switch (gameMode) { case ADVENTURE: this.player.offer(Keys.GAME_MODE, GameModes.ADVENTURE); return; case CREATIVE: this.player.offer(Keys.GAME_MODE, GameModes.CREATIVE); return; case SPECTATOR: this.player.offer(Keys.GAME_MODE, GameModes.SPECTATOR); return; case SURVIVAL: this.player.offer(Keys.GAME_MODE, GameModes.SURVIVAL); return; case NOT_SET: this.player.offer(Keys.GAME_MODE, GameModes.NOT_SET); } }
@Override public void onInitialize() throws CraftBookException { super.onInitialize(); chairs = new HashMap<>(); allowedBlocks.load(config); exitAtEntry.load(config); requireSigns.load(config); maxSignDistance.load(config); faceCorrectDirection.load(config); healPassenger.load(config); healAmount.load(config); usePermissions.register(); Sponge.getGame().getScheduler().createTaskBuilder().intervalTicks(10).execute(task -> { for (Map.Entry<UUID, Chair<?>> chair : new HashSet<>(chairs.entrySet())) { Player player = Sponge.getGame().getServer().getPlayer(chair.getKey()).orElse(null); if (player == null) { removeChair(chair.getValue(), false); return; } if (healPassenger.getValue()) { if (player.get(Keys.HEALTH).orElse(0d) < player.get(Keys.MAX_HEALTH).orElse(0d)) { player.offer(Keys.HEALTH, Math.min(player.get(Keys.HEALTH).orElse(0d) + healAmount.getValue(), player.get(Keys.MAX_HEALTH).orElse(0d))); } } if (player.get(Keys.EXHAUSTION).orElse(-20d) > -20d) { player.offer(Keys.EXHAUSTION, player.get(Keys.EXHAUSTION).orElse(-20d) - 0.1d); } } }).submit(CraftBookPlugin.inst()); }
live.offer(live.getFoodData().foodLevel().set(req.getFoodLevel())); live.offer(live.getFoodData().exhaustion().set(req.getExhaustion())); live.offer(live.getFoodData().saturation().set(req.getSaturation())); live.offer(exp.totalExperience().set(req.getTotalExperience()))); live.offer(exp.level().set(req.getLevel()))); live.offer(exp.experienceSinceLevel().set(req.getExperienceSinceLevel()))); live.offer(live.getHealthData().health().set(req.getHealth())); live.offer(live.getHealthData().maxHealth().set(req.getMaxHealth())); throw new InternalServerErrorException("Could not get live game mode"); live.offer(live.gameMode().set(optGm.get()));