Guest User

Untitled

a guest
Jun 24th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. Add this to NPCConversationManager.java:
  2.  
  3. public void removeBugReport(int number) {
  4. try {
  5. Connection con = (Connection) DatabaseConnection.getConnection();
  6. PreparedStatement pse = (PreparedStatement) con.prepareStatement("DELETE FROM bugreports WHERE id = ?");
  7. pse.setInt(1, number);
  8. pse.executeUpdate();
  9. pse.close();
  10. } catch (Exception e) {
  11. System.err.println("failed to removeBugReport");
  12. }
  13. }
  14.  
  15. public String viewBugReports() {
  16. String text = (isGM() ? "Click a bug report once to remove it (GM Mode)\r\n\r\n" : "") +"Beta Testers's report list: ";
  17. int count = 0;
  18. try {
  19. Connection con = (Connection) DatabaseConnection.getConnection();
  20. PreparedStatement ps = (PreparedStatement) con.prepareStatement("SELECT * FROM bugreports");
  21. ResultSet rs = ps.executeQuery();
  22. rs.first();
  23. while (rs.next()) {
  24. count++;
  25. if (isGM())
  26. text += "#L"+ rs.getInt("id") +"#"+ count +". "+ rs.getString("charname") +" : "+ rs.getString("message") +".#k\r\n";
  27. else
  28. text += count +". "+ rs.getString("charname") +" : "+ rs.getString("message") +".";
  29. }
  30. return text;
  31. } catch (Exception ex) {
  32. System.err.println("failed to viewBugReports.");
  33. return "Something went wrong";
  34. }
  35. }
  36.  
  37. public void bugReport(String message) {
  38. try {
  39. PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO `bugreports` (`charname`, `message`) VALUES (?, ?)");
  40. ps.setString(1, getName());
  41. ps.setString(2, message);
  42. ps.execute();
  43. ps.close();
  44. } catch (SQLException se) {
  45. System.out.println("Failed to add bugReport. Reason: "+ se.getCause());
  46. }
  47. }
Add Comment
Please, Sign In to add comment