Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Hooking into CrackShot

Shampaggon edited this page · 4 revisions

░ CrackShot Utility Functions

Getting started

The CSUtility class offers a few functions that some may find useful. In order to access them:

  • Import CrackShot into your libraries.
  • Import the CSUtility class: import com.shampaggon.crackshot.CSUtility;
  • Create an instance of CSUtility and assign it to a field.

You will now be able to use the functions described below.

Spawning weapons

You can give CrackShot weapons directly to players using the function:

giveWeapon(Player player, String weaponName, int amount)
  • player - the player who will receive the item(s).
  • weaponName - the weapon title of the weapon the player will receive.
  • amount - the amount the player will receive.

No weapon will be given if the provided weapon title does not exist in the configuration, or if the player's inventory is full.

Generating weapons

You can generate a CrackShot weapon using the function:

generateWeapon(String weaponName)
  • weaponName - the weapon title of the weapon you wish to generate.

Returns the ItemStack of the given weapon or null if the given weapon does not exist in the configuration.

Generating explosions

You can generate a CrackShot explosion at a given location using the function:

generateExplosion(Player player, Location loc, String weaponTitle)
  • player - the player who will be identified as the causer of the explosion.
  • loc - the location the explosion will be generated at.
  • weaponTitle - the weapon title that the explosion will use.

Spawning mines

You can spawn a CrackShot mine at a given location using the function:

spawnMine(Player player, Location loc, String weaponTitle)
  • player - the player who will be identified as the placer of the mine.
  • loc - the location the mine will be spawned at.
  • weaponTitle - the weapon title that the mine will use.

CrackShot projectiles

You can convert ordinary projectiles into CrackShot projectiles. Applies only to snowballs, eggs, arrows, fireballs and wither skulls.

setProjectile(Player player, Projectile proj, String weaponTitle)
  • player - the player who will be identified as the shooter of the projectile. Cannot be null.
  • proj - the projectile to convert.
  • weaponTitle - the weapon title of the converted projectile.

Getting the weapon title of an item

You can get the weapon title of an item. Returns the weapon title of the item as a String. Returns null if one could not be found.

getWeaponTitle(ItemStack item)
  • item - the item you would like to identify. Cannot be null.

Getting the weapon title of a projectile

You can get the weapon title of a projectile. Returns the weapon title of the projectile as a String. Returns null if one could not be found.

getWeaponTitle(Projectile proj)
  • proj - the projectile you would like to identify. Cannot be null.

Getting the weapon title of a TNTPrimed entity

You can get the weapon title of a TNTPrimed entity. Returns the weapon title of the entity as a String. Returns null if one could not be found.

getWeaponTitle(TNTPrimed tnt)
  • tnt - the TNTPrimed entity you would like to identify. Cannot be null.

░ CrackShot Events

WeaponDamageEntityEvent

This event is called when an entity is damaged by a melee attack, projectile or explosion caused by a CrackShot weapon.

  • Methods:
    • getDamager() - Returns the damager as an Entity, or null if the damage was caused by an energy/splash projectile or a melee attack.
      • This entity could be of the type:
        • Projectile, if the damage was caused by a projectile (direct impact).
        • TNTPrimed, if the damage was caused by an explosion.
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getVictim() - Returns the victim as an Entity.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • getDamage() - Returns the amount of damage caused by this event.
    • isBackstab() - Checks if the event was a backstab.
    • isCancelled() - Gets the cancellation state of this event.
    • isCritical() - Checks if the event was a critical hit.
    • isHeadshot() - Checks if the event was a headshot.
    • setCancelled() - Sets the cancellation state of this event.
    • setDamage() - Sets the amount of damage caused by this event.

WeaponExplodeEvent

This event is called whenever a CrackShot weapon creates an explosion, splits or calls an airstrike.

  • Methods:
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getLocation() - Returns the Location of the explosion.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • isSplit() - Checks if the event was a cluster bomb split.
    • isAirstrike() - Checks if the event was an airstrike call.

WeaponHitBlockEvent

This event is called whenever a CrackShot projectile strikes a solid block. Applies only to arrows, eggs and snowballs.

  • Methods:
    • getAirBlock() - Returns the Block that the projectile traveled through before impact.
    • getBlock() - Returns the Block that the projectile struck.
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getProjectile() - Returns the fired projectile as an Entity, or null if the projectile is of the energy type.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.

WeaponPlaceMineEvent

This event is called whenever a CrackShot landmine is placed.

  • Methods:
    • getPlayer() - Returns the Player that placed the mine.
    • getMine() - Returns the placed mine as an Entity.
    • getWeaponTitle() - Returns the weapon title of the placed mine.

WeaponPreShootEvent

This event is called right before a weapon launches any projectiles.

  • Methods:
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getBulletSpread() - Returns the bullet spread value to be used in this event.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • isCancelled() - Gets the cancellation state of this event.
    • setBulletSpread() - Sets the bullet spread value to be used in this event.
    • setCancelled() - Sets the cancellation state of this event.

WeaponPrepareShootEvent

This event is called at the very start of the shooting process. Its intention is to provide finer control over which players are allowed to use particular weapons.

  • Methods:
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • isCancelled() - Gets the cancellation state of this event.
    • setCancelled() - Sets the cancellation state of this event.

WeaponReloadEvent

This event is called whenever a player reloads a weapon. The reload speed can be scaled, and is a double ranging from 0-1, where 0 is instantaneous and 1 is normal.

  • Methods:
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getReloadSpeed() - Gets the reload speed of this event.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • setReloadSpeed() - Sets the cancellation state of this event.

WeaponScopeEvent

This event is called whenever a player zooms in or out with a CrackShot weapon.

  • Methods:
    • getPlayer() - Returns the Player involved in this event.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • isZoomIn() - Checks if the player was zooming in.

WeaponShootEvent

This event is called when a player uses a CrackShot weapon to fire any of the 9 supported projectiles, or when an item bomb is thrown.

  • Methods:
    • getPlayer() - Returns the Player involved in this event.
    • getProjectile() - Returns the fired projectile as an Entity, or null if the projectile is of the energy type.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.

WeaponTriggerEvent

This event is called whenever a landmine is triggered by an entity walking through it.

  • Methods:
    • getPlayer() - Returns the Player that caused this event, or null if the player is offline.
    • getVictim() - Returns the victim as a LivingEntity.
    • getWeaponTitle() - Returns the weapon title of the weapon involved in this event.
    • isCancelled() - Gets the cancellation state of this event.
    • setCancelled() - Sets the cancellation state of this event.
Something went wrong with that request. Please try again.