Package org.spout.api.entity

Examples of org.spout.api.entity.Player


import org.spout.vanilla.protocol.msg.world.block.BlockChangeMessage;

public class BlockChangeHandler extends MessageHandler<BlockChangeMessage> {
  @Override
  public void handleClient(ClientSession session, BlockChangeMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();
    RepositionManager rm = player.getNetwork().getRepositionManager();

    int x = rm.convertX(message.getX());
    int y = rm.convertY(message.getY());
    int z = rm.convertZ(message.getZ());
View Full Code Here


import org.spout.vanilla.protocol.msg.window.WindowItemsMessage;

public class WindowItemsHandler extends MessageHandler<WindowItemsMessage> {
  @Override
  public void handleClient(ClientSession session, WindowItemsMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder == null) {
      return;
    }
    Window window = holder.getActiveWindow();
    ItemStack[] slots = msg.getItems();
View Full Code Here

    }
  }

  @Override
  public void handleClient(ClientSession session, EntityAnimationMessage message) {
    Player player = session.getPlayer();

    Entity entity = player.getWorld().getEntity(message.getEntityId());

    ModelComponent models = entity.get(ModelComponent.class);
    if (models == null) {
      return;
    }
View Full Code Here

import org.spout.vanilla.protocol.msg.window.WindowSlotMessage;

public class WindowSlotHandler extends MessageHandler<WindowSlotMessage> {
  @Override
  public void handleClient(ClientSession session, WindowSlotMessage msg) {
    Player player = session.getPlayer();
    WindowHolder holder = player.get(WindowHolder.class);
    if (holder != null) {
      Slot entry = holder.getActiveWindow().getSlot(msg.getSlot());
      if (entry == null) {
        return;
      }
View Full Code Here

import org.spout.vanilla.protocol.msg.window.WindowOpenMessage;

public class WindowOpenHandler extends MessageHandler<WindowOpenMessage> {
  @Override
  public void handleClient(ClientSession session, WindowOpenMessage message) {
    Player player = ((Client) VanillaPlugin.getInstance().getEngine()).getPlayer();
    String title = message.getTitle();
    switch (message.getType()) {
      case DEFAULT:
        break;
      case CHEST:
        ChestInventory inventory = new ChestInventory(message.getSlots());
        player.get(WindowHolder.class).openWindow(new ChestWindow(player, inventory, title));
        break;
      case CRAFTING_TABLE:
        player.get(WindowHolder.class).openWindow(new CraftingTableWindow(player, title));
        break;
      case FURNACE:
        player.get(WindowHolder.class).openWindow(new FurnaceWindow(player, new FurnaceInventory(), title));
        break;
      case DISPENSER:
        player.get(WindowHolder.class).openWindow(new DispenserWindow(player, new DispenserInventory(), title));
        break;
      case ENCHANTMENT_TABLE:
        player.get(WindowHolder.class).openWindow(new EnchantmentTableWindow(player, new EnchantmentTableInventory(), title));
        break;
      case BREWING_STAND:
        player.get(WindowHolder.class).openWindow(new BrewingStandWindow(player, new BrewingStandInventory(), title));
        break;
      case VILLAGER:
        player.get(WindowHolder.class).openWindow(new VillagerWindow(player, new VillagerInventory(), title));
        break;
      default:
        break;
    }
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.entity.EntityEquipmentMessage;

public final class EntityEquipmentHandler extends MessageHandler<EntityEquipmentMessage> {
  @Override
  public void handleClient(ClientSession session, EntityEquipmentMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();

    int entityId = message.getEntityId();

    Entity entity = world.getEntity(entityId);
    if (entity == null) {
      player.getEngine().getLogger().warning("EntityEquipmentHandler entity don't exist");
      return;
    }

    EntityInventory inventory = entity.get(EntityInventory.class);
    if (inventory == null) {
      player.getEngine().getLogger().warning("EntityEquipmentHandler entity haven't EntityInventory");
      return;
    }

    ItemStack item = message.get();

    switch (message.getSlot()) {
      case 0:
        inventory.getHeldItem().setMaterial(item.getMaterial());
        inventory.getHeldItem().setAmount(item.getAmount());
        return;
      case 1:
        inventory.getArmor().getHelmet().setMaterial(item.getMaterial());
        inventory.getArmor().getHelmet().setAmount(item.getAmount());
        return;
      case 2:
        inventory.getArmor().getChestPlate().setMaterial(item.getMaterial());
        inventory.getArmor().getChestPlate().setAmount(item.getAmount());
        return;
      case 3:
        inventory.getArmor().getLeggings().setMaterial(item.getMaterial());
        inventory.getArmor().getLeggings().setAmount(item.getAmount());
        return;
      case 4:
        inventory.getArmor().getBoots().setMaterial(item.getMaterial());
        inventory.getArmor().getBoots().setAmount(item.getAmount());
        return;
      default:
        player.getEngine().getLogger().warning("EntityEquipmentHandler slot bad value");
    }
  }
View Full Code Here

    session.getPlayer().sendMessage(message.getMessage());
  }

  @Override
  public void handleServer(ServerSession session, PlayerChatMessage message) {
    Player player = session.getPlayer();
    String text = message.getMessage().trim();
    if (text.length() > 100) {
      text = text.substring(0, 99);
    }

    String command;
    String[] args;

    if (text.startsWith("/")) {
      command = text.split(" ")[0].replaceFirst("/", "");
      int argsIndex = text.indexOf(" ") + 1;
      args = argsIndex > 0 ? text.substring(argsIndex).split(" ") : new String[0];
    } else {
      command = "say";
      args = text.split(" ");
    }

    player.processCommand(command, args);
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.player.PlayerAbilityMessage;

public final class PlayerAbilityHandler extends MessageHandler<PlayerAbilityMessage> {
  @Override
  public void handleServer(ServerSession session, PlayerAbilityMessage message) {
    Player player = session.getPlayer();
    Human human = player.get(Human.class);
    if (human != null) {
      // TODO - this should do a permission check and revert if required
      human.setFlyingSpeed(message.getFlyingSpeed(), false);
      human.setWalkingSpeed(message.getWalkingSpeed(), false);
      human.setFlying(message.isFlying(), false);
View Full Code Here

    }
  }

  @Override
  public void handleClient(ClientSession session, PlayerAbilityMessage message) {
    Player player = session.getPlayer();
    Human human = player.get(Human.class);
    if (human != null) {
      // TODO - this should do a permission check and revert if required
      human.setFlyingSpeed(message.getFlyingSpeed(), false);
      human.setWalkingSpeed(message.getWalkingSpeed(), false);
      human.setFlying(message.isFlying(), false);
View Full Code Here

import org.spout.vanilla.protocol.msg.player.PlayerTimeMessage;

public final class PlayerTimeHandler extends MessageHandler<PlayerTimeMessage> {
  @Override
  public void handleClient(ClientSession session, PlayerTimeMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();

    Sky sky = world.add(Sky.class);
    sky.setTime(message.getTime());
  }
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.