Giter VIP home page Giter VIP logo

osu4j's Introduction

osu4j

an easy-to-use wrapper for the osu! API, complete with users, beatmaps, matches, customizable rate limits, et cetera.

Example 1 - GetUserTest

public class GetUserTest {
	private static final String USER = "oopsjpeg";
	private static final GameMode MODE = GameMode.STANDARD;
	private static final int TOP_SCORE_LIMIT = 3;

	public static void main(String[] args) throws OsuAPIException, MalformedURLException {
		// Create a new Osu object with an API key
		String key = args[0];
		Osu osu = Osu.getAPI(key);

		// Get the user
		System.out.println("Getting user...");
		OsuUser user = osu.users.query(new EndpointUsers.ArgumentsBuilder(USER).setMode(MODE).build());

		// Print some user info
		System.out.println(user.getUsername() + "(" + user.getID() + ")");
		System.out.println(user.getURL());
		System.out.println("Rank: #" + user.getRank());
		System.out.println("Performance: #" + user.getRank() + " (" + user.getPP() + "pp)");
		System.out.println("Total Score: " + user.getTotalScore());

		// Get the user's top scores
		List<OsuScore> topScores = user.getTopScores(TOP_SCORE_LIMIT).get();

		// Print the top scores
		for (int i = 0; i < topScores.size(); i++) {
			OsuScore score = topScores.get(i);
			OsuBeatmap beatmap = score.getBeatmap().get();
			System.out.println("Top score #" + (i + 1) + ": " + beatmap.toString() + " " + beatmap.getURL());
		}
	}
}

Example 2 - GetBeatmapTest

public class GetBeatmapTest {
	private static final int BEATMAP_ID = 131891;

	public static void main(String[] args) throws OsuAPIException, MalformedURLException {
		// Create a new Osu object with an API key
		String KEY = args[0];
		Osu osu = Osu.getAPI(KEY);

		// Get the beatmap
		OsuBeatmap beatmap = osu.beatmaps.getAsQuery(new EndpointBeatmaps.ArgumentsBuilder()
				.setBeatmapID(BEATMAP_ID).build())
				.resolve().get(0);

		// Print information
		System.out.println(beatmap.toString());
		System.out.println(beatmap.getURL());
		System.out.println("Creator: " + beatmap.getCreatorName());
		System.out.println("BPM: " + beatmap.getBPM());
		System.out.println("Difficulty: " + beatmap.getDifficulty());
	}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.