Gun Plugin

Discussion in 'Plugin Development' started by ostylk, Apr 11, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ostylk

    Hey,
    I want to make a gun plugin with snipers some shotguns and so on but how can I distinguish between sniper and shotgun they both shot snowballs?When I check ItemInHand its not good because you can cheat then(automatic sniper)?Sorry for really bad english this time :D!
     
  2. Offline

    xXDJONESXx

    Hey, I've done something like this before, what you need to do is assign the entity that is thrown with some data.
    I suggest using a HashMap for this one.
    When the projectile hits the ground you can fetch the data with firedBullets.get(event.getEntity);
     
  3. Offline

    iZanax

    There are 2 approaches,

    # Map<UUID,String>
    .put(UUID, value);
    * UUID = the ID of the bullet (bullet.getUniqueId())
    * String = The value for the bullet, in your case Shotgun or Sniper

    # MetaData
    bullet.setMetaData(String, new FixedMetadataValue(plugin, value);
    * String = the name to retrieve the value also known as "key"
    * plugin = main instance of the plugin (class which extends javaplugin)
    * value = The value for the bullet, in your case Shotgun or Sniper (Can be String)

    Please search on MetaData and bukkit or Map if u don't know how these work.
    Good luck,
    Zanax
     
Thread Status:
Not open for further replies.

Share This Page