SmashHit - Async hit detection 1.3.3

Free async hit pre-processing for Bukkit

  1. SkorrloreGaming
    Native Minecraft Version:
    Legacy (< 1.13)
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    • 1.10
    • 1.11
    • 1.12
    • 1.13
    Source Code:
    https://github.com/Speentie8081/SmashHit
    Contributors:
    Speentie8081, thekeenant, kukelekuuk00, frash23
    SmashHit
    Free async hit pre-processor for bukkit

    This project was originally developed by frash23, but has been developed further by other developers including myself. This means that you should report issues encountered with this fork of the project to my github repository instead of the original.

    SmashHit is a asynchronous hit processing agent that replaces the build-in one hard-coded into Bukkit, this allows users of this plugin to control the max clicks per second and attack range for the players. On a side note, this plugin is very experimental even in this stage, and may not work as intended.

    Changes and additions:
    • Added complete 1.11, 1.12, and 1.13 support
    • Resolved 1.7 incompatibility issues
    • Resolve a bug causing spriting to be less effective
    • Completely change most of the plugin messages
    • Add /smashhit debug into the help dialog
    • Resolve a bug causing two damage events to be sent
    • ... among other changes
    What's wrong with the default hit processor?
    There's nothing wrong with it, but it can be improved.

    To my knowledge, there are two deficiencies:
    • Hits are processed in the current tick stack, not on demand *
    • There is a (pretty low) max clicks-per-second (aka CPS) limit hardcoded into the server
    * = This is the main focus of the plugin and is explained in the What does async hit pre-processing mean? section

    The CPS limit is automatically bypassed when we process hits on our own. SmashHit's configuration allows you to set your own preferred CPS. The CPS limit in SmashHit will keep counting a player's CPS even if the limit is reached, however they will be denied further hits - this way a hacker spamming clicks will lock himself out of combat.

    What does async hit pre-processing mean?
    The Minecraft server has a "stack" of operations to carry out, called the "tick stack". When new operations have to be carried out, they are added to the tick stack. The tick stack is processed 20 times every second. That means any operation can unnecessarily take an additional 50ms! This can be felt by some people in PvP, which is what this plugin aims to solve. Some big PvP servers already deploy a similar feature.

    SmashHit listens for hit requests and processes them independent of the tick stack! Actual damage is still synchronized to the Minecraft server (as damaging players isn't thread-safe), but the hit animation and hit registering is carried out by SmashHit - this means you can hit a player as frequently as the network can handle with zero delay. SmashHit, of course, has an inbuilt configurable rate limiter.

    API
    Since async code works differently from regular code, we need a separate event for cancelling SmashHit's pre-processing. For this, the "AsyncPreDamageEvent" is provided, which you can hook into. Here is an example for cancelling hits in protected WorldGuard regions:

    Code (Java):
    class WorldGuardListener implements Listener {
       WorldGuardPlugin wg = (WorldGuardPlugin)Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");

       @EventHandler
       public void onAsyncPreDamageEvent(AsyncPreDamageEvent e) {
           Player damager = e.getDamager();
           Damageable entity = e.getEntity();
           World world = damager.getWorld();
           RegionManager rgMgr = wg.getRegionManager(world);

           boolean damagerCanDamage = rgMgr.getApplicableRegions(damager.getLocation()).testState( wg.wrapPlayer(damager), DefaultFlag.PVP)
           boolean entityIsDamageable = rgMgr.getApplicableRegions(entity.getLocation()).testState( wg.wrapPlayer(damager), DefaultFlag.PVP)
           if(!damagerCanDamage || !entityIsDamageable) {
               e.setCancelled(true);
           }
       }

    }
    Remember that your listener is invoked asynchronously and you can NOT safely write to the Bukkit API
    Aoro likes this.

Recent Reviews

  1. Flapppie
    Flapppie
    3/5,
    Version: 1.2.5
    Hit detection does not work, could it be my plugins? i got it to load in but it doesnt let me hit people.
    1. SkorrloreGaming
      Author's Response
  2. RekoNation
    RekoNation
    5/5,
    Version: 1.2.5
    amazing but fire aspect is half broke, sometimes works, sometimes doesnt..



























    .
    1. SkorrloreGaming
      Author's Response
  3. BadSkid
    BadSkid
    5/5,
    Version: 1.2.5
    Best hit detection plugin out there... plus its free, the original smashhit didnt work on my server even if i used 1.8 and this is great! thanks
    1. SkorrloreGaming
      Author's Response
      Thanks, if you find any bugs please report them on GitHub.