Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.4 kB
2
Indexable
Never
package ballistickemu.Lobby.handlers;

import ballistickemu.Tools.DatabaseTools;
import ballistickemu.Types.StickClient;
import java.io.PrintStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;


public class GiveTicketHandler
{
  public static void HandlePacket(StickClient paramStickClient, String paramString)
  {
    try
    {
      ArrayList localArrayList = new ArrayList();
      localArrayList.add(Integer.valueOf(20));
      localArrayList.add(Integer.valueOf(25));
      localArrayList.add(Integer.valueOf(30));
      localArrayList.add(Integer.valueOf(35));
      localArrayList.add(Integer.valueOf(40));
      localArrayList.add(Integer.valueOf(55));
      localArrayList.add(Integer.valueOf(60));
      localArrayList.add(Integer.valueOf(75));
      localArrayList.add(Integer.valueOf(100));
      localArrayList.add(Integer.valueOf(250));
      localArrayList.add(Integer.valueOf(500));
      localArrayList.add(Integer.valueOf(999));
      localArrayList.add(Integer.valueOf(1500));
      localArrayList.add(Integer.valueOf(5000));
      Random localRandom = new Random();
      int i = ((Integer)localArrayList.get(new Random().nextInt(localArrayList.size()))).intValue();
      DatabaseTools.dbConnect();
      PreparedStatement localPreparedStatement1 = DatabaseTools.getDbConnection().prepareStatement("UPDATE users SET cash = ? + ? WHERE UID = ?");
      localPreparedStatement1.setInt(1, paramStickClient.getCash());
      localPreparedStatement1.setInt(2, i);
      localPreparedStatement1.setInt(3, paramStickClient.getDbID());
      localPreparedStatement1.executeUpdate();
      if (i == 20)
      {
        paramStickClient.getPrize("0");
      }
      else if (i == 25)
      {
        paramStickClient.getPrize("1");
      }
      else if (i == 30)
      {
        paramStickClient.getPrize("2");
      }
      else if (i == 35)
      {
        paramStickClient.getPrize("3");
      }
      else if (i == 40)
      {
        paramStickClient.getPrize("4");
      }
      else if (i == 55)
      {
        paramStickClient.getPrize("5");
      }
      else if (i == 60)
      {
        paramStickClient.getPrize("6");
      }
      else if (i == 75)
      {
        paramStickClient.getPrize("7");
      }
      else if (i == 100)
      {
        paramStickClient.getPrize("8");
      }
      else if (i == 250)
      {
        paramStickClient.getPrize("9");
      }
      else if (i == 500)
      {
        paramStickClient.getPrize("10");
      }
      else if (i == 999)
      {
        paramStickClient.getPrize("11");
      }
      else if (i == 1500)
      {
        paramStickClient.getPrize("12");
      }
      else if (i == 5000)
      {
        paramStickClient.getPrize("13");
      }
      PreparedStatement localPreparedStatement2 = DatabaseTools.getDbConnection().prepareStatement("UPDATE users SET ticket = 0 WHERE UID = ?");
      localPreparedStatement2.setInt(1, paramStickClient.getDbID());
      localPreparedStatement2.executeUpdate();
    }
    catch (Exception localException)
    {
      paramStickClient.writeAnnounce("There was an error collecting your creds, please try again later");
      System.out.println("error: " + localException);
      return;
    }
  }
}