Package org.spout.api.entity

Examples of org.spout.api.entity.Player


    }
    if (self) {
      // Sync using vanilla Player 'self' protocol
      // Note: No messages gathered because all update methods send to the Player
      PlayerEntityProtocol pep = (PlayerEntityProtocol) ep;
      Player player = (Player) e;
      if (destroy) {
        pep.doSelfDestroy(player);
      }
      if (spawn) {
        pep.doSelfSpawn(player, getRepositionManager());
View Full Code Here


    event.getMessages().add(new EntityEffectMessage(event.getEntity().getId(), (byte) event.getEffect().getType().getId(), (byte) 0, (short) (event.getEffect().getDuration() * 20)));
  }

  @EventHandler
  public void onExperienceChange(PlayerExperienceChangeEvent event) {
    Player player = event.getPlayer();
    Level level = player.add(Level.class);
    event.getMessages().add(new PlayerExperienceMessage(level.getProgress(), level.getLevel(), event.getNewExp()));
  }
View Full Code Here

  }

  @CommandDescription (aliases = "clear", usage = "[player] [item] [data]", desc = "Clears the target's inventory")
  @Permissible ("vanilla.command.clear")
  public void clear(CommandSource source, CommandArguments args) throws CommandException {
    Player player = args.popPlayerOrMe("player", source);
    Material filter = VanillaArgumentTypes.popMaterial("filter", args);
    Integer data = args.popInteger("data");
    args.assertCompletelyParsed();

    PlayerInventory inv = player.get(PlayerInventory.class);
    if (inv == null) {
      throw new CommandException(player.getName() + " doesn't have a inventory!");
    } else {
      // Count the items and clear the inventory
      Inventory[] inventories = new Inventory[] {inv.getMain(), inv.getQuickbar(), inv.getArmor()};
      int cleared = 0;
      for (int k = 0; k < inventories.length; k++) {
        for (int i = 0; i < inventories[k].size(); i++) {
          if (inventories[k].get(i) != null && (filter == null || inventories[k].get(i).isMaterial(filter)) && (data == null || inventories[k].get(i).getData() == data)) {
            cleared += inventories[k].get(i).getAmount();
            inventories[k].set(i, null);
          }
        }
      }

      if (cleared == 0) {
        throw new CommandException("Inventory is already empty");
      }

      source.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Cleared the inventory of " + player.getName() + ", removing " + cleared + " items.");
    }
  }
View Full Code Here

  }

  @CommandDescription (aliases = {"give"}, usage = "[player] <block> [amount] [data]", desc = "Lets a player spawn items")
  @Permissible ("vanilla.command.give")
  public void give(CommandSource source, CommandArguments args) throws CommandException {
    Player player;
    if (args.length() != 1) {
      player = args.popPlayerOrMe("player", source);
    } else {
      player = args.checkPlayer(source);
    }
    Material material = VanillaArgumentTypes.popMaterial("material", args);
    int quantity = args.popInteger("quantity");
    int data = args.popInteger("data");
    args.assertCompletelyParsed();

    PlayerInventory inventory = player.get(PlayerInventory.class);
    if (inventory != null) {
      inventory.add(new ItemStack(material, data, quantity));
      source.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Gave "
          + ChatStyle.WHITE + player.getName() + " " + quantity + ChatStyle.GREEN + " of " + ChatStyle.WHITE
          + material.getDisplayName());
    } else {
      throw new CommandException(player.getName() + " doesn't have a inventory!");
    }
  }
View Full Code Here

    }

    ops.setOp(playerName, false);
    source.sendMessage(plugin.getPrefix() + playerName + ChatStyle.RED + " had their operator status revoked!");
    if (getEngine() instanceof Server) {
      Player player = ((Server) getEngine()).getPlayer(playerName, true);
      if (player != null && !source.equals(player)) {
        player.sendMessage(plugin.getPrefix() + ChatStyle.RED + "You had your operator status revoked!");
      }
    }
  }
View Full Code Here

    }

    ops.setOp(playerName, true);
    source.sendMessage(plugin.getPrefix() + ChatStyle.RED + playerName + " is now an operator!");
    if (getEngine() instanceof Server) {
      Player player = ((Server) getEngine()).getPlayer(playerName, true);
      if (player != null && !source.equals(player)) {
        player.sendMessage(plugin.getPrefix() + ChatStyle.YELLOW + "You are now an operator!");
      }
    }
  }
View Full Code Here

  @CommandDescription (aliases = {"gamemode", "gm"}, usage = "<0|1|2|survival|creative|adventure|s|c|a> [player] (0 = SURVIVAL, 1 = CREATIVE, 2 = ADVENTURE)", desc = "Change a player's game mode")
  @Permissible ("vanilla.command.gamemode")
  public void gamemode(CommandSource source, CommandArguments args) throws CommandException {
    GameMode mode = VanillaArgumentTypes.popGameMode("gamemode", args);
    Player player = args.popPlayerOrMe("player", source);
    args.assertCompletelyParsed();

    Human human = player.get(Human.class);
    if (human == null) {
      throw new CommandException("Invalid player!");
    }

    human.setGamemode(mode);

    if (!player.equals(source)) {
      source.sendMessage(plugin.getPrefix() + ChatStyle.WHITE + player.getName()
          + "'s " + ChatStyle.GREEN + "gamemode has been changed to "
          + ChatStyle.WHITE + mode.name() + ChatStyle.GREEN + ".");
    }
  }
View Full Code Here

    }
    if (!Action.RIGHT_CLICK.equals(type)) {
      return;
    }

    Player player = (Player) entity;
    AnvilInventory inventory = new AnvilInventory();
    AnvilOpenEvent event = player.getEngine().getEventManager().callEvent(new AnvilOpenEvent(block, inventory, player));
    if (!event.isCancelled()) {
      player.get(WindowHolder.class).openWindow(new AnvilWindow(player, new AnvilInventory(), block));
    }
  }
View Full Code Here

  public void onInteractBy(Entity entity, Block block, Action type, BlockFace clickedFace) {
    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

  }

  @CommandDescription (aliases = "xp", usage = "[player] <amount>", desc = "Give/take experience from a player")
  @Permissible ("vanilla.command.xp")
  public void xp(CommandSource source, CommandArguments args) throws CommandException {
    Player player = args.popPlayerOrMe("player", source);
    int amount = args.popInteger("amount");
    args.assertCompletelyParsed();

    Level level = player.get(Level.class);
    if (level == null) {
      throw new CommandException(player.getDisplayName() + " does not have experience.");
    }

    level.addExperience(amount);
    player.sendMessage(plugin.getPrefix() + ChatStyle.GREEN + "Your experience has been set to " + ChatStyle.WHITE + amount + ChatStyle.GREEN + ".");
  }
View Full Code Here

TOP

Related Classes of org.spout.api.entity.Player

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.