RequestPetitionFeedback.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.network.clientpackets;
  20. import java.sql.Connection;
  21. import java.sql.PreparedStatement;
  22. import java.sql.SQLException;
  23. import java.util.logging.Level;
  24. import com.l2jserver.L2DatabaseFactory;
  25. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  26. /**
  27. * @author Plim
  28. */
  29. public class RequestPetitionFeedback extends L2GameClientPacket
  30. {
  31. private static final String _C__C9_REQUESTPETITIONFEEDBACK = "[C] C9 RequestPetitionFeedback";
  32. private static final String INSERT_FEEDBACK = "INSERT INTO petition_feedback VALUES (?,?,?,?,?)";
  33. // cdds
  34. // private int _unknown;
  35. private int _rate; // 4=VeryGood, 3=Good, 2=Fair, 1=Poor, 0=VeryPoor
  36. private String _message;
  37. @Override
  38. protected void readImpl()
  39. {
  40. // _unknown =
  41. readD(); // unknown
  42. _rate = readD();
  43. _message = readS();
  44. }
  45. @Override
  46. protected void runImpl()
  47. {
  48. L2PcInstance player = getClient().getActiveChar();
  49. if ((player == null) || (player.getLastPetitionGmName() == null))
  50. {
  51. return;
  52. }
  53. if ((_rate > 4) || (_rate < 0))
  54. {
  55. return;
  56. }
  57. try (Connection con = L2DatabaseFactory.getInstance().getConnection();
  58. PreparedStatement statement = con.prepareStatement(INSERT_FEEDBACK))
  59. {
  60. statement.setString(1, player.getName());
  61. statement.setString(2, player.getLastPetitionGmName());
  62. statement.setInt(3, _rate);
  63. statement.setString(4, _message);
  64. statement.setLong(5, System.currentTimeMillis());
  65. statement.execute();
  66. }
  67. catch (SQLException e)
  68. {
  69. _log.log(Level.SEVERE, "Error while saving petition feedback");
  70. }
  71. }
  72. @Override
  73. public String getType()
  74. {
  75. return _C__C9_REQUESTPETITIONFEEDBACK;
  76. }
  77. }