Esempio n. 1
0
 /**
  * Reloads the gun
  *
  * @param player Player to reload the gun
  */
 public void reload(final Player player) {
   if (ammo <= 0) {
     return;
   }
   reloading = true;
   // SpoutGUI.showReloading(player, this);
   RushMe.getInstance()
       .getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           RushMe.getInstance(),
           new Runnable() {
             public void run() {
               if (!(reloading)) {
                 return;
               }
               if (ammo - maxClipSize >= 0) {
                 int lastLoadedInClip = loadedInClip;
                 loadedInClip = maxClipSize;
                 ammo = ammo - (maxClipSize - lastLoadedInClip);
               } else {
                 loadedInClip = ammo;
                 ammo = 0;
               }
               reloading = false;
               SpoutGUI.getHudOf(player).updateHUD();
             }
           },
           reloadTime);
 }
Esempio n. 2
0
  /**
   * Creates a gun
   *
   * @param name Name of gun
   * @param texture Online texture URL
   * @param reloadTime Time between reloads
   * @param autoReload If gun auto reloads
   * @param maxClipSize Max clip size
   * @param maxAmmo Max ammo of gun
   * @param timeBetweenFire Time between firing
   * @param bulletsExplode If Bullets explode
   * @param explosionSize Size of explosion (Can be null if bullets don't explode)
   * @param entityDamageDistance Distance in which entities get damaged by explosions (Can be null
   *     if bullets don't explode)
   * @param headshotDamage Damage of a head shot (Can be null if bullets explode)
   * @param bodyDamage Damage of a body shot (Can be null if bullets explode)
   * @param recoilBack Recoil moving the player back (Negative if the player should move forward)
   * @param recoilVertical Recoil moving the player's gun up (Negative if the player's gun should go
   *     down)
   * @param recoilHorizontal Recoil moving the player's gun to the right (Negative if the player's
   *     gun should go to the left)
   */
  protected Gun(
      String name,
      String texture,
      Integer reloadTime,
      Boolean autoReload,
      Integer maxClipSize,
      Integer maxAmmo,
      Double timeBetweenFire,
      Boolean bulletsExplode,
      Float explosionSize,
      Double entityDamageDistance,
      Integer headshotDamage,
      Integer bodyDamage,
      Double recoilBack,
      Float recoilVertical,
      Float recoilHorizontal) {
    super(RushMe.getInstance(), name, texture);

    this.reloadTime = reloadTime;
    this.maxClipSize = maxClipSize;
    this.loadedInClip = maxClipSize;
    this.autoReload = autoReload;
    this.maxAmmo = maxAmmo;
    this.ammo = maxAmmo;
    this.timeBetweenFire = timeBetweenFire;
    this.bulletsExplode = bulletsExplode;
    this.explosionSize = explosionSize;
    this.entityDamageDistance = entityDamageDistance;
    this.headshotDamage = headshotDamage;
    this.bodyDamage = bodyDamage;
    this.recoilBack = recoilBack;
    this.recoilVertical = recoilVertical;
    this.recoilHorizontal = recoilHorizontal;
  }
Esempio n. 3
0
 @Override
 public void read(SpoutInputStream stream) {
   name = stream.readString();
   shortName = stream.readString();
   typeInt = stream.readInt();
   try {
     type = GrenadeType.getByCode(typeInt);
   } catch (Exception e) {
     RushMe.getInstance().getLogger().log(e, "PacketGrenadeUpdate was sent wrongly!");
   }
   amount = stream.readInt();
   startAmount = stream.readInt();
   explosionSize = stream.readInt();
   timeBeforeExplosion = stream.readInt();
   damage = stream.readInt();
   stunTime = stream.readInt();
   uuid = stream.readUUID();
   RushMe.getInstance().getLogger().debugLog(Level.INFO, "Read PacketGrenadeUpdate.  Atributes:");
   RushMe.getInstance()
       .getLogger()
       .debugLog(
           Level.INFO,
           "Name = "
               + name
               + ";ShortName = "
               + shortName
               + ";TypeInt = "
               + typeInt
               + ";Type = "
               + type
               + ";Amount = "
               + amount
               + ";StartAmount = "
               + startAmount
               + ";ExplosionSize = "
               + explosionSize
               + ";TimeBeforeExplosion = "
               + timeBeforeExplosion
               + ";Damage = "
               + damage
               + ";StunTime = "
               + stunTime
               + ";UUID = "
               + uuid);
 }
Esempio n. 4
0
 @Override
 public void write(SpoutOutputStream stream) {
   stream.writeString(name);
   stream.writeString(shortName);
   stream.writeInt(typeInt);
   stream.writeInt(amount);
   stream.writeInt(startAmount);
   stream.writeInt(explosionSize);
   stream.writeInt(timeBeforeExplosion);
   stream.writeInt(damage);
   stream.writeInt(stunTime);
   stream.writeUUID(uuid);
   RushMe.getInstance().getLogger().debugLog(Level.INFO, "Read PacketGrenadeUpdate.  Atributes:");
   RushMe.getInstance()
       .getLogger()
       .debugLog(
           Level.INFO,
           "Name = "
               + name
               + ";ShortName = "
               + shortName
               + ";TypeInt = "
               + typeInt
               + ";Type = "
               + type
               + ";Amount = "
               + amount
               + ";StartAmount = "
               + startAmount
               + ";ExplosionSize = "
               + explosionSize
               + ";TimeBeforeExplosion = "
               + timeBeforeExplosion
               + ";Damage = "
               + damage
               + ";StunTime = "
               + stunTime
               + ";UUID = "
               + uuid);
 }
Esempio n. 5
0
  protected Grenade(
      String name,
      String texture,
      GrenadeType type,
      Integer defaultAmount,
      Integer startAmount,
      Integer explosionSize,
      Integer timeBeforeExplosion,
      Integer damage,
      Integer stunTime) {
    super(RushMe.getInstance(), name, texture);

    this.type = type;
    this.defaultAmount = defaultAmount;
    this.startAmount = startAmount;
    this.explosionSize = explosionSize;
    this.timeBeforeExplosion = timeBeforeExplosion;
    this.damage = damage;
    this.stunTime = stunTime;
  }
Esempio n. 6
0
 @Override
 public void run(SpoutPlayer sp) {
   RushMe.getInstance()
       .getLogger()
       .debugLog(Level.INFO, "Running PacketGrenadeUpdate for " + sp.getName());
   Grenade grenade = GrenadeManager.getGrenade(name);
   if (grenade == null) {
     grenade =
         GrenadeManager.createGrenade(
             name,
             null,
             shortName,
             type,
             startAmount,
             explosionSize,
             timeBeforeExplosion,
             damage,
             stunTime,
             uuid);
   }
   grenade.setAmount(amount);
 }
Esempio n. 7
0
 public FlagBase() {
   super(RushMe.getInstance(), "FlagBase", true, new FlagBaseBlockDesign());
 }