Git Product home page Git Product logo

queryapi-bukkit's Introduction

QueryAPI-Bukkit

NOTE: This plugin is untested, it's open source hence and is super easy to work with. Please report and issues to me

QueryAPI runs as its own bukkit plugins, so you'll need it in the plugins directory of each server you plan to retrieve information from. I'd also highly advise that you set the plugin as a dependency in your plugin.yml: softdepend: [QueryAPI-Bukkit], or as a hard dependency depending on your implementation.

I'm also going to mention that you need to be on the SAME REDIS INSTANCE in order to communicate the information. I feel as if I shouldn't need to say this, but you'd be surprised.

Compiling

First, clone the repository using git clone https://github.com/InvisRaidinq/QueryAPI-Bukkit.git, and then compile using cd QueryAPI-Bukkit && mvn clean install. A target/ directory will be created, with the compiled JAR file.

Implementing the API into a plugin

Getting an instance of the API

There are two possible ways to get an instance of the API. You can declare it a global variable in your Main class, and then create a getter for it:

public class ExamplePlugin extends JavaPlugin {
    
    private final QueryAPI queryAPI = QueryAPI.getInstance();

    @Override
    public void onEnable() {
        if (Bukkit.getPluginManager().getPlugin("QueryAPI-Bukkit") == null) {
            this.getLogger().warning("Oh no, looks like you forgot to set the plugin as a dependency!");
            this.getServer().shutdown();
        }
    }
    
    public QueryAPI getQueryAPI() {
        return this.queryAPI;
    }
}

Or you can grab the instance in a class:

public class ExampleClass {
    
    private final QueryAPI queryAPI = QueryAPI.getInstance();
    
    public void broadcastOnlinePlayers() {
        Bukkit.broadcastMessage(ChatColor.GREEN + "There are currently " + queryAPI.getOnlinePlayers() + " players on this network");
    }
}

Pull Requests and Changes

I want this to be a community focused project: if there are any bugs or you've got a suggestion, feel free to fork the repository and make a pull request, or let me know your ideas and I'll look into implementing them!

Using this in your plugins

You're free to use this API in any of your plugins, including premium plugins that you want to re-sell. Please, however, give me credit for the work I've done.

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.