Package org.spout.vanilla.component.entity.misc

Examples of org.spout.vanilla.component.entity.misc.Sleep


    if (!(entity instanceof Player) || type != Action.RIGHT_CLICK) {
      return;
    }

    final Player player = (Player) entity;
    Sleep sleep = player.get(Sleep.class);
    if (sleep == null) {
      return;
    }

    final Block head = getCorrectHalf(block, true);
    final World world = player.getWorld();
    final Sky sky = world.get(Sky.class);

    for (Entity e : world.getNearbyEntities(player, NEARBY_MONSTER_RANGE)) {
      if (e.get(Living.class) instanceof Hostile) {
        player.sendMessage(NEARBY_MONSTER_MESSAGE);
        return;
      }
    }

    if (sky != null && sky.getTime() < Time.DUSK.getTime()) {
      player.sendMessage(NOT_NIGHT_MESSAGE);
      return;
    }

    if (isOccupied(head)) {
      player.sendMessage(OCCUPIED_MESSAGE);
      return;
    }

    sleep.sleep(head);
  }
View Full Code Here


    final List<Player> playerList = getOwner().getPlayers();

    // Sleeping players
    boolean skipNight = false;
    for (Player player : playerList) {
      Sleep c = player.get(Sleep.class);
      if (c == null || c.canSkipNight()) {
        skipNight = true;
      } else {
        skipNight = false;
        break;
      }
    }

    if (skipNight) {
      time = Time.DAWN.getTime();
      for (Player player : playerList) {
        Sleep c = player.get(Sleep.class);
        if (c != null && player.isOnline()) {
          c.wake();
        }
      }
    }
    getData().put(VanillaData.WORLD_TIME, time);
View Full Code Here

    Entity entity = world.getEntity(message.getEntityId());

    Block block = world.getBlock(message.getX(), message.getY(), message.getZ());

    Sleep sleep = entity.get(Sleep.class);
    sleep.sleep(block);
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.component.entity.misc.Sleep

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.