Skip to content

toppev/StrikePracticeAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

StrikePracticeAPI

For example:
StrikePracticeAPI.java
StrikePractice Events

Installation

Download the API jar to use in your own plugins here: https://strikepractice-api.toppe.dev/strikepractice-api.jar

Create a folder called libs (or whatever you want) in your plugin folder and put the jar there.

wget https://strikepractice-api.toppe.dev/strikepractice-api.jar -P libs

Now include the .jar in your pom.xml or build.gradle* file.

Maven

<dependencies>
    <!-- Your other dependencies -->
    <dependency>
        <groupId>ga.strikepractice</groupId>
        <artifactId>strikepractice-api</artifactId>
        <systemPath>${project.basedir}/libs/strikepractice-api.jar</systemPath>
    </dependency>
</dependencies>

Gradle (Kotlin DSL)

repositories {
    // ...
    // Include libs directory as a repository
    flatDir { dirs("libs") }
}

dependencies {
    // ...
    // Add the API as a compileOnly dependency
    compileOnly("ga.strikepractice:strikepractice-api")
}

Getting started with the API

Get current instance of the StrikePracticeAPI with the following:

StrikePracticeAPI api = StrikePractice.getAPI();

Now you can do anything with the api. For example

Player player = ...
Player opponent = api.getDuelOpponent(player);
if (opponent != null) {
  opponent.sendMessage("Hello opponent!");
}

You will find most useful methods in the ga.strikepractice.api.StrikePracticeAPI

There are also custom Bukkit events for each fight type and more. You will find these under ga.strikepractice.events. Just use them like any other Bukkit event. For example:

    
@EventHandler
public void onFightEnd(DuelEndEvent event) {
    Player p = event.getWinner();
    if(event.getFight().getKit().isElo()) {
        PlayerStats stats = StrikePractice.getAPI().getPlayerStats(p);
        int globalElo = stats.getGlobalElo();
        p.sendMessage("Your global elo is now " + globalElo);
    }
}

Or to set a custom spigot knockback to specific kits (Obviously not a working example but to get you started...):

    
@EventHandler
public void onKitSelect(KitSelectEvent event) {
    String kit = event.getKit().getName();
    Knockback kb = getKnockback(kit);
    // Set the kb found or default knockback
    event.getPlayer().setKnockback(kb == null ? getKnockback("default") : kb);
}
    
private KnockBack getKnockback(String key) {
    return ... // Your stuff here
}
    
//Also see KitDeselectEvent (called when the kit is removed from the player)

About

The API of StrikePractice plugin

Resources

License

Stars

Watchers

Forks