Package com.sijobe.spc.wrapper

Examples of com.sijobe.spc.wrapper.Player


   /**
    * @see com.sijobe.spc.wrapper.CommandBase#execute(com.sijobe.spc.wrapper.CommandSender, java.util.List)
    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = super.getSenderAsPlayer(sender);
      Coordinate c = player.getPosition();
      int distance = 0;
      try {
         distance = Integer.parseInt((String)params.get(0));
      } catch (NumberFormatException e) {
         throw new CommandException("Could not parse disance specified as integer: " + params.get(0));
      }
     
      if (((String)params.get(1)).toUpperCase().startsWith("N")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ() - distance));
      } else if (((String)params.get(1)).toUpperCase().startsWith("E")) {
         player.setPosition(new Coordinate(player.getPosition().getX() + distance, player.getPosition().getY(), player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("S")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ() + distance));
      } else if (((String)params.get(1)).toUpperCase().startsWith("W")) {
         player.setPosition(new Coordinate(player.getPosition().getX() - distance, player.getPosition().getY(), player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("U")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY() + distance, player.getPosition().getZ()));
      } else if (((String)params.get(1)).toUpperCase().startsWith("D")) {
         player.setPosition(new Coordinate(player.getPosition().getX(), player.getPosition().getY() - distance, player.getPosition().getZ() - distance));
      } else {
         throw new CommandException("Invalid direction specified.");
      }

      sender.sendMessageToPlayer("Moved from " +
               FontColour.AQUA + c.getBlockX() + FontColour.WHITE + ", " +
               FontColour.AQUA + c.getBlockX() + FontColour.WHITE + ", " +
               FontColour.AQUA + c.getBlockX() + FontColour.WHITE + " to " +
               FontColour.AQUA + player.getPosition().getBlockX() + FontColour.WHITE + ", " +
               FontColour.AQUA + player.getPosition().getBlockY() + FontColour.WHITE + ", " +
               FontColour.AQUA + player.getPosition().getBlockZ()
      );
   }
View Full Code Here


   /**
    * @see com.sijobe.spc.wrapper.CommandBase#execute(net.minecraft.src.ICommandSender, java.util.List)
    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = super.getSenderAsPlayer(sender);
      String portalType = (String)params.get(0);
      if (portalType.equalsIgnoreCase("end")) {
         Coordinate coord = player.getPosition();
         int x = MathHelper.floor_double(coord.getX());
         int z = MathHelper.floor_double(coord.getZ());
         EntityDragon entityDragon = new EntityDragon(player.getWorld().getMinecraftWorld()); // EntityDragon
         try {
            Class<?>[] args = new Class<?>[]{Integer.TYPE, Integer.TYPE};
            Method method;
            try {
               method = entityDragon.getClass().getDeclaredMethod("c", args);
            } catch (NoSuchMethodException nsme) {
               method = entityDragon.getClass().getDeclaredMethod("createEnderPortal", args);
            }
            method.setAccessible(true);
            method.invoke(entityDragon, new Object[]{x, z});
         } catch (Throwable t) {
            t.printStackTrace();
            throw new CommandException("End portal generation is currently unsupported.");
         }
      } else if (portalType.equalsIgnoreCase("nether")) {
         EntityPlayerMP playerEntity;
         if(player.getMinecraftPlayer() instanceof EntityPlayerMP) {
            playerEntity = (EntityPlayerMP)player.getMinecraftPlayer();
         } else {
            throw new CommandException("SPC should *NOT* be processing commands client-side!");
         }
         (new Teleporter(playerEntity.getServerForPlayer())).makePortal(playerEntity);
      } else {
View Full Code Here

      return new String[] {"set", "rem", "goto"};
   }

   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = super.getSenderAsPlayer(sender);
      if (getName().equalsIgnoreCase("set")) {
         setWaypoint((String)params.get(0), player);
         player.sendChatMessage("Waypoint was set at " + FontColour.AQUA + getLocationAsString(player.getPosition()));
      } else if (getName().equalsIgnoreCase("rem")) {
         if (removeWaypoint((String)params.get(0), player)) {
            player.sendChatMessage("Waypoint was removed.");
         } else {
            throw new CommandException("Waypoint does not exist.");
         }
      } else if (getName().equalsIgnoreCase("goto")) {
         if (gotoWaypoint((String)params.get(0), player)) {
            player.sendChatMessage("Whoosh");
         } else {
            throw new CommandException("Waypoint does not exist.");
         }
      } else {
         assert false : "Unexpected call not being handled: " + params.get(0);
View Full Code Here

   /**
    * @see com.sijobe.spc.wrapper.CommandBase#execute(com.sijobe.spc.wrapper.CommandSender, java.util.List)
    */
   @Override
   public void execute(CommandSender sender, List<?> params) throws CommandException {
      Player player = getSenderAsPlayer(sender);
      Coordinate block = player.trace(128);
      if (block == null) {
         throw new CommandException("No block within range.");
      }
      Coordinate fire = new Coordinate(block.getBlockX(), block.getBlockY() + 1, block.getBlockZ());
      if (player.getWorld().getBlockId(fire) == 0) {
         player.getWorld().setBlock(fire, BLOCK_FIRE);
      }
   }
View Full Code Here

      }
      int quantity = 1;
      if (params.size() > 1) {
         quantity = (Integer)params.get(1);
      }
      Player player = super.getSenderAsPlayer(sender);
      Coordinate coord = player.trace(128);
      if (coord == null) {
         coord = player.getPosition();
         coord = new Coordinate(coord.getX() + (Math.random() * 10) - 5, coord.getY(), coord.getZ() + (Math.random() * 10) - 5);
      }
      for (int i = 0; i < quantity; i++) {
         if (!Entity.spawnEntity(argument, coord, player.getWorld())) {
            throw new CommandException("Could not spawn entity named " + argument);
         }
      }
   }
View Full Code Here

public class EnderCrystal extends StandardCommand {

  @Override
  public void execute(CommandSender sender, List<?> params)
      throws CommandException {
    Player player = super.getSenderAsPlayer(sender);
    Coordinate c = player.trace(128D);
    if (c == null) {
      throw new CommandException("No block within range.");
    }
   
    Entity.spawnEntity("EnderCrystal", c, player.getWorld());
  }
View Full Code Here

public class Firework extends StandardCommand {

  @Override
  public void execute(CommandSender sender, List<?> params)
      throws CommandException {
    Player player = super.getSenderAsPlayer(sender);
    Coordinate c = player.trace(128D);
    Entity.spawnEntity("FireworksRocketEntity", c, player.getWorld());
  }
View Full Code Here

)
public class Ascend extends StandardCommand {

   @Override
   public void execute(CommandSender sender, List<?> params) {
      Player player = getSenderAsPlayer(sender);
      Coordinate c = player.getPosition();
      int y = c.getBlockY() + 1;
      while (y < 260) {
         if (player.isClear(new Coordinate(c.getBlockX(), y++, c.getBlockZ()))) {
            player.setPosition(new Coordinate(c.getBlockX() + 0.5F, --y, c.getBlockZ() + 0.5F));
            player.sendChatMessage("You ascended " + FontColour.AQUA + (y - c.getBlockY()) +
                     FontColour.WHITE + " blocks.");
            break;
         }
      }
   }
View Full Code Here

      }
   );

   @Override
   public void execute(CommandSender sender, List<?> params) {
      Player player = super.getSenderAsPlayer(sender);
      EntityTNTPrimed tnt = new EntityTNTPrimed(player.getWorld().getMinecraftWorld());
      tnt.setLocationAndAngles(player.getPosition().getX(), player.getPosition().getY() + 1, player.getPosition().getZ(), player.getYaw(), player.getPitch());
      tnt.fuse = 40;
      tnt.motionX = -MathHelper.sin((tnt.rotationYaw / 180F) * 3.141593F) * MathHelper.cos((tnt.rotationPitch / 180F) * 3.141593F);
      tnt.motionZ = MathHelper.cos((tnt.rotationYaw / 180F) * 3.141593F) * MathHelper.cos((tnt.rotationPitch / 180F) * 3.141593F);
      tnt.motionY = -MathHelper.sin((tnt.rotationPitch / 180F) * 3.141593F);

      double multiplier = 1;
      if (params.size() > 0) {
         multiplier = (Double)params.get(0);
      }

      tnt.motionX *= multiplier;
      tnt.motionY *= multiplier;
      tnt.motionZ *= multiplier;

      player.getWorld().getMinecraftWorld().spawnEntityInWorld(tnt);
   }
View Full Code Here

   @Override
   public void keyPressed(int key) {
      if (Minecraft.isGuiScreenOpen()) {
         return;
      }
      Player player = Minecraft.getPlayer();
      if (player != null) {
         CommandSender sender = new CommandSender(MinecraftServer.getPlayerByUsername(player.getPlayerName()));
         CommandManager.runCommand(sender, BINDINGS.getString(key + "", ""));
      }
   }
View Full Code Here

TOP

Related Classes of com.sijobe.spc.wrapper.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.