OpenJS-docs
Download plugin
  • Overview
    • Welcome
  • Getting Started
    • Installing the plugin
    • Configuration file
    • Commands
    • Creating scripts
  • OpenJS Components
    • Feature Flags
    • Managing scripts within scripts
    • Sharing variables between scripts
    • Custom Commands
    • Using PlaceHolderApi
    • Listening and cancelling events
    • Custom events
    • Loading and saving data
    • Logging in console
    • Scheduling
    • Java imports
  • Example Scripts
    • spawn hit stand command
    • Knockbackstick command
    • No hit-cooldown script
    • NoBlockPlacing script
    • Saving Player data script
    • running code asynchronously
    • WhileTrue do script
Powered by GitBook
On this page
  1. Example Scripts

No hit-cooldown script

nohitcooldown.js
var Attribute = Java.type("org.bukkit.attribute.Attribute");
var Bukkit = org.bukkit.Bukkit;

registerEvent("org.bukkit.event.player.PlayerJoinEvent", {
    handleEvent: function(event) {
        var player = event.getPlayer();
        var attributeInstance = player.getAttribute(Attribute.ATTACK_SPEED);

        if (attributeInstance != null) {
            attributeInstance.setBaseValue(1024.0); // disables cooldown UI
            log.info("Disabled hit cooldown for player: " + player.getName());
        } else {
            log.warning("Attribute instance was null for player: " + player.getName());
        }
    }
});

registerEvent("org.bukkit.event.entity.EntityDamageByEntityEvent", {
    handleEvent: function(event) {
        var e = event.getEntity();        
        if (e && e.setMaximumNoDamageTicks) {
            // allows hit-damage each tick on the target
            e.setMaximumNoDamageTicks(1);
            e.setNoDamageTicks(1);
        }
    }
});
PreviousKnockbackstick commandNextNoBlockPlacing script

Last updated 16 hours ago