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);
    }
}

cooldownsx's People

Contributors

dependabot[bot] avatar olivoz avatar sirblobman avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cooldownsx's Issues

Error 1.19.4

I am using paperspigot 1.19.4 b521
with
BlueSlimeCore-2.9.0.347
CooldownsX-5.1.0.220
and it gives this error and does not work
[03:55:02] [Server thread/ERROR]: [ModernPluginLoadingStrategy] Could not load plugin 'CooldownsX-5.1.0.220.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.NoClassDefFoundError: com/github/sirblobman/api/bstats/charts/CustomChart
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:127) ~[paper-1.19.4.jar:git-Paper-521]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:35) ~[paper-1.19.4.jar:git-Paper-521]
at io.papermc.paper.plugin.entrypoint.strategy.modern.ModernPluginLoadingStrategy.loadProviders(ModernPluginLoadingStrategy.java:116) ~[paper-1.19.4.jar:git-Paper-521]
at io.papermc.paper.plugin.storage.SimpleProviderStorage.enter(SimpleProviderStorage.java:39) ~[paper-1.19.4.jar:git-Paper-521]
at io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.enter(LaunchEntryPointHandler.java:36) ~[paper-1.19.4.jar:git-Paper-521]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.loadPlugins(CraftServer.java:423) ~[paper-1.19.4.jar:git-Paper-521]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:273) ~[paper-1.19.4.jar:git-Paper-521]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1104) ~[paper-1.19.4.jar:git-Paper-521]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-521]
at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: java.lang.NoClassDefFoundError: com/github/sirblobman/api/bstats/charts/CustomChart
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:495) ~[?:?]
at java.lang.Class.forName(Class.java:474) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.(PluginClassLoader.java:76) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[paper-1.19.4.jar:git-Paper-521]
... 9 more
Caused by: java.lang.ClassNotFoundException: com.github.sirblobman.api.bstats.charts.CustomChart
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:183) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:150) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at java.lang.Class.forName0(Native Method) ~[?:?]
at java.lang.Class.forName(Class.java:495) ~[?:?]
at java.lang.Class.forName(Class.java:474) ~[?:?]
at org.bukkit.plugin.java.PluginClassLoader.(PluginClassLoader.java:76) ~[paper-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProvider.createInstance(SpigotPluginProvider.java:123) ~[paper-1.19.4.jar:git-Paper-521]
... 9 more

Update 1.15.1

Hello !
When I use your plugin on 1.15.1, there is this error spamming the console.

[SirBlobmanAPI] Could not find valid NMS handler for '1_15_R1'. Using fallback handler...

EnderPearl-Coolddown version 3.3
Server: git-Paper-33 (MC 1.15.1)

Suggestion: Multiple cooldowns in the actionbar

Would be so cool if you could add more cooldowns in one actionbar, so you could have it like the following: Pearl: Gapple: Combat: (Would be even cooler if you could make it link with combatlogx so i can also add the combattime with it. :) )

Health potions do not trigger cooldown

Using health potions does not trigger a cooldown under:

  cooldown-type: POTION
  potion-effect:
    - HEAL
  material:
    - SPLASH_POTION
    - LINGERING_POTION
    - POTION

If this cooldown is triggered by other potions, it will add a cooldown even for health potions, but using health potions never activates it.
This would be important to fix because currently it is not possible to make an 'all-in-one' cooldown for potions, and health potions are the most important one to have a cooldown for PvP wise.

Only the POTION_THROW option seems to trigger health potion cooldowns properly, but this only applies to Splash Potions, which is not enough as players would just use normal potions then.

1.16 version

Actually this plugin doesn't work very well on 1.16, actionbar spam the chat

Suggestion: Add shared cooldown for all potion types

It currently seems to separate basic potions / splash potions / lingering potions into different cooldowns, allowing players to avoid a cooldown by switching potion type.

Could a way to make all potion types share the same cooldown be added?

API Version

Hello !
Can you add an API Version in plugin.yml to prevent this please ?

Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
Legacy plugin EnderpearlCooldown v4.0.0 does not specify an api-version.

Beacons & Tipped Arrows trigger potion cooldowns

If you have for example, Regeneration effect causing Potion cooldowns, then shooting an enemy with a Tipped Arrow will trigger that cooldown for them.
This is very exploitable in PvP, as you can prevent your enemies from using said potions by just shooting them with similar effect, or depending on cooldown setup, even disable all potions.

Tipped Arrows should not trigger cooldowns the same way, as their effects are very short compared to real potions.
Could they please be disabled from even being counted for POTION / POTION_THROW cooldown types?

Enchanted Gapples & Gapples

Hi,

Could you add the support for Enchanted Golden Apples & Golden Apples?

This is pretty useless to add a cooldown to all Golden apples.

Best regards,

Potion cooldown does not apply if no effect is gained

Under cooldown-type: POTION, the cooldown is never applied if you do not gain the effect.
What this means is that you can throw potions endlessly at your friends, as long as you do not gain the effect.
It actually triggers the cooldown for the person you throw it on, but not the thrower, which makes the cooldown type unreliable and exploitable.

  cooldown-type: POTION
  potion-effect:
    - INCREASE_DAMAGE
    - HEAL
  material:
    - SPLASH_POTION
    - LINGERING_POTION

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.