Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, noble2, hero_end_date) VALUES (?,?,?,?,?,?)";
- private void updateDatabase(L2PcInstance player, long heroTime)
- {
- Connection con = null;
- try
- {
- if(player == null)
- return;
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
- stmt.setInt(1, player.getObjectId());
- stmt.setString(2, player.getName());
- stmt.setInt(3, 1);
- stmt.setInt(4, player.isNoble() ? 1 : 0);
- stmt.setInt(5, player.isNoble() ? 1 : 0);
- stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
- stmt.execute();
- stmt.close();
- stmt = null;
- }
- catch(Exception e)
- {
- if(Config.ENABLE_ALL_EXCEPTIONS)
- e.printStackTrace();
- _log.log(Level.SEVERE, "Error: could not update database: ", e);
- }
- finally
- {
- L2DatabaseFactory.close(con);
- con = null;
- }
- }
- else if (command.startsWith("hero"))
- {
- if(player.isInOlympiadMode())
- {
- player.sendMessage("You cannot make hero when you are in Olympiad Games.");
- }
- if(player.isHero())
- {
- player.sendMessage("You Are Already A Hero!.");
- }
- player.setHero(true);
- updateDatabase(player, Config.HERO_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
- player.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
- player.broadcastUserInfo();
- player.destroyItemByItemId("Hero donate", Config.HERO_COIN, Config.HERO_PRICE, player, true);
- player.getInventory().addItem("Wings", 6842, 1, player, null);
- }
Advertisement
Add Comment
Please, Sign In to add comment