@Override
  public void b(PacketDataSerializer packetdataserializer)
      throws IOException { // CraftBukkit - added throws
    packetdataserializer.b(a);

    UUID uuid = b.getId();
    // Spigot start - protocol patch
    if (packetdataserializer.version < 20) {
      packetdataserializer.a(
          uuid == null
              ? ""
              : packetdataserializer.version >= 5
                  ? uuid.toString()
                  : uuid.toString().replaceAll("-", "")); // Spigot
      packetdataserializer.a(
          b.getName().length() > 16
              ? b.getName().substring(0, 16)
              : b.getName()); // CraftBukkit - Limit name length to 16 characters
      if (packetdataserializer.version >= 5) { // Spigot
        packetdataserializer.b(b.getProperties().size());
        Iterator iterator = b.getProperties().values().iterator();

        while (iterator.hasNext()) {
          Property property = (Property) iterator.next();

          packetdataserializer.a(property.getName());
          packetdataserializer.a(property.getValue());
          packetdataserializer.a(property.getSignature());
        }
      }
    } else {
      packetdataserializer.writeUUID(uuid);
    }
    // Spigot end

    packetdataserializer.writeInt(c);
    packetdataserializer.writeInt(d);
    packetdataserializer.writeInt(e);
    packetdataserializer.writeByte(f);
    packetdataserializer.writeByte(g);
    // Spigot start - protocol patch
    if (packetdataserializer.version >= 47) {
      packetdataserializer.writeShort(org.spigotmc.SpigotDebreakifier.getItemId(h));
    } else {
      packetdataserializer.writeShort(h);
    }
    i.a(packetdataserializer);
  }
예제 #2
0
  public String getName() {
    Player player = getPlayer();
    if (player != null) {
      return player.getName();
    }

    // This might not match lastKnownName but if not it should be more correct
    if (profile.getName() != null) {
      return profile.getName();
    }

    NBTTagCompound data = getBukkitData();

    if (data != null) {
      if (data.hasKey("lastKnownName")) {
        return data.getString("lastKnownName");
      }
    }

    return null;
  }
예제 #3
0
 protected GameProfile a(GameProfile gameprofile) {
   UUID uuid =
       UUID.nameUUIDFromBytes(("OfflinePlayer:" + gameprofile.getName()).getBytes(Charsets.UTF_8));
   return new GameProfile(uuid, gameprofile.getName());
 }