A Project for Chronicle 4 based on L2JServer.


    [Request] Can someon adapt this codes for Lisvus?

    Share

    B3rahT

    Posts : 2
    Join date : 2014-12-12

    [Request] Can someon adapt this codes for Lisvus?

    Post  B3rahT on 28th December 2014, 23:30

    Maybe someone can adapt this donator codes for L2JLisvus?

    Code:
    Index: config/functions/l2jfrozen.properties
    ===================================================================
    --- config/functions/l2jfrozen.properties   (revision 939)
    +++ config/functions/l2jfrozen.properties   (working copy)
    @@ -203,8 +203,17 @@
     # ---------------------------
     #  Donator Config -
     # ---------------------------
    -# Command in game: //setdonator
    +# Command in game: //setdonator @time (1 for 1 day)
     
    +# When ActiveChar will use this item will gain Donator Status.
    +EnableDonatorCustomItem = False
    +
    +# Id Itemn Need's default 6392
    +DonatorCustomItemId = 6392
    +
    +# Donator for X days, 0 forever.
    +DonatorCustomDay = 0
    +
     # If it is true then donators will have their name colored.
     DonatorNameColorEnabled = False
     
    Index: head-src/com/l2jfrozen/Config.java
    ===================================================================
    --- head-src/com/l2jfrozen/Config.java   (revision 939)
    +++ head-src/com/l2jfrozen/Config.java   (working copy)
    @@ -2321,6 +2321,7 @@
        public static String ADD_CHAR_TITLE;
        public static boolean NOBLE_CUSTOM_ITEMS;
        public static boolean HERO_CUSTOM_ITEMS;
    +   public static boolean DONATOR_CUSTOM_ITEMS;
        public static boolean ALLOW_CREATE_LVL;
        public static int CHAR_CREATE_LVL;
        public static boolean SPAWN_CHAR;
    @@ -2357,7 +2358,9 @@
     
        public static int HERO_CUSTOM_ITEM_ID;
        public static int NOOBLE_CUSTOM_ITEM_ID;
    +   public static int DONATOR_CUSTOM_ITEM_ID;
        public static int HERO_CUSTOM_DAY;
    +   public static int DONATOR_CUSTOM_DAY;
        public static boolean ALLOW_FARM1_COMMAND;
        public static boolean ALLOW_FARM2_COMMAND;
        public static boolean ALLOW_PVP1_COMMAND;
    @@ -2454,6 +2457,10 @@
              HERO_CUSTOM_ITEMS = Boolean.parseBoolean(L2JFrozenSettings.getProperty("EnableHeroCustomItem", "true"));
              HERO_CUSTOM_ITEM_ID = Integer.parseInt(L2JFrozenSettings.getProperty("HeroCustomItemId", "3481"));
              HERO_CUSTOM_DAY = Integer.parseInt(L2JFrozenSettings.getProperty("HeroCustomDay", "0"));
    +         
    +         DONATOR_CUSTOM_ITEMS = Boolean.parseBoolean(L2JFrozenSettings.getProperty("EnableDonatorCustomItem", "true"));
    +         DONATOR_CUSTOM_ITEM_ID = Integer.parseInt(L2JFrozenSettings.getProperty("DonatorCustomItemId", "6392"));
    +         DONATOR_CUSTOM_DAY = Integer.parseInt(L2JFrozenSettings.getProperty("DonatorCustomDay", "0"));
     
              ALLOW_CREATE_LVL = Boolean.parseBoolean(L2JFrozenSettings.getProperty("CustomStartingLvl", "False"));
              CHAR_CREATE_LVL = Integer.parseInt(L2JFrozenSettings.getProperty("CharLvl", "80"));
    Index: head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java   (revision 939)
    +++ head-src/com/l2jfrozen/gameserver/handler/ItemHandler.java   (working copy)
    @@ -42,6 +42,7 @@
     import com.l2jfrozen.gameserver.handler.itemhandlers.FishShots;
     import com.l2jfrozen.gameserver.handler.itemhandlers.Harvester;
     import com.l2jfrozen.gameserver.handler.itemhandlers.HeroCustomItem;
    +import com.l2jfrozen.gameserver.handler.itemhandlers.DonatorCustomItem;
     import com.l2jfrozen.gameserver.handler.itemhandlers.JackpotSeed;
     import com.l2jfrozen.gameserver.handler.itemhandlers.MOSKey;
     import com.l2jfrozen.gameserver.handler.itemhandlers.MapForestOfTheDead;
    @@ -148,6 +149,7 @@
           registerItemHandler(new JackpotSeed());
           registerItemHandler(new NobleCustomItem());
           registerItemHandler(new HeroCustomItem());
    +      registerItemHandler(new DonatorCustomItem());
           registerItemHandler(new MOSKey());
           registerItemHandler(new BreakingArrow());
           registerItemHandler(new ChristmasTree());
    Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminDonator.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminDonator.java   (revision 939)
    +++ head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminDonator.java   (working copy)
    @@ -67,6 +67,23 @@
     
           if(command.startsWith("admin_setdonator"))
           {
    +         String[] cmdParams = command.split(" ");
    +         
    +         long donatorTime = 0;
    +         
    +         if(cmdParams.length > 1)
    +         {
    +            try
    +            {
    +               donatorTime = Integer.parseInt(cmdParams[1]) * 24L * 60L * 60L * 1000L;
    +            }
    +            catch(NumberFormatException nfe)
    +            {
    +               if(Config.ENABLE_ALL_EXCEPTIONS)
    +                  nfe.printStackTrace();
    +            }
    +         }
    +         
              L2Object target = activeChar.getTarget();
     
              if(target instanceof L2PcInstance)
    @@ -78,7 +95,7 @@
                 {
                    targetPlayer.setDonator(true);
                    targetPlayer.updateNameTitleColor();
    -               updateDatabase(targetPlayer, true);
    +               updateDatabase(targetPlayer, true, donatorTime);
                    sendMessages(true, targetPlayer, activeChar, false, true);
                    targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
                    targetPlayer.broadcastUserInfo();
    @@ -87,7 +104,7 @@
                 {
                    targetPlayer.setDonator(false);
                    targetPlayer.updateNameTitleColor();
    -               updateDatabase(targetPlayer, false);
    +               updateDatabase(targetPlayer, false, donatorTime);
                    sendMessages(false, targetPlayer, activeChar, false, true);
                    targetPlayer.broadcastUserInfo();
                 }
    @@ -145,7 +162,7 @@
         * @param player
         * @param newDonator
         */
    -   private void updateDatabase(L2PcInstance player, boolean newDonator)
    +   private void updateDatabase(L2PcInstance player, boolean newDonator, long donatorTime)
        {
           Connection con = null;
           try
    @@ -169,6 +186,8 @@
                 stmt.setInt(3, player.isHero() ? 1 : 0);
                 stmt.setInt(4, player.isNoble() ? 1 : 0);
                 stmt.setInt(5, 1);
    +            stmt.setLong(6, player.getHeroDate(player.getObjectId()));
    +            stmt.setLong(7, donatorTime == 0 ? 0 : System.currentTimeMillis() + donatorTime);
                 stmt.execute();
                 stmt.close();
                 stmt = null;
    @@ -197,8 +216,8 @@
     
        // Updates That Will be Executed by MySQL
        // ----------------------------------------
    -   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator) VALUES (?,?,?,?,?)";
    -   String DEL_DATA = "UPDATE characters_custom_data SET donator = 0 WHERE obj_Id=?";
    +   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date, donator_end_date) VALUES (?,?,?,?,?,?,?)";
    +   String DEL_DATA = "UPDATE characters_custom_data SET donator = 0, donator_end_date = 0 WHERE obj_Id=?";
     
        /**
         * @return
    Index: head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminHero.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminHero.java   (revision 939)
    +++ head-src/com/l2jfrozen/gameserver/handler/admincommandhandlers/AdminHero.java   (working copy)
    @@ -179,6 +179,7 @@
                 stmt.setInt(4, 1);
                 stmt.setInt(5, player.isDonator() ? 1 : 0);
                 stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
    +            stmt.setLong(7, player.getDonatorDate(player.getObjectId()));
                 stmt.execute();
                 stmt.close();
                 stmt = null;
    @@ -207,7 +208,7 @@
     
        // Updates That Will be Executed by MySQL
        // ----------------------------------------
    -   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
    +   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date, donator_end_date) VALUES (?,?,?,?,?,?,?)";
        String DEL_DATA = "UPDATE characters_custom_data SET hero = 0 WHERE obj_Id=?";
     
        /**
    Index: head-src/com/l2jfrozen/gameserver/handler/itemhandlers/DonatorCustomItem.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/handler/itemhandlers/DonatorCustomItem.java   (revision 0)
    +++ head-src/com/l2jfrozen/gameserver/handler/itemhandlers/DonatorCustomItem.java   (working copy)
    @@ -0,0 +1,131 @@
    +// Donator Custom Item , Created By Stefoulis15
    +// Added From Stefoulis15 Into The Core.
    +// Visit www.MaxCheaters.com For Support
    +// Source File Name:  HeroCustomItem.java
    +// New File Name:    DonatorCustomItem.java
    +// Modded by programmos, sword dev
    +// Adapted for Donator items by Karech
    +
    +package com.l2jfrozen.gameserver.handler.itemhandlers;
    +
    +import java.sql.Connection;
    +import java.sql.PreparedStatement;
    +import java.util.logging.Level;
    +import java.util.logging.Logger;
    +
    +import com.l2jfrozen.Config;
    +import com.l2jfrozen.gameserver.handler.IItemHandler;
    +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance;
    +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
    +import com.l2jfrozen.gameserver.model.actor.instance.L2PlayableInstance;
    +import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;
    +import com.l2jfrozen.util.CloseUtil;
    +import com.l2jfrozen.util.database.L2DatabaseFactory;
    +
    +public class DonatorCustomItem implements IItemHandler
    +{
    +
    +   public DonatorCustomItem()
    +   {
    +   //null
    +   }
    +
    +   protected static final Logger _log = Logger.getLogger(DonatorCustomItem.class.getName());
    +   
    +   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date, donator_end_date) VALUES (?,?,?,?,?,?,?)";
    +   
    +   @Override
    +   public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    +   {
    +      if(Config.DONATOR_CUSTOM_ITEMS)
    +      {
    +         if(!(playable instanceof L2PcInstance))
    +            return;
    +
    +         L2PcInstance activeChar = (L2PcInstance) playable;
    +
    +         if(activeChar.isDonator() && Config.DONATOR_CUSTOM_DAY == 0)
    +         {
    +            activeChar.sendMessage("You Are Already A Donator!.");
    +         }
    +         else
    +         {
    +            activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
    +            activeChar.setDonator(true);
    +            updateDatabase(activeChar, Config.DONATOR_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
    +            
    +            if (!activeChar.isDonator())
    +            {
    +               activeChar.sendMessage("You Are Now a Donator! Your rates are now increased!");
    +            }
    +            else
    +            {
    +               activeChar.sendMessage("Your Donator time has been extended for " + Config.DONATOR_CUSTOM_DAY + " day(s).");
    +            }   
    +            
    +            activeChar.broadcastUserInfo();
    +            playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
    +         }
    +         activeChar = null;
    +      }
    +   }
    +
    +   @Override
    +   public int[] getItemIds()
    +   {
    +      return ITEM_IDS;
    +   }
    +   
    +   private void updateDatabase(L2PcInstance player, long donatorTime)
    +   {
    +      Connection con = null;
    +      try
    +      {
    +         if(player == null)
    +            return;
    +         
    +         con = L2DatabaseFactory.getInstance().getConnection(false);         
    +         
    +         PreparedStatement stmt = con.prepareStatement(INSERT_DATA);         
    +         
    +         stmt.setInt(1, player.getObjectId());
    +         stmt.setString(2, player.getName());
    +         stmt.setInt(3, player.isHero() ? 1 : 0);
    +         stmt.setInt(4, player.isNoble() ? 1 : 0);
    +         stmt.setInt(5, 1);
    +         stmt.setLong(6, player.isHero() ? 0 : player.getHeroDate(player.getObjectId()));
    +         
    +         if (player.isDonator())
    +         {
    +            stmt.setLong(6, player.getDonatorDate(player.getObjectId()) + donatorTime);
    +         }
    +         else
    +         {
    +            stmt.setLong(6, donatorTime == 0 ? 0 : System.currentTimeMillis() + donatorTime);
    +         }
    +         
    +         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
    +      {
    +         CloseUtil.close(con);
    +         
    +         con = null;
    +      }
    +   }
    +
    +   private static final int ITEM_IDS[] =
    +   {
    +      Config.DONATOR_CUSTOM_ITEM_ID
    +   };
    +
    +}
    \ No newline at end of file
    Index: head-src/com/l2jfrozen/gameserver/handler/itemhandlers/HeroCustomItem.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/handler/itemhandlers/HeroCustomItem.java   (revision 939)
    +++ head-src/com/l2jfrozen/gameserver/handler/itemhandlers/HeroCustomItem.java   (working copy)
    @@ -30,7 +30,7 @@
     
        protected static final Logger _log = Logger.getLogger(HeroCustomItem.class.getName());
        
    -   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
    +   String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date, donator_end_date) VALUES (?,?,?,?,?,?,?)";
     
        @Override
        public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    @@ -47,7 +47,7 @@
                 activeChar.sendMessage("This Item Cannot Be Used On Olympiad Games.");
              }
     
    -         if(activeChar.isHero())
    +         if(activeChar.isHero() && Config.HERO_CUSTOM_DAY == 0 )
              {
                 activeChar.sendMessage("You Are Already A Hero!.");
              }
    @@ -56,10 +56,19 @@
                 activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
                 activeChar.setIsHero(true);
                 updateDatabase(activeChar, Config.HERO_CUSTOM_DAY * 24L * 60L * 60L * 1000L);
    -            activeChar.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
    +            
    +            if (!activeChar.isHero())
    +            {
    +               activeChar.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
    +               activeChar.getInventory().addItem("Wings", 6842, 1, activeChar, null);
    +            }
    +            else
    +            {
    +               activeChar.sendMessage("Your Hero time has been extended for " + Config.HERO_CUSTOM_DAY + " day(s).");
    +            }      
    +            
                 activeChar.broadcastUserInfo();
                 playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
    -            activeChar.getInventory().addItem("Wings", 6842, 1, activeChar, null);
              }
              activeChar = null;
           }
    @@ -79,15 +88,26 @@
              if(player == null)
                 return;
     
    -         con = L2DatabaseFactory.getInstance().getConnection(false);
    -         PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
    -
    +         con = L2DatabaseFactory.getInstance().getConnection(false);         
    +         
    +         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.isDonator() ? 1 : 0);
    -         stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
    +         
    +         if (player.isHero())
    +         {
    +            stmt.setLong(6, player.getHeroDate(player.getObjectId()) + heroTime);
    +         }
    +         else
    +         {
    +            stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
    +         }
    +         
    +         stmt.setLong(7, player.isDonator() ? 0 : player.getDonatorDate(player.getObjectId()));
              stmt.execute();
              stmt.close();
              stmt = null;
    Index: head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java
    ===================================================================
    --- head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java   (revision 939)
    +++ head-src/com/l2jfrozen/gameserver/model/actor/instance/L2PcInstance.java   (working copy)
    @@ -461,7 +461,7 @@
        private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer,"+/* in_jail, jail_timer,*/ "newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point"+/*,banchat_time*/",name_color,title_color,first_log,aio,aio_end FROM characters WHERE obj_id=?";
     
        /** The Constant STATUS_DATA_GET. */
    -   private static final String STATUS_DATA_GET = "SELECT hero, noble, donator, hero_end_date FROM characters_custom_data WHERE obj_Id = ?";
    +   private static final String STATUS_DATA_GET = "SELECT hero, noble, donator, hero_end_date, donator_end_date FROM characters_custom_data WHERE obj_Id = ?";
     
        /** The Constant RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS. */
        private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
    @@ -14054,7 +14054,46 @@
        {
           return _donator;
        }
    +   
    +   /**
    +    * Gets Donator's end time
    +    *
    +    * @return time, 0 if time is infinitive, or -1 if error
    +    */
    +   
    +   public long getDonatorDate(int obj_Id)
    +   {
    +      Connection con = null;
    +      int out = -1;
    +      
    +      try
    +      {
    +         con = L2DatabaseFactory.getInstance().getConnection(false);
    +         PreparedStatement stmt = con.prepareStatement("SELECT donator_end_date FROM characters_custom_data WHERE obj_Id=" + obj_Id);
    +         ResultSet rs = stmt.executeQuery();
    +         if (rs.next())
    +         {
    +            out = rs.getInt(1);
    +         }
    +         rs.close();
    +         rs = null;
    +         stmt.close();
    +         stmt = null;
    +      }
    +      catch (Exception e) {
    +         if(Config.ENABLE_ALL_EXCEPTIONS)
    +            e.printStackTrace();
    +         
    +         _log.log(Level.SEVERE, "Error: could not get donator_end_date from database: ", e);
    +      }
    +      finally {
    +         CloseUtil.close(con);         
    +         con = null;
    +      }
    +      return out;
    +   }
     
    +
        /**
         * Checks if is away.
         *
    @@ -14134,8 +14173,46 @@
        {
           return _hero;
        }
    -
    +   
        /**
    +    * Gets Hero end time
    +    *
    +    * @return time, 0 if time is infinitive, or -1 if error
    +    */
    +   
    +   public long getHeroDate(int obj_Id)
    +   {
    +      Connection con = null;
    +      int out = -1;
    +      
    +      try
    +      {
    +         con = L2DatabaseFactory.getInstance().getConnection(false);
    +         PreparedStatement stmt = con.prepareStatement("SELECT hero_end_date FROM characters_custom_data WHERE obj_Id=" + obj_Id);
    +         ResultSet rs = stmt.executeQuery();
    +         if (rs.next())
    +         {
    +            out = rs.getInt(1);
    +         }
    +         rs.close();
    +         rs = null;
    +         stmt.close();
    +         stmt = null;
    +      }
    +      catch (Exception e) {
    +         if(Config.ENABLE_ALL_EXCEPTIONS)
    +            e.printStackTrace();
    +         
    +         _log.log(Level.SEVERE, "Error: could not get hero_end_date from database: ", e);
    +      }
    +      finally {
    +         CloseUtil.close(con);         
    +         con = null;
    +      }
    +      return out;
    +   }
    +   
    +   /**
         * Checks if is in olympiad mode.
         *
         * @return true, if is in olympiad mode
    @@ -17716,6 +17793,7 @@
           int noble = 0;
           int donator = 0;
           long hero_end = 0;
    +      long donator_end = 0;
     
           Connection con = null;
     
    @@ -17734,6 +17812,7 @@
                 noble = rset.getInt("noble");
                 donator = rset.getInt("donator");
                 hero_end = rset.getLong("hero_end_date");
    +            donator_end = rset.getLong("donator_end_date");
              }
              rset.close();
              statement.close();
    @@ -17767,7 +17846,7 @@
              setNoble(true);
           }
     
    -      if(donator > 0)
    +      if(donator > 0 && (donator_end == 0 || donator_end > System.currentTimeMillis()))
           {
              setDonator(true);
           }

      Current date/time is 22nd November 2017, 05:53