예제 #1
0
  public static void sendEndCredits(Player p) {
    CraftPlayer craft = (CraftPlayer) p;
    EntityPlayer nms = craft.getHandle();

    nms.viewingCredits = true;
    nms.playerConnection.sendPacket(new PacketPlayOutGameStateChange(4, 0.0F));
  }
예제 #2
0
 public static void sendActionBar(Player player, String message) {
   CraftPlayer p = (CraftPlayer) player;
   IChatBaseComponent cbc =
       IChatBaseComponent.ChatSerializer.a((String) ("{\"text\": \"" + message + "\"}"));
   PacketPlayOutChat ppoc = new PacketPlayOutChat(cbc, (byte) 2);
   p.getHandle().playerConnection.sendPacket(ppoc);
 }
예제 #3
0
 public void sendMessageRaw(Player player, String message) {
   if (player instanceof CraftPlayer) {
     ((CraftPlayer) player)
         .getHandle()
         .playerConnection
         .sendPacket(new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(message)));
   }
 }
예제 #4
0
 public void sendMessageActionBar(Player player, String message) {
   if (player instanceof CraftPlayer) {
     IChatBaseComponent cbc =
         IChatBaseComponent.ChatSerializer.a("{\"text\": \"" + JSONObject.escape(message) + "\"}");
     ((CraftPlayer) player)
         .getHandle()
         .playerConnection
         .sendPacket(new PacketPlayOutChat(cbc, (byte) 2));
   }
 }
예제 #5
0
 @Override
 public void doPickupAnimation(Entity entity, Entity target) {
   for (Entity p : target.getNearbyEntities(10, 10, 10)) {
     if (p instanceof Player) {
       ((CraftPlayer) p)
           .getHandle()
           .playerConnection
           .sendPacket(new PacketPlayOutCollect(target.getEntityId(), entity.getEntityId()));
     }
   }
 }
예제 #6
0
  /**
   * @param location the {@link Location} around which players must be to see the effect
   * @param effectName list of effects: https://gist.github.com/riking/5759002
   * @param offsetX the amount to be randomly offset by in the X axis
   * @param offsetY the amount to be randomly offset by in the Y axis
   * @param offsetZ the amount to be randomly offset by in the Z axis
   * @param speed the speed of the particles
   * @param count the number of particles
   * @param radius the radius around the location
   */
  public void playParticleEffect(
      Location location,
      String effectName,
      float offsetX,
      float offsetY,
      float offsetZ,
      float speed,
      int count,
      int radius,
      int... data) {
    EnumParticle effect = EnumParticle.valueOf(effectName);

    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(effect, "Effect cannot be null");
    Validate.notNull(location.getWorld(), "World cannot be null");

    PacketPlayOutWorldParticles packet =
        new PacketPlayOutWorldParticles(
            effect,
            false,
            (float) location.getX(),
            (float) location.getY(),
            (float) location.getZ(),
            offsetX,
            offsetY,
            offsetZ,
            speed,
            count,
            data);

    for (Player player : location.getWorld().getPlayers()) {
      if (player.getLocation().getWorld() == location.getWorld()) {
        if ((int) player.getLocation().distance(location) <= radius) {
          ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
      }
    }
  }
예제 #7
0
 public static void sendEntityVelocity(int id, double x, double y, double z, Player player) {
   PacketPlayOutEntityVelocity packet = new PacketPlayOutEntityVelocity(id, x, y, z);
   ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
 }