Package net.lightstone.world

Examples of net.lightstone.world.World


    if (args.length != 1) {
      player.sendMessage("§eUsage: /kick <username>");
      return;
    }

    World world = player.getWorld();
    String name = args[0];

    for (Player p : world.getPlayers()) {
      if (p.getName().equalsIgnoreCase(name)) {
        player.sendMessage("§eKicking " + p.getName());
        p.getSession().send(new KickMessage("Kicked by " + player.getName()));
        return;
      }
View Full Code Here


    } catch (NumberFormatException ex) {
      player.sendMessage("§eThat doesn't appear to be a valid number.");
      return;
    }

    World world = player.getWorld();
    if (mode.equals("add")) {
      world.setTime(world.getTime() + value);
    } else if (mode.equals("set")) {
      world.setTime(value);
    } else {
      player.sendMessage("&eInvalid mode - try 'add' or 'set'.");
    }
  }
View Full Code Here

  public void handle(Session session, Player player, DiggingMessage message) {
    if (player == null)
      return;

    if (message.getState() == DiggingMessage.STATE_DONE_DIGGING) {
      World world = player.getWorld();

      int x = message.getX();
      int z = message.getZ();
      int y = message.getY();

      // TODO it might be nice to move these calculations somewhere else since they will need to be reused
      int chunkX = x / Chunk.WIDTH + ((x < 0 && x % Chunk.WIDTH != 0) ? -1 : 0);
      int chunkZ = z / Chunk.HEIGHT + ((z < 0 && z % Chunk.HEIGHT != 0) ? -1 : 0);

      int localX = (x - chunkX * Chunk.WIDTH) % Chunk.WIDTH;
      int localZ = (z - chunkZ * Chunk.HEIGHT) % Chunk.HEIGHT;

      Chunk chunk = world.getChunks().getChunk(chunkX, chunkZ);
      int oldType = chunk.getType(localX, localZ, y);
      chunk.setType(localX, localZ, y, Blocks.TYPE_AIR);

      // TODO this should also be somewhere else as well... perhaps in the chunk.setType() method itself?
      BlockChangeMessage bcmsg = new BlockChangeMessage(x, y, z, 0, 0);
      SoundEffectMessage soundMsg = new SoundEffectMessage(SoundEffectMessage.DIG_SOUND, x, y, z, oldType);
      for (Player p: world.getPlayers()) {
        p.getSession().send(bcmsg);
        if(p != player && player.isWithinDistance(p)) {
          p.getSession().send(soundMsg);
        }
      }
View Full Code Here

TOP

Related Classes of net.lightstone.world.World

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.