Guest User

ff

a guest
Aug 10th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, noble2, hero_end_date) VALUES (?,?,?,?,?,?)";
  2.  
  3. private void updateDatabase(L2PcInstance player, long heroTime)
  4.     {
  5.     Connection con = null;
  6.     try
  7.     {
  8.     if(player == null)
  9.     return;
  10.      
  11.     con = L2DatabaseFactory.getInstance().getConnection();
  12.     PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
  13.      
  14.     stmt.setInt(1, player.getObjectId());
  15.     stmt.setString(2, player.getName());
  16.     stmt.setInt(3, 1);
  17.     stmt.setInt(4, player.isNoble() ? 1 : 0);
  18.     stmt.setInt(5, player.isNoble() ? 1 : 0);
  19.     stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
  20.     stmt.execute();
  21.     stmt.close();
  22.     stmt = null;
  23.     }
  24.     catch(Exception e)
  25.     {
  26.     if(Config.ENABLE_ALL_EXCEPTIONS)
  27.     e.printStackTrace();
  28.      
  29.     _log.log(Level.SEVERE, "Error: could not update database: ", e);
  30.     }
  31.     finally
  32.     {
  33.         L2DatabaseFactory.close(con);
  34.      
  35.     con = null;
  36.     }
  37. }
  38.  
  39. else if (command.startsWith("hero"))
  40.         {
  41.             if(player.isInOlympiadMode())
  42.             {
  43.                 player.sendMessage("You cannot make hero when you are in Olympiad Games.");
  44.             }
  45.              
  46.             if(player.isHero())
  47.             {
  48.                 player.sendMessage("You Are Already A Hero!.");
  49.             }
  50.                                    
  51.             player.setHero(true);
  52.             updateDatabase(player, Config.HERO_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
  53.             player.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
  54.             player.broadcastUserInfo();
  55.             player.destroyItemByItemId("Hero donate", Config.HERO_COIN, Config.HERO_PRICE, player, true);
  56.             player.getInventory().addItem("Wings", 6842, 1, player, null);
  57.             }
Advertisement
Add Comment
Please, Sign In to add comment