Coder Social home page Coder Social logo

sirblobman / cooldownsx Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 11.0 486 KB

A plugin that adds configurable cooldowns to items.

Home Page: https://www.spigotmc.org/resources/41981/

Java 95.43% Kotlin 4.57%
bukkit cooldown ender java minecraft pearl plugin bukkit-plugin papermc spigot-plugin

cooldownsx's Introduction

CooldownsX

A plugin that adds customizable cool down timers to items. Using this plugin, you can ensure that your server is balanced and that players use items strategically instead of spamming them.

Requirements

Placeholders

CooldownsX adds placeholders to plugins that support PlaceholderAPI. Review the table below for placeholder information:

Placeholder Description Example Output
%cooldownsx_time_left_<id>% The amount of seconds left for a specific cooldown. (integer) 5
%cooldownsx_time_left_decimal_<id>% The amount of seconds left for a specific cooldown. (decimal) 5.2

<id>: The configuration identifier.

API Information

CooldownsX has a useful API that is hosted on my own repository. To use the api, add the following values to your pom.xml file:

Maven Repository
<repositories>
    <!-- SirBlobman Public Repository -->
    <repository>
        <id>sirblobman-public</id>
        <url>https://nexus.sirblobman.xyz/public/</url>
    </repository>
</repositories>
Maven Dependency
<dependencies>
    <!-- CooldownsX -->
    <dependency>
        <groupId>com.github.sirblobman.plugin.cooldowns</groupId>
        <artifactId>cooldowns-api</artifactId>
        <version>5.1.0-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

API Usage

To use the API you should make sure that CooldownsX is enabled on the server first.
The main things you need to know are how to get the plugin instance and how to get data for a player:

Example Code
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;

import com.github.sirblobman.plugin.cooldown.CooldownsX;
import com.github.sirblobman.plugin.cooldown.Cooldown;
import com.github.sirblobman.plugin.cooldown.PlayerCooldown;
import com.github.sirblobman.plugin.cooldown.PlayerCooldownManager;

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;

public final class CooldownHelper {
    public @NotNull CooldownsX getCooldownsX() {
        PluginManager pluginManager = Bukkit.getPluginManager();
        Plugin plugin = pluginManager.getPlugin("CooldownsX");
        return (CooldownsX) plugin;
    }

    public @NotNull PlayerCooldown getData(@NotNull Player player) {
        CooldownsX plugin = getCooldownsX();
        PlayerCooldownManager manager = plugin.getCooldownManager();
        return manager.getData(player);
    }
    
    public @Nullable Cooldown getCooldownSettings(@NotNull String id) {
        CooldownsX plugin = getCooldownsX();
        PlayerCooldownManager manager = plugin.getCooldownManager();
        return manager.getCooldownSettings(id);
    }

    /*
     *  You can check the expiration time of a specific cooldown for a player:
     */
    public long getCooldownExpireMillis(@NotNull Player player, @NotNull String id) {
        Cooldown cooldown = getCooldownSettings(id);
        if (cooldown == null) {
            return 0L;
        }

        PlayerCooldown data = getData(player);
        return data.getCooldownExpireTime(cooldown);
    }
}

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.