SHOW:
|
|
- or go back to the newest paste.
1 | //If first argument is "unvote" | |
2 | - | }else if(args[0].equalsIgnoreCase("unvote")){ |
2 | + | }else if(args[0].equalsIgnoreCase("unvote")){ |
3 | - | try { |
3 | + | try { |
4 | - | |
4 | + | |
5 | - | //Establish database connection and generate statement |
5 | + | //Establish database connection and generate statement |
6 | - | Statement st = SQLConnect.sqlConnection(); |
6 | + | Statement st = SQLConnect.sqlConnection(); |
7 | - | //Retrieve specified users database info |
7 | + | //Retrieve specified users database info |
8 | - | ResultSet rs = st.executeQuery("Select playername,voted,lastvote,groups FROM users WHERE playername='"+args[1]+"';"); |
8 | + | ResultSet rs = st.executeQuery("Select playername,voted,lastvote,groups FROM users WHERE playername='"+args[1]+"';"); |
9 | - | System.out.println(rs.isClosed()); |
9 | + | //Get the users group count |
10 | - | //Get the users group count |
10 | + | int groups = rs.getInt("groups"); |
11 | - | int groups = rs.getInt("groups"); |
11 | + | //Remove VIP or sub VIP rank from player depending on group size |
12 | - | //Remove VIP or sub VIP rank from player depending on group size |
12 | + | if(groups == 1){ |
13 | - | if(groups == 1){ |
13 | + | plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manudel " + args[1]); |
14 | - | plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manudel " + args[1]); |
14 | + | }else{ |
15 | - | }else{ |
15 | + | plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manudelsub "+args[1]+" VIP"); |
16 | - | plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), "manudelsub "+args[1]+" VIP"); |
16 | + | } |
17 | - | } |
17 | + | |
18 | - | |
18 | + | //Delete user from db |
19 | - | //Delete user from db |
19 | + | rs.rowDeleted(); |
20 | - | rs.rowDeleted(); |
20 | + | |
21 | - | |
21 | + | //Close ResultSet and statement |
22 | - | //Close ResultSet and statement |
22 | + | rs.close(); |
23 | - | rs.close(); |
23 | + | st.close(); |
24 | - | st.close(); |
24 | + | } catch (Exception e) { |
25 | - | } catch (Exception e) { |
25 | + | e.printStackTrace(); |
26 | - | e.printStackTrace(); |
26 | + | } |
27 | - | } |
27 | + | |
28 | - | |
28 | + | |
29 | - | |
29 | + | //If first argument is "check" |
30 | - | //If first argument is "check" |
30 | + | }else if(args[0].equalsIgnoreCase("check")){ |
31 | - | }else if(args[0].equalsIgnoreCase("check")){ |
31 | + | try { |
32 | - | try { |
32 | + | //Establish database connection and generate statement |
33 | - | //Establish database connection and generate statement |
33 | + | Statement st = SQLConnect.sqlConnection(); |
34 | - | Statement st = SQLConnect.sqlConnection(); |
34 | + | //Retrieve specified users database info |
35 | - | //Retrieve specified users database info |
35 | + | ResultSet rs = st.executeQuery("Select * FROM users WHERE playername='"+args[1]+"' AND voted='false';"); |
36 | - | ResultSet rs = st.executeQuery("Select * FROM users WHERE playername='"+args[1]+"' AND voted='false';"); |
36 | + | |
37 | - | |
37 | + | |
38 | - | |
38 | + | //Display result |
39 | - | //Display result |
39 | + | if(rs.getBoolean("voted")){ |
40 | - | if(rs.getBoolean("voted")){ |
40 | + | sender.sendMessage("This player has voted within the past 24 hours"); |
41 | - | sender.sendMessage("This player has voted within the past 24 hours"); |
41 | + | }else{ |
42 | - | }else{ |
42 | + | sender.sendMessage("This player has not voted within the past 24 hours"); |
43 | - | sender.sendMessage("This player has not voted within the past 24 hours"); |
43 | + | } |
44 | - | } |
44 | + | //Close ResultSet & Statement |
45 | - | //Close ResultSet & Statement |
45 | + | rs.close(); |
46 | - | rs.close(); |
46 | + | st.close(); |
47 | - | st.close(); |
47 | + | } catch (Exception e) { |
48 | - | } catch (Exception e) { |
48 | + | e.printStackTrace(); |
49 | - | e.printStackTrace(); |
49 | + | } |
50 | - | } |
50 | + | } |