Git Product home page Git Product logo

coinsapi-mysql's Introduction

» CoinsAPI

A MySQL based Coins API

Gradle

repositories {
    maven {
        url = "http://tykopvp.com/"
        allowInsecureProtocol(true)
    }
}

dependencies {
    compileOnly("com.tykopvp:coinsapi:1.0")
}

Maven

<repositories>
    <repository>
        <id>coins</id>
        <url>http://tykopvp.com/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.tykopvp</groupId>
        <artifactId>coinsapi</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

   

» Spigot Example

@EventHandler
public void handle(PlayerJoinEvent event) {
    Player player = event.getPlayer();

    CoinsAPI instance = CoinsAPI.getInstance();
    if(instance.existsUser(player.getUniqueId())) return;
    ICoinsAPIUser user = instance.getUser(player.getUniqueId());

    user.addCoins(50);
    //Update Coins in a pool
    user.update(true);

    player.sendMessage("Your Coins: " + user.getCoins());
}

   

» Proxy Example

You can use the API on a BungeeCord Proxy too!

//You can of course also do the same with velocity it is important that you always connect the CoinsAPI to the database!
@Override
public void onEnable() {
    CoinsAPI.getInstance().connect(3, new Profile("127.0.0.1", 3306, "root", "coins", null));
}
@Override
public void onDisable() {
    CoinsAPI.getInstance().disconnect();
}

   

The player is registered in the database because it does not exist, but the spigot does it automatically!

@EventHandler
public void handle(PostLoginEvent event) {
    ProxiedPlayer player = event.getPlayer();
    CoinsAPI instance = CoinsAPI.getInstance();
    if(!instance.existsUser(player.getUniqueId())) {
        instance.addUser(player.getUniqueId(), player.getName());
    }
}

coinsapi-mysql's People

Contributors

cutenyami avatar bylumia avatar

Watchers

 avatar

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.