示例#1
0
  static Player getOfflinePlayer(String player, UUID uuid) {
    Player pplayer = null;
    try {
      File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");

      for (File playerfile : playerfolder.listFiles()) {
        String filename = playerfile.getName();
        String playername = filename.substring(0, filename.length() - 4);

        GameProfile profile = new GameProfile(uuid, playername);

        if (playername.trim().equalsIgnoreCase(player)) {
          MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
          EntityPlayer entity =
              new EntityPlayer(
                  server,
                  server.getWorldServer(0),
                  profile,
                  new PlayerInteractManager(server.getWorldServer(0)));
          Player target = entity == null ? null : (Player) entity.getBukkitEntity();
          if (target != null) {
            target.loadData();
            return target;
          }
        }
      }
    } catch (Exception e) {
      return null;
    }
    return pplayer;
  }
示例#2
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));
  }
示例#3
0
  public String getPlayerLanguage(Player player) {
    if (!(player instanceof CraftPlayer)) {
      return "en_US";
    }
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    try {
      Field field = entityPlayer.getClass().getDeclaredField("locale");
      field.setAccessible(true);

      return (String) field.get(entityPlayer);
    } catch (Exception e) {
      return "en_US";
    }
  }