Advertisement
Guest User

Untitled

a guest
Jan 20th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 20.78 KB | None | 0 0
  1. package MySQL;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8.  
  9. import org.bukkit.entity.Player;
  10.  
  11. import main.Core;
  12.  
  13. public class MySQL {
  14.  
  15.     public static String host = Core.cfg.getString("MySQL.Host");
  16.     public static String port = Core.cfg.getString("MySQL.Port");
  17.     public static String database = Core.cfg.getString("MySQL.Datenbank");
  18.     public static String username = Core.cfg.getString("MySQL.Benutzername");
  19.     public static String password = Core.cfg.getString("MySQL.Passwort");
  20.     public static String host2 = Core.cfg.getString("Inventory.MySQL.Host");
  21.     public static String port2 = Core.cfg.getString("Inventory.MySQL.Port");
  22.     public static String database2 = Core.cfg.getString("Inventory.MySQL.Datenbank");
  23.     public static String username2 = Core.cfg.getString("Inventory.MySQL.Benutzername");
  24.     public static String password2 = Core.cfg.getString("Inventory.MySQL.Passwort");
  25.     public static Connection connection;
  26.     public static Connection connection2;
  27.  
  28.     public static Connection getConnection() {
  29.         return connection;
  30.     }
  31.    
  32.     public static Connection getConnection2() {
  33.         return connection2;
  34.     }
  35.    
  36.     public static boolean isConnected() {
  37.         return connection != null;
  38.     }
  39.    
  40.     public static boolean isConnected2() {
  41.         return connection2 != null;
  42.     }
  43.    
  44.     public static void connect() {
  45.         if (!isConnected()) {
  46.             try {
  47.                 connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  48.             } catch (SQLException e) {
  49.                 e.printStackTrace();
  50.             }
  51.         }
  52.     }
  53.    
  54.     public static void connect2() {
  55.         if (!isConnected2()) {
  56.             try {
  57.                 connection2 = DriverManager.getConnection("jdbc:mysql://" + host2 + ":" + port2 + "/" + database2, username2, password2);
  58.             } catch (SQLException e) {
  59.                 e.printStackTrace();
  60.             }
  61.         }
  62.     }
  63.    
  64.     public static void disconnect() {
  65.         if (isConnected()) {
  66.             try {
  67.                 connection.close();
  68.             } catch (SQLException e) {
  69.                 e.printStackTrace();
  70.             }
  71.         }
  72.     }
  73.    
  74.     public static void disconnect2() {
  75.         if (isConnected2()) {
  76.             try {
  77.                 connection2.close();
  78.             } catch (SQLException e) {
  79.                 e.printStackTrace();
  80.             }
  81.         }
  82.     }
  83.    
  84.     public static void createTableIfNotExists() {
  85.         if (isConnected()) {
  86.             try {
  87.                 PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS 1vs1 (NAME VARCHAR(100), UUID VARCHAR(100), KILLS INT(100), DEATHS INT(100), POINTS INT(100), WINS INT(100), LOSES INT(100))");
  88.                 ps.executeUpdate();
  89.                 ps.close();
  90.             } catch (SQLException ex) {
  91.                 ex.printStackTrace();
  92.             }
  93.         }
  94.     }
  95.    
  96.     public static void createTableIfNotExists2() {
  97.         if (isConnected2()) {
  98.             try {
  99.                 PreparedStatement ps = getConnection2().prepareStatement("CREATE TABLE IF NOT EXISTS 1vs1 (NAME VARCHAR(100), UUID VARCHAR(100), INV VARCHAR(10000))");
  100.                 ps.executeUpdate();
  101.                 ps.close();
  102.             } catch (SQLException ex) {
  103.                 ex.printStackTrace();
  104.             }
  105.         }
  106.     }
  107.    
  108.     public static boolean isUserExisting(Player p) {
  109.         try {
  110.             PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  111.             ps.setString(1, p.getUniqueId().toString());
  112.             ResultSet result = ps.executeQuery();
  113.             boolean user = result.next();
  114.             result.close();
  115.             ps.close();
  116.             return user;
  117.         } catch (Exception ex) {
  118.             ex.printStackTrace();
  119.         }
  120.         return false;
  121.     }
  122.    
  123.     public static boolean isUserExisting(String player) {
  124.         try {
  125.             PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  126.             ps.setString(1, player);
  127.             ResultSet result = ps.executeQuery();
  128.             boolean user = result.next();
  129.             result.close();
  130.             ps.close();
  131.             return user;
  132.         } catch (Exception ex) {
  133.             ex.printStackTrace();
  134.         }
  135.         return false;
  136.     }
  137.    
  138.     public static boolean isUserInvExisting(Player p) {
  139.         try {
  140.             PreparedStatement ps = connection2.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  141.             ps.setString(1, p.getUniqueId().toString());
  142.             ResultSet result = ps.executeQuery();
  143.             boolean user = result.next();
  144.             result.close();
  145.             ps.close();
  146.             return user;
  147.         } catch (Exception ex) {
  148.             ex.printStackTrace();
  149.         }
  150.         return false;
  151.     }
  152.    
  153.     public static void registerPlayer(Player p)
  154.       {
  155.         if (isUserExisting(p)) {
  156.           return;
  157.         }
  158.         try
  159.         {
  160.           PreparedStatement ps = connection.prepareStatement("INSERT INTO 1vs1 (NAME, UUID, KILLS, DEATHS, POINTS, WINS, LOSES) VALUES (?, ?, ?, ?, ?, ?, ?)");
  161.           ps.setString(1, p.getName());
  162.           ps.setString(2, p.getUniqueId().toString());
  163.           ps.setInt(3, 0);
  164.           ps.setInt(4, 0);
  165.           ps.setInt(5, 100);
  166.           ps.setInt(6, 0);
  167.           ps.setInt(7, 0);
  168.           ps.execute();
  169.           ps.close();
  170.         }
  171.         catch (Exception ex)
  172.         {
  173.           ex.printStackTrace();
  174.         }
  175.       }
  176.      
  177.       public static void registerInv(Player p)
  178.       {
  179.         if (isUserInvExisting(p)) {
  180.           return;
  181.         }
  182.         try
  183.         {
  184.           PreparedStatement ps = connection2.prepareStatement("INSERT INTO 1vs1 (NAME, UUID, INV) VALUES (?, ?, ?)");
  185.           ps.setString(1, p.getName());
  186.           ps.setString(2, p.getUniqueId().toString());
  187.           ps.setString(3, "null");
  188.           ps.execute();
  189.           ps.close();
  190.         }
  191.         catch (Exception ex)
  192.         {
  193.           ex.printStackTrace();
  194.         }
  195.       }
  196.      
  197.       public static void setInv(Player p, String inv)
  198.       {
  199.         try
  200.         {
  201.           PreparedStatement ps = connection2.prepareStatement("UPDATE 1vs1 SET INV = ? WHERE UUID = ?");
  202.           ps.setString(1, inv);
  203.           ps.setString(2, p.getUniqueId().toString());
  204.           ps.executeUpdate();
  205.           ps.close();
  206.         }
  207.         catch (Exception ex)
  208.         {
  209.           ex.printStackTrace();
  210.         }
  211.       }
  212.      
  213.       public static String getInv(Player p)
  214.       {
  215.         try
  216.         {
  217.           PreparedStatement ps = connection2.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  218.           ps.setString(1, p.getUniqueId().toString());
  219.           ResultSet result = ps.executeQuery();
  220.           result.next();
  221.           String fire = result.getString("INV");
  222.           result.close();
  223.           ps.close();
  224.           return fire;
  225.         }
  226.         catch (Exception ex)
  227.         {
  228.           ex.printStackTrace();
  229.         }
  230.         return "null";
  231.       }
  232.      
  233.       public static void setPlayerName(Player p)
  234.       {
  235.         try
  236.         {
  237.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET NAME = ? WHERE UUID = ?");
  238.           ps.setString(1, p.getName());
  239.           ps.setString(2, p.getUniqueId().toString());
  240.           ps.executeUpdate();
  241.           ps.close();
  242.         }
  243.         catch (Exception ex)
  244.         {
  245.           ex.printStackTrace();
  246.         }
  247.       }
  248.      
  249.       public static String getPlayer(String player)
  250.       {
  251.         try
  252.         {
  253.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  254.           ps.setString(1, player);
  255.           ResultSet result = ps.executeQuery();
  256.           result.next();
  257.           String name = result.getString("NAME");
  258.           result.close();
  259.           ps.close();
  260.           return name;
  261.         }
  262.         catch (Exception ex)
  263.         {
  264.           ex.printStackTrace();
  265.         }
  266.         return "null";
  267.       }
  268.      
  269.       public static int getKills(Player p)
  270.       {
  271.         try
  272.         {
  273.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  274.           ps.setString(1, p.getUniqueId().toString());
  275.           ResultSet result = ps.executeQuery();
  276.           result.next();
  277.           int kills = result.getInt("KILLS");
  278.           result.close();
  279.           ps.close();
  280.           return kills;
  281.         }
  282.         catch (Exception ex)
  283.         {
  284.           ex.printStackTrace();
  285.         }
  286.         return -1;
  287.       }
  288.      
  289.       public static int getKills(String player)
  290.       {
  291.         try
  292.         {
  293.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  294.           ps.setString(1, player);
  295.           ResultSet result = ps.executeQuery();
  296.           result.next();
  297.           int kills = result.getInt("KILLS");
  298.           result.close();
  299.           ps.close();
  300.           return kills;
  301.         }
  302.         catch (Exception ex)
  303.         {
  304.           ex.printStackTrace();
  305.         }
  306.         return -1;
  307.       }
  308.      
  309.       public static int getDeaths(Player p)
  310.       {
  311.         try
  312.         {
  313.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  314.           ps.setString(1, p.getUniqueId().toString());
  315.           ResultSet result = ps.executeQuery();
  316.           result.next();
  317.           int deaths = result.getInt("DEATHS");
  318.           result.close();
  319.           ps.close();
  320.           return deaths;
  321.         }
  322.         catch (Exception ex)
  323.         {
  324.           ex.printStackTrace();
  325.         }
  326.         return -1;
  327.       }
  328.      
  329.       public static int getDeaths(String player)
  330.       {
  331.         try
  332.         {
  333.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  334.           ps.setString(1, player);
  335.           ResultSet result = ps.executeQuery();
  336.           result.next();
  337.           int deaths = result.getInt("DEATHS");
  338.           result.close();
  339.           ps.close();
  340.           return deaths;
  341.         }
  342.         catch (Exception ex)
  343.         {
  344.           ex.printStackTrace();
  345.         }
  346.         return -1;
  347.       }
  348.      
  349.       public static double getKD(Player p)
  350.       {
  351.         try
  352.         {
  353.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  354.           ps1.setString(1, p.getUniqueId().toString());
  355.           ResultSet result1 = ps1.executeQuery();
  356.           result1.next();
  357.           double kills = result1.getInt("KILLS");
  358.           result1.close();
  359.           ps1.close();
  360.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  361.           ps2.setString(1, p.getUniqueId().toString());
  362.           ResultSet result2 = ps2.executeQuery();
  363.           result2.next();
  364.           double deaths = result2.getInt("DEATHS");
  365.           result2.close();
  366.           ps2.close();
  367.           if ((kills == 0.0D) && (deaths == 0.0D)) {
  368.             return 0.0D;
  369.           }
  370.           if (deaths == 0.0D) {
  371.             return kills;
  372.           }
  373.           return Math.round(kills / deaths * 100.0D) / 100.0D;
  374.         }
  375.         catch (Exception ex)
  376.         {
  377.           ex.printStackTrace();
  378.         }
  379.         return -1.0D;
  380.       }
  381.      
  382.       public static double getKD(String player)
  383.       {
  384.         try
  385.         {
  386.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  387.           ps1.setString(1, player);
  388.           ResultSet result1 = ps1.executeQuery();
  389.           result1.next();
  390.           double kills = result1.getInt("KILLS");
  391.           result1.close();
  392.           ps1.close();
  393.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  394.           ps2.setString(1, player);
  395.           ResultSet result2 = ps2.executeQuery();
  396.           result2.next();
  397.           double deaths = result2.getInt("DEATHS");
  398.           result2.close();
  399.           ps2.close();
  400.           if ((kills == 0.0D) && (deaths == 0.0D)) {
  401.             return 0.0D;
  402.           }
  403.           if (deaths == 0.0D) {
  404.             return kills;
  405.           }
  406.           return Math.round(kills / deaths * 100.0D) / 100.0D;
  407.         }
  408.         catch (Exception ex)
  409.         {
  410.           ex.printStackTrace();
  411.         }
  412.         return -1.0D;
  413.       }
  414.      
  415.       public static int getGamesPlayed(Player p)
  416.       {
  417.         try
  418.         {
  419.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  420.           ps1.setString(1, p.getUniqueId().toString());
  421.           ResultSet result1 = ps1.executeQuery();
  422.           result1.next();
  423.           int wins = result1.getInt("WINS");
  424.           result1.close();
  425.           ps1.close();
  426.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  427.           ps2.setString(1, p.getUniqueId().toString());
  428.           ResultSet result2 = ps2.executeQuery();
  429.           result2.next();
  430.           int looses = result2.getInt("LOSES");
  431.           result2.close();
  432.           ps2.close();
  433.           return wins + looses;
  434.         }
  435.         catch (Exception ex)
  436.         {
  437.           ex.printStackTrace();
  438.         }
  439.         return -1;
  440.       }
  441.      
  442.       public static int getGamesPlayed(String player)
  443.       {
  444.         try
  445.         {
  446.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  447.           ps1.setString(1, player);
  448.           ResultSet result1 = ps1.executeQuery();
  449.           result1.next();
  450.           int wins = result1.getInt("WINS");
  451.           result1.close();
  452.           ps1.close();
  453.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  454.           ps2.setString(1, player);
  455.           ResultSet result2 = ps2.executeQuery();
  456.           result2.next();
  457.           int looses = result2.getInt("LOSES");
  458.           result2.close();
  459.           ps2.close();
  460.           return wins + looses;
  461.         }
  462.         catch (Exception ex)
  463.         {
  464.           ex.printStackTrace();
  465.         }
  466.         return -1;
  467.       }
  468.      
  469.       public static int getWins(Player p)
  470.       {
  471.         try
  472.         {
  473.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  474.           ps.setString(1, p.getUniqueId().toString());
  475.           ResultSet result = ps.executeQuery();
  476.           result.next();
  477.           int wins = result.getInt("WINS");
  478.           result.close();
  479.           ps.close();
  480.           return wins;
  481.         }
  482.         catch (Exception ex)
  483.         {
  484.           ex.printStackTrace();
  485.         }
  486.         return -1;
  487.       }
  488.      
  489.       public static int getWins(String player)
  490.       {
  491.         try
  492.         {
  493.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  494.           ps.setString(1, player);
  495.           ResultSet result = ps.executeQuery();
  496.           result.next();
  497.           int wins = result.getInt("WINS");
  498.           result.close();
  499.           ps.close();
  500.           return wins;
  501.         }
  502.         catch (Exception ex)
  503.         {
  504.           ex.printStackTrace();
  505.         }
  506.         return -1;
  507.       }
  508.      
  509.       public static int getLooses(Player p)
  510.       {
  511.         try
  512.         {
  513.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  514.           ps.setString(1, p.getUniqueId().toString());
  515.           ResultSet result = ps.executeQuery();
  516.           result.next();
  517.           int looses = result.getInt("LOSES");
  518.           result.close();
  519.           ps.close();
  520.           return looses;
  521.         }
  522.         catch (Exception ex)
  523.         {
  524.           ex.printStackTrace();
  525.         }
  526.         return -1;
  527.       }
  528.      
  529.       public static int getLooses(String player)
  530.       {
  531.         try
  532.         {
  533.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  534.           ps.setString(1, player);
  535.           ResultSet result = ps.executeQuery();
  536.           result.next();
  537.           int looses = result.getInt("LOSES");
  538.           result.close();
  539.           ps.close();
  540.           return looses;
  541.         }
  542.         catch (Exception ex)
  543.         {
  544.           ex.printStackTrace();
  545.         }
  546.         return -1;
  547.       }
  548.      
  549.       public static int getPoints(Player p)
  550.       {
  551.         try
  552.         {
  553.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  554.           ps.setString(1, p.getUniqueId().toString());
  555.           ResultSet result = ps.executeQuery();
  556.           result.next();
  557.           int wins = result.getInt("POINTS");
  558.           result.close();
  559.           ps.close();
  560.           return wins;
  561.         }
  562.         catch (Exception ex)
  563.         {
  564.           ex.printStackTrace();
  565.         }
  566.         return -1;
  567.       }
  568.      
  569.       public static int getPoints(String player)
  570.       {
  571.         try
  572.         {
  573.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  574.           ps.setString(1, player);
  575.           ResultSet result = ps.executeQuery();
  576.           result.next();
  577.           int wins = result.getInt("POINTS");
  578.           result.close();
  579.           ps.close();
  580.           return wins;
  581.         }
  582.         catch (Exception ex)
  583.         {
  584.           ex.printStackTrace();
  585.         }
  586.         return -1;
  587.       }
  588.      
  589.       public static double getWL(Player p)
  590.       {
  591.         try
  592.         {
  593.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  594.           ps1.setString(1, p.getUniqueId().toString());
  595.           ResultSet result1 = ps1.executeQuery();
  596.           result1.next();
  597.           double wins = result1.getInt("WINS");
  598.           result1.close();
  599.           ps1.close();
  600.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE UUID = ?");
  601.           ps2.setString(1, p.getUniqueId().toString());
  602.           ResultSet result2 = ps2.executeQuery();
  603.           result2.next();
  604.           double looses = result2.getInt("LOSES");
  605.           result2.close();
  606.           ps2.close();
  607.           if ((wins == 0.0D) && (looses == 0.0D)) {
  608.             return 0.0D;
  609.           }
  610.           if (looses == 0.0D) {
  611.             return wins;
  612.           }
  613.           return Math.round(wins / looses * 100.0D) / 100.0D;
  614.         }
  615.         catch (Exception ex)
  616.         {
  617.           ex.printStackTrace();
  618.         }
  619.         return -1.0D;
  620.       }
  621.      
  622.       public static double getWL(String player)
  623.       {
  624.         try
  625.         {
  626.           PreparedStatement ps1 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  627.           ps1.setString(1, player);
  628.           ResultSet result1 = ps1.executeQuery();
  629.           result1.next();
  630.           double wins = result1.getInt("WINS");
  631.           result1.close();
  632.           ps1.close();
  633.           PreparedStatement ps2 = connection.prepareStatement("SELECT * FROM 1vs1 WHERE NAME = ?");
  634.           ps2.setString(1, player);
  635.           ResultSet result2 = ps2.executeQuery();
  636.           result2.next();
  637.           double looses = result2.getInt("LOSES");
  638.           result2.close();
  639.           ps2.close();
  640.           if ((wins == 0.0D) && (looses == 0.0D)) {
  641.             return 0.0D;
  642.           }
  643.           if (looses == 0.0D) {
  644.             return wins;
  645.           }
  646.           return Math.round(wins / looses * 100.0D) / 100.0D;
  647.         }
  648.         catch (Exception ex)
  649.         {
  650.           ex.printStackTrace();
  651.         }
  652.         return -1.0D;
  653.       }
  654.      
  655.       public static int getRank(Player p)
  656.       {
  657.         int rank = -1;
  658.         try
  659.         {
  660.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 ORDER BY WINS DESC");
  661.           ResultSet result = ps.executeQuery();
  662.           while (result.next())
  663.           {
  664.             String uuid2 = result.getString("UUID");
  665.             if (uuid2.equalsIgnoreCase(p.getUniqueId().toString()))
  666.             {
  667.               rank = result.getRow();
  668.               break;
  669.             }
  670.           }
  671.           result.close();
  672.           ps.close();
  673.         }
  674.         catch (Exception ex)
  675.         {
  676.           ex.printStackTrace();
  677.         }
  678.         return rank;
  679.       }
  680.      
  681.       public static int getRank(String player)
  682.       {
  683.         int rank = -1;
  684.         try
  685.         {
  686.           PreparedStatement ps = connection.prepareStatement("SELECT * FROM 1vs1 ORDER BY WINS DESC");
  687.           ResultSet result = ps.executeQuery();
  688.           while (result.next())
  689.           {
  690.             String uuid2 = result.getString("NAME");
  691.             if (uuid2.equalsIgnoreCase(player))
  692.             {
  693.               rank = result.getRow();
  694.               break;
  695.             }
  696.           }
  697.           result.close();
  698.           ps.close();
  699.         }
  700.         catch (Exception ex)
  701.         {
  702.           ex.printStackTrace();
  703.         }
  704.         return rank;
  705.       }
  706.      
  707.       public static void addKill(Player p)
  708.       {
  709.         try
  710.         {
  711.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET KILLS = ? WHERE UUID = ?");
  712.           ps.setInt(1, getKills(p) + 1);
  713.           ps.setString(2, p.getUniqueId().toString());
  714.           ps.executeUpdate();
  715.           ps.close();
  716.         }
  717.         catch (Exception ex)
  718.         {
  719.           ex.printStackTrace();
  720.         }
  721.       }
  722.      
  723.       public static void addDeath(Player p)
  724.       {
  725.         try
  726.         {
  727.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET DEATHS = ? WHERE UUID = ?");
  728.           ps.setInt(1, getDeaths(p) + 1);
  729.           ps.setString(2, p.getUniqueId().toString());
  730.           ps.executeUpdate();
  731.           ps.close();
  732.         }
  733.         catch (Exception ex)
  734.         {
  735.           ex.printStackTrace();
  736.         }
  737.       }
  738.      
  739.       public static void addWin(Player p)
  740.       {
  741.         try
  742.         {
  743.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET WINS = ? WHERE UUID = ?");
  744.           ps.setInt(1, getWins(p) + 1);
  745.           ps.setString(2, p.getUniqueId().toString());
  746.           ps.executeUpdate();
  747.           ps.close();
  748.         }
  749.         catch (Exception ex)
  750.         {
  751.           ex.printStackTrace();
  752.         }
  753.       }
  754.      
  755.       public static void addLoose(Player p)
  756.       {
  757.         try
  758.         {
  759.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET LOSES = ? WHERE UUID = ?");
  760.           ps.setInt(1, getLooses(p) + 1);
  761.           ps.setString(2, p.getUniqueId().toString());
  762.           ps.executeUpdate();
  763.           ps.close();
  764.         }
  765.         catch (Exception ex)
  766.         {
  767.           ex.printStackTrace();
  768.         }
  769.       }
  770.      
  771.       public static void addPoints(Player p, int points)
  772.       {
  773.         try
  774.         {
  775.           PreparedStatement ps = connection.prepareStatement("UPDATE 1vs1 SET POINTS = ? WHERE UUID = ?");
  776.           ps.setInt(1, getPoints(p) + points);
  777.           ps.setString(2, p.getUniqueId().toString());
  778.           ps.executeUpdate();
  779.           ps.close();
  780.         }
  781.         catch (Exception ex)
  782.         {
  783.           ex.printStackTrace();
  784.         }
  785.       }
  786.    
  787. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement