Guest User

Untitled

a guest
Feb 18th, 2020
76
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static void Start(Player p, String n){
  2. if (!p.hasPermission(ppp)){
  3. p.sendMessage(ChatColor.translateAlternateColorCodes('&', Getter.getconfig("Virksomhed.IngenPermission")));
  4. return;
  5. }
  6. Main.openConnection();
  7. try {
  8. if (Main.playerdataContainsStringVirk(n)) {
  9. p.sendMessage(ChatColor.translateAlternateColorCodes('&', Getter.getconfig("Virksomhed.DenVirksomhedEkistere")));
  10. }else if (Main.playerdataContainsString(p.getUniqueId()+"")) {
  11. PreparedStatement sql = Main.connection.prepareStatement("SELECT virksomhed FROM `"+Getter.getconfig("Friheden.Sql.TABLE2")+"` WHERE player=?;");
  12. sql.setString(1, p.getUniqueId()+"");
  13. ResultSet result = sql.executeQuery();
  14. result.next();
  15. String s = result.getString("virksomhed");
  16. sql.close();
  17. result.close();
  18. p.sendMessage(ChatColor.translateAlternateColorCodes('&', Getter.getconfig("Virksomhed.AlleredeIVirksomhed").replace("%virksomhed%",s)));
  19. }else{
  20. CheckUUID(p);
  21. PreparedStatement newPlayer = Main.connection.prepareStatement("INSERT INTO `"+Getter.getconfig("Friheden.Sql.TABLE2")+"` values(?,?,?,?);");
  22. newPlayer.setString(1, p.getUniqueId()+"");
  23. newPlayer.setString(2, n);
  24. newPlayer.setInt(3, 0);
  25. newPlayer.setInt(4, 0);
  26. newPlayer.execute();
  27. newPlayer.close();
  28.  
  29. int i = 1;
  30. String kræves = "";
  31. while (!Getter.getconfig("Virksomhed.SellItems.Items."+i).equalsIgnoreCase("fejl")){
  32.  
  33. String[] s2 = Getter.getconfig("Virksomhed.SellItems.Items."+i+".KraevesForOverskud").split("-");
  34. Random r2 = new Random();
  35. long Low2 = Long.parseLong(s2[0]);
  36. long High2 = Long.parseLong(s2[1]);
  37. double Result2 = r2.nextInt((int) (High2-Low2)) + Low2;
  38. double Result21=Result2*1*Double.parseDouble(Getter.getconfig("Virksomhed.Levels.1.Multiplyer"));
  39. if (kræves.equalsIgnoreCase("")){
  40. kræves = (int)Result21+" "+Getter.getconfig("Virksomhed.SellItems.Items."+i+".Material")+" "+i;
  41. }else{
  42. kræves = kræves + "," + (int)Result21+" "+Getter.getconfig("Virksomhed.SellItems.Items."+i+".Material")+" "+i;
  43. }
  44. i++;
  45. }
  46.  
  47. PreparedStatement newPlayer2 = Main.connection.prepareStatement("INSERT INTO `"+Getter.getconfig("Friheden.Sql.TABLE")+"` values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
  48. newPlayer2.setString(1, n);
  49. newPlayer2.setString(2, p.getUniqueId()+"");
  50. newPlayer2.setString(3, p.getName());
  51. newPlayer2.setString(4, p.getUniqueId()+"");
  52. newPlayer2.setInt(5, 0);
  53. newPlayer2.setInt(6, 1); //level
  54. newPlayer2.setInt(7, 0);
  55. newPlayer2.setInt(8, 0);
  56. newPlayer2.setInt(9, 1); //antal spillere
  57. newPlayer2.setInt(10, 0);
  58. newPlayer2.setInt(11, Integer.parseInt(Getter.getconfig("Virksomhed.IkBeskeder.StartProcent"))); //Procent
  59. newPlayer2.setString(12, "");
  60. newPlayer2.setString(13, "");
  61. newPlayer2.setInt(14, 0);
  62. newPlayer2.setString(15, kræves);
  63. newPlayer2.setInt(16, 1);
  64. newPlayer2.execute();
  65. newPlayer2.close();
  66.  
  67. p.sendMessage(ChatColor.translateAlternateColorCodes('&', Getter.getconfig("Virksomhed.OprettetVirksomhed").replace("%virksomhed%",n)));
  68. }
  69. } catch (Exception e2) {
  70. e2.printStackTrace();
  71. } finally{
  72. Main.closeConnection();
  73. }
  74. }
RAW Paste Data