Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/l2f/gameserver/handler/voicecommands/VoicedCommandHandler.java
- ===================================================================
- --- java/l2f/gameserver/handler/voicecommands/VoicedCommandHandler.java (revision 109)
- +++ java/l2f/gameserver/handler/voicecommands/VoicedCommandHandler.java (working copy)
- @@ -10,6 +10,7 @@
- import l2f.gameserver.handler.voicecommands.impl.Debug;
- import l2f.gameserver.handler.voicecommands.impl.Hellbound;
- import l2f.gameserver.handler.voicecommands.impl.Offline;
- +import l2f.gameserver.handler.voicecommands.impl.OfflineBuffs;
- import l2f.gameserver.handler.voicecommands.impl.Online;
- import l2f.gameserver.handler.voicecommands.impl.Password;
- import l2f.gameserver.handler.voicecommands.impl.RefferalSystem;
- @@ -25,14 +26,14 @@
- public class VoicedCommandHandler extends AbstractHolder
- {
- private static final VoicedCommandHandler _instance = new VoicedCommandHandler();
- -
- +
- public static VoicedCommandHandler getInstance()
- {
- return _instance;
- }
- -
- +
- private final Map<String, IVoicedCommandHandler> _datatable = new HashMap<>();
- -
- +
- private VoicedCommandHandler()
- {
- registerVoicedCommandHandler(new Atod());
- @@ -52,8 +53,9 @@
- registerVoicedCommandHandler(new ReportBot());
- registerVoicedCommandHandler(new res());
- registerVoicedCommandHandler(new RewardVote());
- + registerVoicedCommandHandler(new OfflineBuffs());
- }
- -
- +
- public void registerVoicedCommandHandler(IVoicedCommandHandler handler)
- {
- String[] ids = handler.getVoicedCommandList();
- @@ -62,7 +64,7 @@
- _datatable.put(element, handler);
- }
- }
- -
- +
- public IVoicedCommandHandler getVoicedCommandHandler(String voicedCommand)
- {
- String command = voicedCommand;
- @@ -70,16 +72,16 @@
- {
- command = voicedCommand.substring(0, voicedCommand.indexOf(" "));
- }
- -
- +
- return _datatable.get(command);
- }
- -
- +
- @Override
- public int size()
- {
- return _datatable.size();
- }
- -
- +
- @Override
- public void clear()
- {
- Index: java/l2f/gameserver/Config.java
- ===================================================================
- --- java/l2f/gameserver/Config.java (revision 109)
- +++ java/l2f/gameserver/Config.java (working copy)
- @@ -103,7 +103,7 @@
- public static final String DEFENSE_TOWNS_CONFIG_FILE = "config/events/DefenseTowns.properties";
- public static final String VIKTORINA_CONFIG_FILE = "config/events/Victorina.properties";
- public static final String PVP_MOD_CONFIG_FILE = "config/mod/PvPmod.properties";
- -
- + public static final String BUFF_STORE_CONFIG_FILE = "config/OfflineBuffer.properties";
- /** Community PvP */
- public static final String BOARD_MANAGER_CONFIG_FILE = "config/CommunityPvP/board_manager.properties";
- @@ -1729,7 +1729,16 @@
- public static boolean LOAD_CUSTOM_SPAWN;
- public static boolean SAVE_GM_SPAWN;
- -
- + public static boolean BUFF_STORE_MP_ENABLED;
- + public static boolean BUFF_STORE_ENABLED;
- + public static double BUFF_STORE_MP_CONSUME_MULTIPLIER;
- + public static boolean BUFF_STORE_ITEM_CONSUME_ENABLED;
- + public static int BUFF_STORE_NAME_COLOR;
- + public static int BUFF_STORE_TITLE_COLOR;
- + public static int BUFF_STORE_OFFLINE_NAME_COLOR;
- + public static List<Integer> BUFF_STORE_ALLOWED_CLASS_LIST;
- + public static List<Integer> BUFF_STORE_FORBIDDEN_SKILL_LIST;
- +
- public static void loadServerConfig()
- {
- ExProperties serverSettings = load(CONFIGURATION_FILE);
- @@ -3699,7 +3708,40 @@
- EVENT_CtF_DISALLOWED_SKILLS = eventCaptureTheFlagSettings.getProperty("CtF_DisallowedSkills", "").trim().replaceAll(" ", "").split(";");
- }
- -
- +
- + public static void loadBuffStoreConfig()
- + {
- + ExProperties buffStoreConfig = load(BUFF_STORE_CONFIG_FILE);
- +
- + BUFF_STORE_ENABLED = buffStoreConfig.getProperty("BuffStoreEnabled", false);
- + BUFF_STORE_MP_ENABLED = buffStoreConfig.getProperty("BuffStoreMpEnabled", true);
- + BUFF_STORE_MP_CONSUME_MULTIPLIER = buffStoreConfig.getProperty("BuffStoreMpConsumeMultiplier", 1.0D);
- + BUFF_STORE_ITEM_CONSUME_ENABLED = buffStoreConfig.getProperty("BuffStoreItemConsumeEnabled", true);
- +
- + BUFF_STORE_NAME_COLOR = Integer.decode("0x" + buffStoreConfig.getProperty("BuffStoreNameColor", "808080")).intValue();
- + BUFF_STORE_TITLE_COLOR = Integer.decode("0x" + buffStoreConfig.getProperty("BuffStoreTitleColor", "808080")).intValue();
- + BUFF_STORE_OFFLINE_NAME_COLOR = Integer.decode("0x" + buffStoreConfig.getProperty("BuffStoreOfflineNameColor", "808080")).intValue();
- +
- + String[] classes = buffStoreConfig.getProperty("BuffStoreAllowedClassList", "").split(",");
- + BUFF_STORE_ALLOWED_CLASS_LIST = new ArrayList();
- + if (classes.length > 0)
- + {
- + for (String classId : classes)
- + {
- + BUFF_STORE_ALLOWED_CLASS_LIST.add(Integer.valueOf(Integer.parseInt(classId)));
- + }
- + }
- + String[] skills = buffStoreConfig.getProperty("BuffStoreForbiddenSkillList", "").split(",");
- + BUFF_STORE_FORBIDDEN_SKILL_LIST = new ArrayList();
- + if (skills.length > 0)
- + {
- + for (String skillId : skills)
- + {
- + BUFF_STORE_FORBIDDEN_SKILL_LIST.add(Integer.valueOf(Integer.parseInt(skillId)));
- + }
- + }
- + }
- +
- public static void load()
- {
- loadServerConfig();
- @@ -3745,6 +3787,7 @@
- loadAcc_moveConfig();
- loadTeamVSTeamSettings();
- loadCaptureTheFlagSettings();
- + loadBuffStoreConfig();
- }
- private Config()
- Index: java/l2f/gameserver/model/base/ClassId.java
- ===================================================================
- --- java/l2f/gameserver/model/base/ClassId.java (revision 109)
- +++ java/l2f/gameserver/model/base/ClassId.java (working copy)
- @@ -1,20 +1,21 @@
- package l2f.gameserver.model.base;
- +import l2f.gameserver.model.Player;
- +import l2f.gameserver.network.serverpackets.components.CustomMessage;
- +
- /**
- - * This class defines all classes (ex : human fighter, darkFighter...) that a player can chose.<BR><BR>
- - *
- - * Data :<BR><BR>
- - * <li>id : The Identifier of the class</li>
- - * <li>isMage : True if the class is a mage class</li>
- - * <li>race : The race of this class</li>
- - * <li>parent : The parent ClassId for male or null if this class is the root</li>
- - * <li>parent2 : The parent2 ClassId for female or null if parent2 like parent</li>
- - * <li>level : The child level of this Class</li><BR><BR>
- + * This class defines all classes (ex : human fighter, darkFighter...) that a player can chose.<BR>
- + * <BR>
- + * Data :<BR>
- + * <BR>
- + * <li>id : The Identifier of the class</li> <li>isMage : True if the class is a mage class</li> <li>race : The race of this class</li> <li>parent : The parent ClassId for male or null if this class is the root</li> <li>parent2 : The parent2 ClassId for female or null if parent2 like parent</li> <li>
- + * level : The child level of this Class</li><BR>
- + * <BR>
- */
- public enum ClassId
- {
- fighter(0, false, Race.human, null, null, 1, null),
- -
- +
- warrior(1, false, Race.human, fighter, null, 2, null),
- gladiator(2, false, Race.human, warrior, null, 3, ClassType2.Warrior),
- warlord(3, false, Race.human, warrior, null, 3, ClassType2.Warrior),
- @@ -24,7 +25,7 @@
- rogue(7, false, Race.human, fighter, null, 2, null),
- treasureHunter(8, false, Race.human, rogue, null, 3, ClassType2.Rogue),
- hawkeye(9, false, Race.human, rogue, null, 3, ClassType2.Rogue),
- -
- +
- mage(10, true, Race.human, null, null, 1, null),
- wizard(11, true, Race.human, mage, null, 2, null),
- sorceror(12, true, Race.human, wizard, null, 3, ClassType2.Wizard),
- @@ -33,7 +34,7 @@
- cleric(15, true, Race.human, mage, null, 2, null),
- bishop(16, true, Race.human, cleric, null, 3, ClassType2.Healer),
- prophet(17, true, Race.human, cleric, null, 3, ClassType2.Enchanter),
- -
- +
- elvenFighter(18, false, Race.elf, null, null, 1, null),
- elvenKnight(19, false, Race.elf, elvenFighter, null, 2, null),
- templeKnight(20, false, Race.elf, elvenKnight, null, 3, ClassType2.Knight),
- @@ -41,14 +42,14 @@
- elvenScout(22, false, Race.elf, elvenFighter, null, 2, null),
- plainsWalker(23, false, Race.elf, elvenScout, null, 3, ClassType2.Rogue),
- silverRanger(24, false, Race.elf, elvenScout, null, 3, ClassType2.Rogue),
- -
- +
- elvenMage(25, true, Race.elf, null, null, 1, null),
- elvenWizard(26, true, Race.elf, elvenMage, null, 2, null),
- spellsinger(27, true, Race.elf, elvenWizard, null, 3, ClassType2.Wizard),
- elementalSummoner(28, true, Race.elf, elvenWizard, null, 3, ClassType2.Summoner),
- oracle(29, true, Race.elf, elvenMage, null, 2, null),
- elder(30, true, Race.elf, oracle, null, 3, ClassType2.Healer),
- -
- +
- darkFighter(31, false, Race.darkelf, null, null, 1, null),
- palusKnight(32, false, Race.darkelf, darkFighter, null, 2, null),
- shillienKnight(33, false, Race.darkelf, palusKnight, null, 3, ClassType2.Knight),
- @@ -56,36 +57,33 @@
- assassin(35, false, Race.darkelf, darkFighter, null, 2, null),
- abyssWalker(36, false, Race.darkelf, assassin, null, 3, ClassType2.Rogue),
- phantomRanger(37, false, Race.darkelf, assassin, null, 3, ClassType2.Rogue),
- -
- +
- darkMage(38, true, Race.darkelf, null, null, 1, null),
- darkWizard(39, true, Race.darkelf, darkMage, null, 2, null),
- spellhowler(40, true, Race.darkelf, darkWizard, null, 3, ClassType2.Wizard),
- phantomSummoner(41, true, Race.darkelf, darkWizard, null, 3, ClassType2.Summoner),
- shillienOracle(42, true, Race.darkelf, darkMage, null, 2, null),
- shillienElder(43, true, Race.darkelf, shillienOracle, null, 3, ClassType2.Healer),
- -
- +
- orcFighter(44, false, Race.orc, null, null, 1, null),
- orcRaider(45, false, Race.orc, orcFighter, null, 2, null),
- destroyer(46, false, Race.orc, orcRaider, null, 3, ClassType2.Warrior),
- orcMonk(47, false, Race.orc, orcFighter, null, 2, null),
- tyrant(48, false, Race.orc, orcMonk, null, 3, ClassType2.Warrior),
- -
- +
- orcMage(49, true, Race.orc, null, null, 1, null),
- orcShaman(50, true, Race.orc, orcMage, null, 2, null),
- overlord(51, true, Race.orc, orcShaman, null, 3, ClassType2.Enchanter),
- warcryer(52, true, Race.orc, orcShaman, null, 3, ClassType2.Enchanter),
- -
- +
- dwarvenFighter(53, false, Race.dwarf, null, null, 1, null),
- scavenger(54, false, Race.dwarf, dwarvenFighter, null, 2, null),
- bountyHunter(55, false, Race.dwarf, scavenger, null, 3, ClassType2.Warrior),
- artisan(56, false, Race.dwarf, dwarvenFighter, null, 2, null),
- warsmith(57, false, Race.dwarf, artisan, null, 3, ClassType2.Warrior),
- -
- +
- /*
- - * Dummy Entries (id's already in decimal format)
- - * btw FU NCSoft for the amount of work you put me
- - * through to do this!!
- - * <START>
- + * Dummy Entries (id's already in decimal format) btw FU NCSoft for the amount of work you put me through to do this!! <START>
- */
- dummyEntry1(58, false, null, null, null, 0, null),
- dummyEntry2(59, false, null, null, null, 0, null),
- @@ -118,10 +116,9 @@
- dummyEntry29(86, false, null, null, null, 0, null),
- dummyEntry30(87, false, null, null, null, 0, null),
- /*
- - * <END>
- - * Of Dummy entries
- + * <END> Of Dummy entries
- */
- -
- +
- duelist(88, false, Race.human, gladiator, null, 4, ClassType2.Warrior),
- dreadnought(89, false, Race.human, warlord, null, 4, ClassType2.Warrior),
- phoenixKnight(90, false, Race.human, paladin, null, 4, ClassType2.Knight),
- @@ -133,7 +130,7 @@
- arcanaLord(96, true, Race.human, warlock, null, 4, ClassType2.Summoner),
- cardinal(97, true, Race.human, bishop, null, 4, ClassType2.Healer),
- hierophant(98, true, Race.human, prophet, null, 4, ClassType2.Enchanter),
- -
- +
- evaTemplar(99, false, Race.elf, templeKnight, null, 4, ClassType2.Knight),
- swordMuse(100, false, Race.elf, swordSinger, null, 4, ClassType2.Enchanter),
- windRider(101, false, Race.elf, plainsWalker, null, 4, ClassType2.Rogue),
- @@ -141,7 +138,7 @@
- mysticMuse(103, true, Race.elf, spellsinger, null, 4, ClassType2.Wizard),
- elementalMaster(104, true, Race.elf, elementalSummoner, null, 4, ClassType2.Summoner),
- evaSaint(105, true, Race.elf, elder, null, 4, ClassType2.Healer),
- -
- +
- shillienTemplar(106, false, Race.darkelf, shillienKnight, null, 4, ClassType2.Knight),
- spectralDancer(107, false, Race.darkelf, bladedancer, null, 4, ClassType2.Enchanter),
- ghostHunter(108, false, Race.darkelf, abyssWalker, null, 4, ClassType2.Rogue),
- @@ -149,20 +146,20 @@
- stormScreamer(110, true, Race.darkelf, spellhowler, null, 4, ClassType2.Wizard),
- spectralMaster(111, true, Race.darkelf, phantomSummoner, null, 4, ClassType2.Summoner),
- shillienSaint(112, true, Race.darkelf, shillienElder, null, 4, ClassType2.Healer),
- -
- +
- titan(113, false, Race.orc, destroyer, null, 4, ClassType2.Warrior),
- grandKhauatari(114, false, Race.orc, tyrant, null, 4, ClassType2.Warrior),
- dominator(115, true, Race.orc, overlord, null, 4, ClassType2.Enchanter),
- doomcryer(116, true, Race.orc, warcryer, null, 4, ClassType2.Enchanter),
- -
- +
- fortuneSeeker(117, false, Race.dwarf, bountyHunter, null, 4, ClassType2.Warrior),
- maestro(118, false, Race.dwarf, warsmith, null, 4, ClassType2.Warrior),
- -
- +
- dummyEntry31(119, false, null, null, null, 0, null),
- dummyEntry32(120, false, null, null, null, 0, null),
- dummyEntry33(121, false, null, null, null, 0, null),
- dummyEntry34(122, false, null, null, null, 0, null),
- -
- +
- /**
- * Kamael
- */
- @@ -180,30 +177,38 @@
- trickster(134, false, Race.kamael, arbalester, null, 4, ClassType2.Rogue),
- inspector(135, false, Race.kamael, trooper, warder, 3, ClassType2.Enchanter),
- judicator(136, false, Race.kamael, inspector, null, 4, ClassType2.Enchanter);
- -
- +
- public static final ClassId[] VALUES = values();
- -
- +
- /** The Identifier of the Class<?> */
- private final int _id;
- -
- +
- /** True if the class is a mage class */
- private final boolean _isMage;
- -
- +
- /** The Race object of the class */
- private final Race _race;
- -
- +
- /** The parent ClassId for male or null if this class is a root */
- private final ClassId _parent;
- -
- +
- /** The parent2 ClassId for female or null if parent2 class is parent */
- private final ClassId _parent2;
- -
- +
- private final ClassType2 _type2;
- -
- +
- private final int _level;
- -
- +
- /**
- - * Constructor<?> of ClassId.<BR><BR>
- + * Constructor<?> of ClassId.<BR>
- + * <BR>
- + * @param id
- + * @param isMage
- + * @param race
- + * @param parent
- + * @param parent2
- + * @param level
- + * @param classType2
- */
- private ClassId(int id, boolean isMage, Race race, ClassId parent, ClassId parent2, int level, ClassType2 classType2)
- {
- @@ -215,83 +220,102 @@
- _level = level;
- _type2 = classType2;
- }
- -
- +
- /**
- - * Return the Identifier of the Class.<BR><BR>
- + * Return the Identifier of the Class.<BR>
- + * <BR>
- + * @return
- */
- public final int getId()
- {
- return _id;
- }
- -
- +
- /**
- - * Return True if the class is a mage class.<BR><BR>
- + * Return True if the class is a mage class.<BR>
- + * <BR>
- + * @return
- */
- public final boolean isMage()
- {
- return _isMage;
- }
- -
- +
- /**
- - * Return the Race object of the class.<BR><BR>
- + * Return the Race object of the class.<BR>
- + * <BR>
- + * @return
- */
- public final Race getRace()
- {
- return _race;
- }
- -
- +
- /**
- - * Return True if this Class<?> is a child of the selected ClassId.<BR><BR>
- - *
- + * Return True if this Class<?> is a child of the selected ClassId.<BR>
- + * <BR>
- * @param cid The parent ClassId to check
- + * @return
- */
- public final boolean childOf(ClassId cid)
- {
- - if(_parent == null)
- + if (_parent == null)
- + {
- return false;
- -
- - if(_parent == cid || _parent2 == cid)
- + }
- +
- + if ((_parent == cid) || (_parent2 == cid))
- + {
- return true;
- -
- + }
- +
- return _parent.childOf(cid);
- -
- +
- }
- -
- +
- /**
- - * Return True if this Class<?> is equal to the selected ClassId or a child of the selected ClassId.<BR><BR>
- - *
- + * Return True if this Class<?> is equal to the selected ClassId or a child of the selected ClassId.<BR>
- + * <BR>
- * @param cid The parent ClassId to check
- + * @return
- */
- public final boolean equalsOrChildOf(ClassId cid)
- {
- - return this == cid || childOf(cid);
- + return (this == cid) || childOf(cid);
- }
- -
- +
- /**
- - * Return the child level of this Class<?> (0=root, 1=child leve 1...).<BR><BR>
- - *
- - * @param cid The parent ClassId to check
- + * Return the child level of this Class<?> (0=root, 1=child leve 1...).<BR>
- + * <BR>
- + * @return
- */
- public final int level()
- {
- - if(_parent == null)
- + if (_parent == null)
- + {
- return 0;
- -
- + }
- +
- return 1 + _parent.level();
- }
- -
- +
- public final ClassId getParent(int sex)
- {
- - return sex == 0 || _parent2 == null ? _parent : _parent2;
- + return (sex == 0) || (_parent2 == null) ? _parent : _parent2;
- }
- -
- +
- public final int getLevel()
- {
- return _level;
- }
- -
- +
- public ClassType2 getType2()
- {
- return _type2;
- }
- +
- + public final String getName(Player player)
- + {
- + return new CustomMessage("l2s.gameserver.model.base.ClassId.name." + getId(), player, new Object[0]).toString();
- + }
- }
- \ No newline at end of file
- Index: dist/gameserver/data/zone/buff_store_only.xml
- ===================================================================
- --- dist/gameserver/data/zone/buff_store_only.xml (revision 0)
- +++ dist/gameserver/data/zone/buff_store_only.xml (working copy)
- @@ -0,0 +1,44 @@
- +<?xml version='1.0' encoding='utf-8'?>
- +<!DOCTYPE list SYSTEM "zone.dtd">
- +<list>
- + <zone name="[aden_buff_store_only_1]" type="buff_store_only">
- + <polygon>
- + <coords loc="147699 27395 -2260 -2180" />
- + <coords loc="148579 27394 -2260 -2180" />
- + <coords loc="148570 26577 -2260 -2180" />
- + <coords loc="147709 26572 -2260 -2180" />
- + </polygon>
- + </zone>
- + <zone name="[giran_buff_store_only_1]" type="buff_store_only">
- + <polygon>
- + <coords loc="83895 148084 -3460 -3360" />
- + <coords loc="83976 148080 -3460 -3360" />
- + <coords loc="83976 148002 -3460 -3360" />
- + <coords loc="84255 147995 -3460 -3360" />
- + <coords loc="84262 148074 -3460 -3360" />
- + <coords loc="84341 148073 -3460 -3360" />
- + <coords loc="84346 148348 -3460 -3360" />
- + <coords loc="84263 148356 -3460 -3360" />
- + <coords loc="84262 148467 -3460 -3360" />
- + <coords loc="83989 148461 -3460 -3360" />
- + <coords loc="83979 148359 -3460 -3360" />
- + <coords loc="83895 148360 -3460 -3360" />
- + </polygon>
- + </zone>
- + <zone name="[giran_buff_store_only_2]" type="buff_store_only">
- + <polygon>
- + <coords loc="83894 149163 -3460 -3360" />
- + <coords loc="83979 149163 -3460 -3360" />
- + <coords loc="83977 149241 -3460 -3360" />
- + <coords loc="84265 149243 -3460 -3360" />
- + <coords loc="84258 149164 -3460 -3360" />
- + <coords loc="84340 149159 -3460 -3360" />
- + <coords loc="84340 148886 -3460 -3360" />
- + <coords loc="84264 148879 -3460 -3360" />
- + <coords loc="84258 148781 -3460 -3360" />
- + <coords loc="83992 148781 -3460 -3360" />
- + <coords loc="83993 148869 -3460 -3360" />
- + <coords loc="83896 148878 -3460 -3360" />
- + </polygon>
- + </zone>
- +</list>
- \ No newline at end of file
- Index: java/l2f/gameserver/GameServer.java
- ===================================================================
- --- java/l2f/gameserver/GameServer.java (revision 109)
- +++ java/l2f/gameserver/GameServer.java (working copy)
- @@ -68,6 +68,7 @@
- import l2f.gameserver.tables.FakePlayersTable;
- import l2f.gameserver.tables.FishTable;
- import l2f.gameserver.tables.LevelUpTable;
- +import l2f.gameserver.tables.OfflineBuffersTable;
- import l2f.gameserver.tables.PetSkillsTable;
- import l2f.gameserver.tables.SkillTreeTable;
- import l2f.gameserver.taskmanager.ItemsAutoDestroy;
- @@ -85,7 +86,7 @@
- {
- public static final int AUTH_SERVER_PROTOCOL = 2;
- private static final Logger _log = LoggerFactory.getLogger(GameServer.class);
- -
- +
- public class GameServerListenerList extends ListenerList<GameServer>
- {
- public void onStart()
- @@ -98,7 +99,7 @@
- }
- }
- }
- -
- +
- public void onShutdown()
- {
- for (Listener<GameServer> listener : getListeners())
- @@ -110,31 +111,31 @@
- }
- }
- }
- -
- +
- public static GameServer _instance;
- -
- +
- private final SelectorThread<GameClient> _selectorThreads[];
- private TelnetServer statusServer;
- private final Version version;
- private final GameServerListenerList _listeners;
- -
- +
- private final int _serverStarted;
- -
- +
- public SelectorThread<GameClient>[] getSelectorThreads()
- {
- return _selectorThreads;
- }
- -
- +
- public int time()
- {
- return (int) (System.currentTimeMillis() / 1000);
- }
- -
- +
- public int uptime()
- {
- return time() - _serverStarted;
- }
- -
- +
- @SuppressWarnings("unchecked")
- public GameServer() throws Exception
- {
- @@ -142,9 +143,9 @@
- _instance = this;
- _serverStarted = time();
- _listeners = new GameServerListenerList();
- -
- +
- new File("./log/").mkdir();
- -
- +
- version = new Version(GameServer.class);
- // Initialize config
- Config.load();
- @@ -153,16 +154,16 @@
- // Initialize database
- Class.forName(Config.DATABASE_DRIVER).newInstance();
- DatabaseFactory.getInstance().getConnection().close();
- -
- +
- IdFactory _idFactory = IdFactory.getInstance();
- if (!_idFactory.isInitialized())
- {
- _log.error("Could not read object IDs from DB. Please Check Your Data.");
- throw new Exception("Could not initialize the ID factory");
- }
- -
- +
- CacheManager.getInstance();
- -
- +
- ThreadPoolManager.getInstance();
- Scripts.getInstance();
- GeoEngine.load();
- @@ -223,45 +224,48 @@
- ResidenceHolder.getInstance().callInit();
- EventHolder.getInstance().callInit();
- _log.info("==================================================");
- -
- +
- CastleManorManager.getInstance();
- -
- +
- Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
- -
- +
- _log.info("IdFactory: Free ObjectID's remaining: " + IdFactory.getInstance().size());
- -
- +
- CoupleManager.getInstance();
- -
- +
- if (Config.ALT_FISH_CHAMPIONSHIP_ENABLED)
- {
- FishingChampionShipManager.getInstance();
- }
- -
- +
- HellboundManager.getInstance();
- -
- +
- NaiaTowerManager.getInstance();
- NaiaCoreManager.getInstance();
- -
- +
- SoDManager.getInstance();
- SoIManager.getInstance();
- BloodAltarManager.getInstance();
- -
- +
- MiniGameScoreManager.getInstance();
- -
- +
- L2TopManager.getInstance();
- -
- + if (Config.BUFF_STORE_ENABLED)
- + {
- + OfflineBuffersTable.getInstance().restoreOfflineBuffers();
- + }
- MMOTopManager.getInstance();
- Protection.Init();
- SMSWayToPay.getInstance();
- -
- +
- Shutdown.getInstance().schedule(Config.RESTART_AT_TIME, Shutdown.RESTART);
- _log.info("GameServer Started");
- _log.info("Maximum Numbers of Connected Players: " + Config.MAXIMUM_ONLINE_USERS);
- -
- +
- GamePacketHandler gph = new GamePacketHandler();
- -
- +
- InetAddress serverAddr = Config.GAMESERVER_HOSTNAME.equalsIgnoreCase("*") ? null : InetAddress.getByName(Config.GAMESERVER_HOSTNAME);
- -
- +
- _selectorThreads = new SelectorThread[Config.PORTS_GAME.length];
- for (int i = 0; i < Config.PORTS_GAME.length; i++)
- {
- @@ -270,16 +274,16 @@
- _selectorThreads[i].start();
- }
- AuthServerCommunication.getInstance().start();
- -
- +
- if (Config.SERVICES_OFFLINE_TRADE_RESTORE_AFTER_RESTART)
- {
- ThreadPoolManager.getInstance().schedule(new RestoreOfflineTraders(), 30000L);
- }
- -
- +
- ThreadPoolManager.getInstance().scheduleAtFixedRate(new AutoAnnounce(), 60000, 60000);
- -
- +
- getListeners().onStart();
- -
- +
- if (Config.IS_TELNET_ENABLED)
- {
- statusServer = new TelnetServer();
- @@ -288,7 +292,7 @@
- {
- _log.info("Telnet server is currently disabled.");
- }
- -
- +
- _log.info("=================================================");
- String memUsage = new StringBuilder().append(StatsUtils.getMemUsage()).toString();
- for (String line : memUsage.split("\n"))
- @@ -297,27 +301,27 @@
- }
- _log.info("=================================================");
- }
- -
- +
- public GameServerListenerList getListeners()
- {
- return _listeners;
- }
- -
- +
- public static GameServer getInstance()
- {
- return _instance;
- }
- -
- +
- public <T extends GameListener> boolean addListener(T listener)
- {
- return _listeners.add(listener);
- }
- -
- +
- public <T extends GameListener> boolean removeListener(T listener)
- {
- return _listeners.remove(listener);
- }
- -
- +
- public static void checkFreePorts()
- {
- boolean binded = false;
- @@ -354,17 +358,17 @@
- }
- }
- }
- -
- +
- public static void main(String[] args) throws Exception
- {
- new GameServer();
- }
- -
- +
- public Version getVersion()
- {
- return version;
- }
- -
- +
- public TelnetServer getStatusServer()
- {
- return statusServer;
- Index: dist/gameserver/config/OfflineBuffer.properties
- ===================================================================
- --- dist/gameserver/config/OfflineBuffer.properties (revision 0)
- +++ dist/gameserver/config/OfflineBuffer.properties (working copy)
- @@ -0,0 +1,33 @@
- +# ---------------------------------------------------------------------------
- +# Buff Store System
- +# ---------------------------------------------------------------------------
- +
- +# Enable / Disable Sell Buff System
- +BuffStoreEnabled = True
- +
- +# If enabled then the buffer will consume his own mp for each buff sold
- +BuffStoreMpEnabled = True
- +
- +# Multiplier to control the mp consumed for each buff sold
- +# 1.0 is 100% of the original mp consume. Smaller value is less consume
- +BuffStoreMpConsumeMultiplier = 1.0
- +
- +# Enable specific skill item consume. Example: Skill Chant of Victory using Spirit Ore.
- +BuffStoreItemConsumeEnabled = True
- +
- +# Allowed class ids that can put their buffs on sale
- +# Format: class ids separated by commas
- +BuffStoreAllowedClassList = 15,16,97,17,98,29,30,105,42,43,112,50,116,51,115,100,21,107,34,94,103
- +
- +# Forbidden skill list, that cannot be put on sale
- +# Put all the skill ids separated by commas
- +BuffStoreForbiddenSkillList = 765,915,989,1507,1410,1411,764,914,988,327,1323,1325,1326,1327,1531,1427
- +
- +# Title Color of the store
- +BuffStoreTitleColor = 3427e1
- +
- +# Name Color of the store when its online
- +BuffStoreNameColor = ffffff
- +
- +# Name Color of the store when it goes offline
- +BuffStoreOfflineNameColor = 808080
- \ No newline at end of file
- Index: java/l2f/gameserver/network/clientpackets/Logout.java
- ===================================================================
- --- java/l2f/gameserver/network/clientpackets/Logout.java (revision 109)
- +++ java/l2f/gameserver/network/clientpackets/Logout.java (working copy)
- @@ -11,73 +11,85 @@
- {
- @Override
- protected void readImpl()
- - {}
- -
- + {
- + }
- +
- @Override
- protected void runImpl()
- {
- Player activeChar = getClient().getActiveChar();
- - if(activeChar == null)
- + if (activeChar == null)
- + {
- return;
- -
- + }
- +
- // Dont allow leaving if player is fighting
- - if(activeChar.isInCombat())
- + if (activeChar.isInCombat())
- {
- activeChar.sendPacket(SystemMsg.YOU_CANNOT_EXIT_THE_GAME_WHILE_IN_COMBAT);
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isFishing())
- +
- + if (activeChar.isFishing())
- {
- activeChar.sendPacket(SystemMsg.YOU_CANNOT_DO_THAT_WHILE_FISHING_2);
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isBlocked() && !activeChar.isFlying()) // Разрешаем выходить из игры если используется сервис HireWyvern. Вернет в начальную точку.
- +
- + if (activeChar.isBlocked() && !activeChar.isFlying()) // Разрешаем выходить из игры если используется сервис HireWyvern. Вернет в начальную точку.
- {
- activeChar.sendMessage(new CustomMessage("l2f.gameserver.clientpackets.Logout.OutOfControl", activeChar));
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isFestivalParticipant())
- - if(SevenSignsFestival.getInstance().isFestivalInitialized())
- +
- + if (activeChar.isFestivalParticipant())
- + {
- + if (SevenSignsFestival.getInstance().isFestivalInitialized())
- {
- activeChar.sendMessage("You cannot log out while you are a participant in a festival.");
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isInOlympiadMode())
- + }
- +
- + if (activeChar.isInOlympiadMode())
- {
- activeChar.sendMessage(new CustomMessage("l2f.gameserver.clientpackets.Logout.Olympiad", activeChar));
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.getVar("isPvPevents") != null)
- +
- + if (activeChar.getVar("isPvPevents") != null)
- {
- activeChar.sendMessage(activeChar.isLangRus() ? "Вы не можите выйти во время участия в ивенте!" : "You can follow any responses did not leave while participating in the event!");
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isInStoreMode() && !activeChar.isInZone(Zone.ZoneType.offshore) && Config.SERVICES_OFFLINE_TRADE_ALLOW_OFFSHORE)
- +
- + if (activeChar.isInStoreMode() && !activeChar.isInZone(Zone.ZoneType.offshore) && Config.SERVICES_OFFLINE_TRADE_ALLOW_OFFSHORE)
- {
- activeChar.sendMessage(new CustomMessage("trade.OfflineNoTradeZoneOnlyOffshore", activeChar));
- activeChar.sendActionFailed();
- return;
- }
- -
- - if(activeChar.isInObserverMode())
- +
- + if (activeChar.isInObserverMode())
- {
- activeChar.sendMessage(new CustomMessage("l2f.gameserver.clientpackets.Logout.Observer", activeChar));
- activeChar.sendActionFailed();
- return;
- }
- -
- + if (activeChar.isInBuffStore())
- + {
- + activeChar.offlineBuffStore();
- + }
- + else
- + {
- + activeChar.kick();
- + }
- activeChar.logout();
- }
- }
- \ No newline at end of file
- Index: java/l2f/gameserver/utils/Util.java
- ===================================================================
- --- java/l2f/gameserver/utils/Util.java (revision 109)
- +++ java/l2f/gameserver/utils/Util.java (working copy)
- @@ -17,12 +17,11 @@
- import l2f.gameserver.Config;
- import l2f.gameserver.model.reward.RewardList;
- -
- public class Util
- {
- static final String PATTERN = "0.0000000000E00";
- static final DecimalFormat df;
- -
- +
- /**
- * Форматтер для адены.<br>
- * Locale.KOREA заставляет его фортматировать через ",".<br>
- @@ -30,7 +29,7 @@
- * Для форматирования через "." убрать с аргументов Locale.FRANCE
- */
- private static NumberFormat adenaFormatter;
- -
- +
- static
- {
- adenaFormatter = NumberFormat.getIntegerInstance(Locale.FRANCE);
- @@ -38,7 +37,7 @@
- df.applyPattern(PATTERN);
- df.setPositivePrefix("+");
- }
- -
- +
- /**
- * Проверяет строку на соответсвие регулярному выражению
- * @param text Строка-источник
- @@ -52,27 +51,35 @@
- {
- pattern = Pattern.compile(template);
- }
- - catch(PatternSyntaxException e) // invalid template
- + catch (PatternSyntaxException e) // invalid template
- {
- e.printStackTrace();
- }
- - if(pattern == null)
- + if (pattern == null)
- + {
- return false;
- + }
- Matcher regexp = pattern.matcher(text);
- return regexp.matches();
- }
- -
- +
- public static String formatDouble(double x, String nanString, boolean forceExponents)
- {
- - if(Double.isNaN(x))
- + if (Double.isNaN(x))
- + {
- return nanString;
- - if(forceExponents)
- + }
- + if (forceExponents)
- + {
- return df.format(x);
- - if((long) x == x)
- + }
- + if ((long) x == x)
- + {
- return String.valueOf((long) x);
- + }
- return String.valueOf(x);
- }
- -
- +
- /**
- * Return amount of adena formatted with " " delimiter
- * @param amount
- @@ -82,14 +89,18 @@
- {
- return adenaFormatter.format(amount);
- }
- -
- +
- /**
- * форматирует время в секундах в дни/часы/минуты/секунды
- + * @param time
- + * @return
- */
- public static String formatTime(int time)
- {
- - if(time == 0)
- + if (time == 0)
- + {
- return "now";
- + }
- time = Math.abs(time);
- String ret = "";
- long numDays = time / 86400;
- @@ -99,257 +110,326 @@
- long numMins = time / 60;
- time -= numMins * 60;
- long numSeconds = time;
- - if(numDays > 0)
- + if (numDays > 0)
- + {
- ret += numDays + "d ";
- - if(numHours > 0)
- + }
- + if (numHours > 0)
- + {
- ret += numHours + "h ";
- - if(numMins > 0)
- + }
- + if (numMins > 0)
- + {
- ret += numMins + "m ";
- - if(numSeconds > 0)
- + }
- + if (numSeconds > 0)
- + {
- ret += numSeconds + "s";
- + }
- return ret.trim();
- }
- -
- +
- /**
- - * Инструмент для подсчета выпавших вещей с учетом рейтов.
- - * Возвращает 0 если шанс не прошел, либо количество если прошел.
- - * Корректно обрабатывает шансы превышающие 100%.
- - * Шанс в 1:1000000 (L2Drop.MAX_CHANCE)
- + * Инструмент для подсчета выпавших вещей с учетом рейтов. Возвращает 0 если шанс не прошел, либо количество если прошел. Корректно обрабатывает шансы превышающие 100%. Шанс в 1:1000000 (L2Drop.MAX_CHANCE)
- + * @param min
- + * @param max
- + * @param calcChance
- + * @param rate
- + * @return
- */
- public static long rollDrop(long min, long max, double calcChance, boolean rate)
- {
- - if(calcChance <= 0 || min <= 0 || max <= 0)
- + if ((calcChance <= 0) || (min <= 0) || (max <= 0))
- + {
- return 0;
- + }
- int dropmult = 1;
- - if(rate)
- + if (rate)
- + {
- calcChance *= Config.RATE_DROP_ITEMS;
- - if(calcChance > RewardList.MAX_CHANCE)
- - if(calcChance % RewardList.MAX_CHANCE == 0) // если кратен 100% то тупо умножаем количество
- + }
- + if (calcChance > RewardList.MAX_CHANCE)
- + {
- + if ((calcChance % RewardList.MAX_CHANCE) == 0)
- + {
- dropmult = (int) (calcChance / RewardList.MAX_CHANCE);
- + }
- else
- {
- dropmult = (int) Math.ceil(calcChance / RewardList.MAX_CHANCE); // множитель равен шанс / 100% округление вверх
- calcChance = calcChance / dropmult; // шанс равен шанс / множитель
- }
- + }
- return Rnd.chance(calcChance / 10000.) ? Rnd.get(min * dropmult, max * dropmult) : 0;
- }
- -
- +
- public static int packInt(int[] a, int bits) throws Exception
- {
- int m = 32 / bits;
- - if(a.length > m)
- + if (a.length > m)
- + {
- throw new Exception("Overflow");
- -
- + }
- +
- int result = 0;
- int next;
- int mval = (int) Math.pow(2, bits);
- - for(int i = 0; i < m; i++)
- + for (int i = 0; i < m; i++)
- {
- result <<= bits;
- - if(a.length > i)
- + if (a.length > i)
- {
- next = a[i];
- - if(next >= mval || next < 0)
- + if ((next >= mval) || (next < 0))
- + {
- throw new Exception("Overload, value is out of range");
- + }
- }
- else
- + {
- next = 0;
- + }
- result += next;
- }
- return result;
- }
- -
- +
- public static long packLong(int[] a, int bits) throws Exception
- {
- int m = 64 / bits;
- - if(a.length > m)
- + if (a.length > m)
- + {
- throw new Exception("Overflow");
- -
- + }
- +
- long result = 0;
- int next;
- int mval = (int) Math.pow(2, bits);
- - for(int i = 0; i < m; i++)
- + for (int i = 0; i < m; i++)
- {
- result <<= bits;
- - if(a.length > i)
- + if (a.length > i)
- {
- next = a[i];
- - if(next >= mval || next < 0)
- + if ((next >= mval) || (next < 0))
- + {
- throw new Exception("Overload, value is out of range");
- + }
- }
- else
- + {
- next = 0;
- + }
- result += next;
- }
- return result;
- }
- -
- +
- public static int[] unpackInt(int a, int bits)
- {
- int m = 32 / bits;
- int mval = (int) Math.pow(2, bits);
- int[] result = new int[m];
- int next;
- - for(int i = m; i > 0; i--)
- + for (int i = m; i > 0; i--)
- {
- next = a;
- a = a >> bits;
- - result[i - 1] = next - a * mval;
- + result[i - 1] = next - (a * mval);
- }
- return result;
- }
- -
- +
- public static int[] unpackLong(long a, int bits)
- {
- int m = 64 / bits;
- int mval = (int) Math.pow(2, bits);
- int[] result = new int[m];
- long next;
- - for(int i = m; i > 0; i--)
- + for (int i = m; i > 0; i--)
- {
- next = a;
- a = a >> bits;
- - result[i - 1] = (int) (next - a * mval);
- + result[i - 1] = (int) (next - (a * mval));
- }
- return result;
- }
- -
- +
- public static float[] parseCommaSeparatedFloatArray(String s)
- {
- if (s.isEmpty())
- + {
- return new float[0];
- + }
- String[] tmp = s.replaceAll(",", ";").replaceAll("\\n", ";").split(";");
- float[] val = new float[tmp.length];
- for (int i = 0; i < tmp.length; i++)
- + {
- val[i] = Float.parseFloat(tmp[i]);
- + }
- return val;
- }
- -
- +
- public static int[] parseCommaSeparatedIntegerArray(String s)
- {
- if (s.isEmpty())
- + {
- return new int[0];
- + }
- String[] tmp = s.replaceAll(",", ";").replaceAll("\\n", ";").split(";");
- int[] val = new int[tmp.length];
- for (int i = 0; i < tmp.length; i++)
- + {
- val[i] = Integer.parseInt(tmp[i]);
- + }
- return val;
- }
- -
- +
- public static long[] parseCommaSeparatedLongArray(String s)
- {
- if (s.isEmpty())
- + {
- return new long[0];
- + }
- String[] tmp = s.replaceAll(",", ";").replaceAll("\\n", ";").split(";");
- long[] val = new long[tmp.length];
- for (int i = 0; i < tmp.length; i++)
- + {
- val[i] = Long.parseLong(tmp[i]);
- + }
- return val;
- }
- -
- +
- public static long[][] parseStringForDoubleArray(String s)
- {
- String[] temp = s.replaceAll("\\n", ";").split(";");
- long[][] val = new long[temp.length][];
- -
- +
- for (int i = 0; i < temp.length; i++)
- + {
- val[i] = parseCommaSeparatedLongArray(temp[i]);
- + }
- return val;
- }
- -
- - /** Just alias */
- +
- + /**
- + * Just alias
- + * @param glueStr
- + * @param strings
- + * @param startIdx
- + * @param maxCount
- + * @return
- + */
- public static String joinStrings(String glueStr, String[] strings, int startIdx, int maxCount)
- {
- return Strings.joinStrings(glueStr, strings, startIdx, maxCount);
- }
- -
- - /** Just alias */
- +
- + /**
- + * Just alias
- + * @param glueStr
- + * @param strings
- + * @param startIdx
- + * @return
- + */
- public static String joinStrings(String glueStr, String[] strings, int startIdx)
- {
- return Strings.joinStrings(glueStr, strings, startIdx, -1);
- }
- -
- +
- public static boolean isNumber(String s)
- {
- try
- {
- Double.parseDouble(s);
- }
- - catch(NumberFormatException e)
- + catch (NumberFormatException e)
- {
- return false;
- }
- return true;
- }
- -
- +
- public static String dumpObject(Object o, boolean simpleTypes, boolean parentFields, boolean ignoreStatics)
- {
- Class<?> cls = o.getClass();
- String val, type, result = "[" + (simpleTypes ? cls.getSimpleName() : cls.getName()) + "\n";
- Object fldObj;
- - List<Field> fields = new ArrayList<Field>();
- - while(cls != null)
- + List<Field> fields = new ArrayList<>();
- + while (cls != null)
- {
- - for(Field fld : cls.getDeclaredFields())
- - if(!fields.contains(fld))
- + for (Field fld : cls.getDeclaredFields())
- + {
- + if (!fields.contains(fld))
- {
- - if(ignoreStatics && Modifier.isStatic(fld.getModifiers()))
- + if (ignoreStatics && Modifier.isStatic(fld.getModifiers()))
- + {
- continue;
- + }
- fields.add(fld);
- }
- + }
- cls = cls.getSuperclass();
- - if(!parentFields)
- + if (!parentFields)
- + {
- break;
- + }
- }
- -
- - for(Field fld : fields)
- +
- + for (Field fld : fields)
- {
- fld.setAccessible(true);
- try
- {
- fldObj = fld.get(o);
- - if(fldObj == null)
- + if (fldObj == null)
- + {
- val = "NULL";
- + }
- else
- + {
- val = fldObj.toString();
- + }
- }
- - catch(Throwable e)
- + catch (Throwable e)
- {
- e.printStackTrace();
- val = "<ERROR>";
- }
- type = simpleTypes ? fld.getType().getSimpleName() : fld.getType().toString();
- -
- +
- result += String.format("\t%s [%s] = %s;\n", fld.getName(), type, val);
- }
- -
- +
- result += "]\n";
- return result;
- }
- -
- +
- private static Pattern _pattern = Pattern.compile("<!--TEMPLET(\\d+)(.*?)TEMPLET-->", Pattern.DOTALL);
- -
- +
- public static HashMap<Integer, String> parseTemplate(String html)
- {
- Matcher m = _pattern.matcher(html);
- - HashMap<Integer, String> tpls = new HashMap<Integer, String>();
- - while(m.find())
- + HashMap<Integer, String> tpls = new HashMap<>();
- + while (m.find())
- {
- tpls.put(Integer.parseInt(m.group(1)), m.group(2));
- html = html.replace(m.group(0), "");
- }
- -
- +
- tpls.put(0, html);
- return tpls;
- }
- -
- +
- public static boolean isDigit(String text)
- {
- if (text == null)
- + {
- return false;
- + }
- return text.matches("[0-9]+");
- }
- -
- +
- /**
- * @param raw
- * @return
- @@ -358,37 +438,37 @@
- {
- return printData(raw, raw.length);
- }
- -
- +
- public static String fillHex(int data, int digits)
- {
- String number = Integer.toHexString(data);
- - for(int i = number.length(); i < digits; i++)
- + for (int i = number.length(); i < digits; i++)
- {
- number = "0" + number;
- }
- return number;
- }
- -
- +
- public static String printData(byte[] data, int len)
- {
- StringBuffer result = new StringBuffer();
- int counter = 0;
- - for(int i = 0; i < len; i++)
- + for (int i = 0; i < len; i++)
- {
- - if(counter % 16 == 0)
- + if ((counter % 16) == 0)
- {
- result.append(fillHex(i, 4) + ": ");
- }
- result.append(fillHex(data[i] & 0xff, 2) + " ");
- counter++;
- - if(counter == 16)
- + if (counter == 16)
- {
- result.append(" ");
- int charpoint = i - 15;
- - for(int a = 0; a < 16; a++)
- + for (int a = 0; a < 16; a++)
- {
- int t1 = data[charpoint++];
- - if(t1 > 0x1f && t1 < 0x80)
- + if ((t1 > 0x1f) && (t1 < 0x80))
- {
- result.append((char) t1);
- }
- @@ -402,17 +482,17 @@
- }
- }
- int rest = data.length % 16;
- - if(rest > 0)
- + if (rest > 0)
- {
- - for(int i = 0; i < 17 - rest; i++)
- + for (int i = 0; i < (17 - rest); i++)
- {
- result.append(" ");
- }
- int charpoint = data.length - rest;
- - for(int a = 0; a < rest; a++)
- + for (int a = 0; a < rest; a++)
- {
- int t1 = data[charpoint++];
- - if(t1 > 0x1f && t1 < 0x80)
- + if ((t1 > 0x1f) && (t1 < 0x80))
- {
- result.append((char) t1);
- }
- @@ -425,15 +505,52 @@
- }
- return result.toString();
- }
- -
- +
- public static byte[] generateHex(int size)
- {
- byte[] array = new byte[size];
- Random rnd = new Random();
- - for(int i = 0; i < size; i++)
- + for (int i = 0; i < size; i++)
- {
- array[i] = (byte) rnd.nextInt(256);
- }
- return array;
- }
- +
- + public static String convertToLineagePriceFormat(double price)
- + {
- + if (price < 10000.0D)
- + {
- + return Math.round(price) + "a";
- + }
- + if (price < 1000000.0D)
- + {
- + return reduceDecimals(price / 1000.0D, 1) + "k";
- + }
- + if (price < 1000000000.0D)
- + {
- + return reduceDecimals(price / 1000.0D / 1000.0D, 1) + "kk";
- + }
- + return reduceDecimals(price / 1000.0D / 1000.0D / 1000.0D, 1) + "kkk";
- + }
- +
- + public static String reduceDecimals(double original, int nDecim)
- + {
- + return reduceDecimals(original, nDecim, false);
- + }
- +
- + public static String reduceDecimals(double original, int nDecim, boolean round)
- + {
- + String decimals = "#";
- + if (nDecim > 0)
- + {
- + decimals = decimals + ".";
- + for (int i = 0; i < nDecim; i++)
- + {
- + decimals = decimals + "#";
- + }
- + }
- + DecimalFormat df = new DecimalFormat(decimals);
- + return df.format(round ? Math.round(original) : original).replace(",", ".");
- + }
- }
- \ No newline at end of file
- Index: dist/gameserver/data/html-en/command/buffstore/buff_store_buffer.htm
- ===================================================================
- --- dist/gameserver/data/html-en/command/buffstore/buff_store_buffer.htm (revision 0)
- +++ dist/gameserver/data/html-en/command/buffstore/buff_store_buffer.htm (working copy)
- @@ -0,0 +1,69 @@
- +<html><head><title>%bufferName% Store</title>
- +<body>
- + <img src=L2UI.SquareGray width=275 height=1>
- + <table width=275 height=30 bgcolor=7d9399>
- + <tr>
- + <td height=10></td>
- + </tr>
- + <tr>
- + <td fixwidth=275 align=center>
- + <font name=hs12>%bufferClass% Lvl %bufferLvl%+</font>
- + </td>
- + </tr>
- + <tr>
- + <td height=10></td>
- + </tr>
- + </table>
- + <img src=L2UI.SquareGray width=275 height=1>
- + <table width=275 height=30 bgcolor=444a45>
- + <tr>
- + <td height=10></td>
- + </tr>
- + <tr>
- + <td fixwidth=275 align=center>
- + Buff Price: <font color=f3ef8e>%buffPrice%</font>
- + </td>
- + </tr>
- + <tr>
- + <td height=10></td>
- + </tr>
- + </table>
- + <img src=L2UI.SquareGray width=275 height=1>
- + <table cellpadding=0>
- + <tr>
- + <td height=10></td>
- + </tr>
- + %buffs%
- + </table>
- + <img src=L2UI.SquareGray width=270 height=1>
- + <table fixwidth=270 height=30 bgcolor=171612>
- + <tr>
- + <td height=5></td>
- + </tr>
- + <tr>
- + <td width=110 align=right>
- + %previousPageButton%
- + </td>
- + <td width=50 align=center>
- + %pageCount%
- + </td>
- + <td width=105>
- + %nextPageButton%
- + </td>
- + </tr>
- + </table>
- + <img src=L2UI.SquareGray width=270 height=1>
- + <br>
- + <table width=250>
- + <tr>
- + <td width=150>
- + <button value="For Player" action="bypass -h BuffStore bufflist %bufferId% player %page%" width=120 height=22 back=L2UI_ct1.button_df fore=L2UI_ct1.button_df>
- + </td>
- + <td>
- + <button value="For Summon" action="bypass -h BuffStore bufflist %bufferId% summon %page%" width=120 height=22 back=L2UI_ct1.button_df fore=L2UI_ct1.button_df>
- + </td>
- + </tr>
- + </table>
- + <br>
- +</body>
- +</html>
- \ No newline at end of file
- Index: java/l2f/gameserver/instancemanager/OfflineBufferManager.java
- ===================================================================
- --- java/l2f/gameserver/instancemanager/OfflineBufferManager.java (revision 0)
- +++ java/l2f/gameserver/instancemanager/OfflineBufferManager.java (working copy)
- @@ -0,0 +1,388 @@
- +package l2f.gameserver.instancemanager;
- +
- +import java.util.HashMap;
- +import java.util.Iterator;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.StringTokenizer;
- +import java.util.concurrent.ConcurrentHashMap;
- +import java.util.logging.Logger;
- +
- +import l2f.gameserver.Config;
- +import l2f.gameserver.model.Player;
- +import l2f.gameserver.model.Skill;
- +import l2f.gameserver.model.Zone;
- +import l2f.gameserver.model.base.ClassId;
- +import l2f.gameserver.model.entity.olympiad.Olympiad;
- +import l2f.gameserver.network.serverpackets.NpcHtmlMessage;
- +import l2f.gameserver.tables.SkillTable;
- +import l2f.gameserver.utils.PositionUtils;
- +import l2f.gameserver.utils.TradeHelper;
- +import l2f.gameserver.utils.Util;
- +
- +public class OfflineBufferManager
- +{
- + protected static final Logger _log = Logger.getLogger(OfflineBufferManager.class.getName());
- + private static final int MAX_INTERACT_DISTANCE = 100;
- + private final Map<Integer, BufferData> _buffStores;
- +
- + public OfflineBufferManager()
- + {
- + this._buffStores = new ConcurrentHashMap();
- + }
- +
- + public Map<Integer, BufferData> getBuffStores()
- + {
- + return this._buffStores;
- + }
- +
- + public void processBypass(Player player, String command)
- + {
- + StringTokenizer st = new StringTokenizer(command, " ");
- + st.nextToken();
- + switch (st.nextToken())
- + {
- + case "setstore":
- + try
- + {
- + int price = Integer.parseInt(st.nextToken());
- + String title = st.nextToken();
- + while (st.hasMoreTokens())
- + {
- + title = title + " " + st.nextToken();
- + }
- + title = title.trim();
- + if (!this._buffStores.containsKey(Integer.valueOf(player.getObjectId())))
- + {
- + if (player.getPrivateStoreType() != 0)
- + {
- + player.sendMessage(player.isLangRus() ? "У вас уже есть магазин" : "You already have a store");
- + }
- + else if (!Config.BUFF_STORE_ALLOWED_CLASS_LIST.contains(Integer.valueOf(player.getClassId().getId())))
- + {
- + player.sendMessage(player.isLangRus() ? "Вашей профессии нельзя открывать магазин бафов" : "Your profession is not allowed to set an Buff Store");
- + }
- + else if (TradeHelper.checksIfCanOpenStore(player, 20))
- + {
- + if ((title.isEmpty()) || (title.length() >= 29))
- + {
- + player.sendMessage(player.isLangRus() ? "Максимальное кол-во символов до 29, используйте титул по короче!" : "You must put a title for this store and it must have less than 29 characters");
- + throw new Exception();
- + }
- + if ((price < 1) || (price > 10000000))
- + {
- + player.sendMessage(player.isLangRus() ? "Цена для каждого баффа должна быть между 1-10кк Аден" : "The price for each buff must be between 1 and 10kk");
- + throw new Exception();
- + }
- + if ((!player.isGM()) && (!player.isInZone(Zone.ZoneType.buff_store_only)))
- + {
- + player.sendMessage(player.isLangRus() ? "Вы не можете открыть магазин тут, поищите специальные места где можно открывать магазин!" : "You can't put a buff store here. Look for special designated zones or clan halls");
- + throw new Exception();
- + }
- + if ((player.isAlikeDead()) || (player.isInOlympiadMode()) || (player.isMounted()) || (player.isCastingNow()) || (player.getOlympiadObserveGame() != null) || (player.getOlympiadGame() != null) || (Olympiad.isRegisteredInComp(player)))
- + {
- + player.sendMessage(player.isLangRus() ? "Вы не соблюдаете правила открытие магазина, попробуйте позже!" : "You don't meet the required conditions to put a buff store right now");
- + throw new Exception();
- + }
- + BufferData buffer = new BufferData(player, title, price, null);
- + for (Skill skill : player.getAllSkills())
- + {
- + if ((skill.isActive()) && (skill.getSkillType() == Skill.SkillType.BUFF) && (!skill.isHeroic()) && (skill.getTargetType() != Skill.SkillTargetType.TARGET_SELF) && (skill.getTargetType() != Skill.SkillTargetType.TARGET_PET) && ((!player.getClassId().equalsOrChildOf(ClassId.doomcryer)) || (skill.getTargetType() != Skill.SkillTargetType.TARGET_CLAN)) && ((!player.getClassId().equalsOrChildOf(ClassId.dominator)) || ((skill.getTargetType() != Skill.SkillTargetType.TARGET_PARTY) && (skill.getTargetType() != Skill.SkillTargetType.TARGET_ONE))) && (!Config.BUFF_STORE_FORBIDDEN_SKILL_LIST.contains(Integer.valueOf(skill.getId()))))
- + {
- + buffer.getBuffs().put(Integer.valueOf(skill.getId()), skill);
- + }
- + }
- + if (buffer.getBuffs().isEmpty())
- + {
- + player.sendMessage(player.isLangRus() ? "У вас нет не одного баффа который вы бы могли продать." : "You don't have any available buff to put on sale in the store");
- + throw new Exception();
- + }
- + this._buffStores.put(Integer.valueOf(player.getObjectId()), buffer);
- + player.sitDown(null);
- + player.setTitleColor(Config.BUFF_STORE_TITLE_COLOR);
- + player.setTitle(title);
- + player.setNameColor(Config.BUFF_STORE_NAME_COLOR);
- + player.broadcastUserInfo(true);
- + player.setPrivateStoreType(20);
- + player.sendMessage(player.isLangRus() ? "Ваш магазин был успешно установлен!" : "Your Buff Store was set succesfully");
- + }
- + }
- + }
- + catch (NumberFormatException e)
- + {
- + player.sendMessage("The price for each buff must be between 1 and 10kk");
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile("command/buffstore/buff_store_create.htm");
- + player.sendPacket(html);
- + }
- + catch (Exception e)
- + {
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile("command/buffstore/buff_store_create.htm");
- + player.sendPacket(html);
- + }
- + case "stopstore":
- + if (player.getPrivateStoreType() != 20)
- + {
- + player.sendMessage(player.isLangRus() ? "У вас нет магазина на данный момент!" : "You dont have any store set right now");
- + }
- + else
- + {
- + this._buffStores.remove(Integer.valueOf(player.getObjectId()));
- + player.setPrivateStoreType(0);
- + player.standUp();
- +
- + player.setTitleColor(16777079);
- + player.setTitle("");
- + player.setNameColor(Config.NORMAL_NAME_COLOUR);
- + player.broadcastUserInfo(true);
- +
- + player.sendMessage("Your Buff Store was removed succesfuly");
- + }
- + break;
- + case "bufflist":
- + try
- + {
- + int playerId = Integer.parseInt(st.nextToken());
- + boolean isPlayer = st.hasMoreTokens() ? st.nextToken().equalsIgnoreCase("player") : true;
- + int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0;
- + BufferData buffer = _buffStores.get(Integer.valueOf(playerId));
- + if (buffer != null)
- + {
- + if (PositionUtils.calculateDistance(player, buffer.getOwner(), true) <= 100.0D)
- + {
- + if ((!isPlayer) && (player.getPet() == null))
- + {
- + player.sendMessage(player.isLangRus() ? "У вас нет активных самонов на данный момент!" : "You don't have any active summon right now");
- + showStoreWindow(player, buffer, !isPlayer, page);
- + }
- + else
- + {
- + showStoreWindow(player, buffer, isPlayer, page);
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + case "purchasebuff":
- + try
- + {
- + int playerId = Integer.parseInt(st.nextToken());
- + boolean isPlayer = st.hasMoreTokens() ? st.nextToken().equalsIgnoreCase("player") : true;
- + int buffId = Integer.parseInt(st.nextToken());
- + int page = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0;
- + BufferData buffer = this._buffStores.get(Integer.valueOf(playerId));
- + if (buffer != null)
- + {
- + if (buffer.getBuffs().containsKey(Integer.valueOf(buffId)))
- + {
- + if (PositionUtils.calculateDistance(player, buffer.getOwner(), true) <= 100.0D)
- + {
- + if ((!isPlayer) && (player.getPet() == null))
- + {
- + player.sendMessage(player.isLangRus() ? "У вас нет активных самонов на данный момент!" : "You don't have any active summon right now");
- + showStoreWindow(player, buffer, !isPlayer, page);
- + }
- + else if ((player.getPvpFlag() > 0) || (player.isInCombat()) || (player.getKarma() > 0) || (player.isAlikeDead()) || (player.isInJail()) || (player.isInOlympiadMode()) || (player.isCursedWeaponEquipped()) || (player.isInStoreMode()) || (player.isInTrade()) || (player.getEnchantScroll() != null) || (player.isFishing()))
- + {
- + player.sendMessage("You don't meet the required conditions to use the buffer right now");
- + }
- + else
- + {
- + double buffMpCost = Config.BUFF_STORE_MP_ENABLED ? buffer.getBuffs().get(Integer.valueOf(buffId)).getMpConsume() * Config.BUFF_STORE_MP_CONSUME_MULTIPLIER : 0.0D;
- + if ((buffMpCost > 0.0D) && (buffer.getOwner().getCurrentMp() < buffMpCost))
- + {
- + player.sendMessage(player.isLangRus() ? "У владельца недостаточно МП =(" : "This store doesn't have enough mp to give sell you this buff");
- + showStoreWindow(player, buffer, isPlayer, page);
- + }
- + else
- + {
- + int buffPrice = (player.getClanId() == buffer.getOwner().getClanId()) && (player.getClanId() != 0) ? 0 : buffer.getBuffPrice();
- + if ((buffPrice > 0) && (player.getAdena() < buffPrice))
- + {
- + player.sendMessage(player.isLangRus() ? "У вас не достаточно Адены!" : "You don't have enough adena to purchase a buff");
- + }
- + else if ((buffPrice > 0) && (!player.reduceAdena(buffPrice, true)))
- + {
- + player.sendMessage(player.isLangRus() ? "У вас не достаточно Адены!" : "You don't have enough adena to purchase a buff");
- + }
- + else
- + {
- + if (buffPrice > 0)
- + {
- + buffer.getOwner().addAdena(buffPrice, true);
- + }
- + if (buffMpCost > 0.0D)
- + {
- + buffer.getOwner().reduceCurrentMp(buffMpCost, null);
- + }
- + if (isPlayer)
- + {
- + buffer.getBuffs().get(Integer.valueOf(buffId)).getEffects(player, player, false, false);
- + }
- + else
- + {
- + buffer.getBuffs().get(Integer.valueOf(buffId)).getEffects(player.getPet(), player.getPet(), false, false);
- + }
- + player.sendMessage("You have bought " + buffer.getBuffs().get(Integer.valueOf(buffId)).getName() + " from " + player.getName());
- + showStoreWindow(player, buffer, isPlayer, page);
- + }
- + }
- + }
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + private void showStoreWindow(Player player, BufferData buffer, boolean isForPlayer, int page)
- + {
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile("command/buffstore/buff_store_buffer.htm");
- +
- + int MAX_ENTRANCES_PER_ROW = 7;
- + double entrancesSize = buffer.getBuffs().size();
- + int maxPage = (int) Math.ceil(entrancesSize / 7.0D) - 1;
- + int currentPage = Math.min(maxPage, page);
- +
- + StringBuilder buffList = new StringBuilder();
- + Iterator<Skill> it = buffer.getBuffs().values().iterator();
- + int i = 0;
- + boolean changeColor = false;
- + while (it.hasNext())
- + {
- + if (i < (currentPage * 7))
- + {
- + it.next();
- + i++;
- + }
- + else
- + {
- + if (i >= ((currentPage * 7) + 7))
- + {
- + break;
- + }
- + Skill buff = it.next();
- + int baseMaxLvl = SkillTable.getInstance().getBaseLevel(buff.getId());
- +
- + buffList.append("<tr>");
- + buffList.append("<td fixwidth=300>");
- + buffList.append("<table height=36 cellspacing=-1 bgcolor=" + (changeColor ? "171612" : "23221e") + ">");
- + buffList.append("<tr>");
- + buffList.append("<td width=42 valign=top><button value=\"\" action=\"bypass -h BuffStore purchasebuff " + buffer.getOwner().getObjectId() + " " + (isForPlayer ? "player" : "summon") + " " + buff.getId() + " " + currentPage + "\" width=32 height=32 back=" + buff.getIcon() + " fore=" + buff.getIcon() + "></td>");
- + if (buff.getLevel() > baseMaxLvl)
- + {
- + int enchantType = (buff.getLevel() - baseMaxLvl) / buff.getEnchantLevelCount();
- + int enchantLvl = (buff.getLevel() - baseMaxLvl) % buff.getEnchantLevelCount();
- + enchantLvl = enchantLvl == 0 ? buff.getEnchantLevelCount() : enchantLvl;
- + buffList.append("<td fixwidth=240>" + buff.getName() + " <font color=a3a3a3>Lv</font> <font color=ae9978>" + baseMaxLvl + "</font>");
- + buffList.append(" <font color=ffd969>+" + enchantLvl + " " + (enchantType >= 3 ? "Power" : enchantType >= 2 ? "Cost" : "Time") + "</font></td>");
- + }
- + else
- + {
- + buffList.append("<td fixwidth=240>" + buff.getName() + " <font color=a3a3a3>Lv</font> <font color=ae9978>" + buff.getLevel() + "</font></td>");
- + }
- + buffList.append("</tr>");
- + buffList.append("</table>");
- + buffList.append("</td>");
- + buffList.append("</tr>");
- + buffList.append("<tr>");
- + buffList.append("<td height=10></td>");
- + buffList.append("</tr>");
- + i++;
- + changeColor = !changeColor;
- + }
- + }
- + String previousPageButton;
- + if (currentPage > 0)
- + {
- + previousPageButton = "<button value=\"\" width=16 height=16 action=\"bypass -h BuffStore bufflist " + buffer.getOwner().getObjectId() + " " + (isForPlayer ? "player" : "summon") + " " + (currentPage - 1) + "\" fore=L2UI_CH3.shortcut_prev_down back=L2UI_CH3.shortcut_prev>";
- + }
- + else
- + {
- + previousPageButton = "<button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_prev_down back=L2UI_CH3.shortcut_prev>";
- + }
- + String nextPageButton;
- + if (currentPage < maxPage)
- + {
- + nextPageButton = "<button value=\"\" width=16 height=16 action=\"bypass -h BuffStore bufflist " + buffer.getOwner().getObjectId() + " " + (isForPlayer ? "player" : "summon") + " " + (currentPage + 1) + "\" fore=L2UI_CH3.shortcut_next_down back=L2UI_CH3.shortcut_next>";
- + }
- + else
- + {
- + nextPageButton = "<button value=\"\" width=16 height=16 action=\"\" fore=L2UI_CH3.shortcut_next_down back=L2UI_CH3.shortcut_next>";
- + }
- + html.replace("%bufferId%", String.valueOf(buffer.getOwner().getObjectId()));
- + html.replace("%bufferClass%", String.valueOf(buffer.getOwner().getClassId().getName(buffer.getOwner())));
- + html.replace("%bufferLvl%", String.valueOf((buffer.getOwner().getLevel() >= 76) && (buffer.getOwner().getLevel() < 80) ? 76 : buffer.getOwner().getLevel() >= 84 ? 84 : Math.round(buffer.getOwner().getLevel() / 10) * 10));
- + html.replace("%bufferName%", buffer.getOwner().getName());
- + html.replace("%bufferMp%", String.valueOf((int) buffer.getOwner().getCurrentMp()));
- + html.replace("%buffPrice%", String.valueOf(Util.convertToLineagePriceFormat(buffer.getBuffPrice())));
- + html.replace("%target%", isForPlayer ? "Player" : "Summon");
- + html.replace("%page%", String.valueOf(currentPage));
- + html.replace("%buffs%", buffList.toString());
- + html.replace("%previousPageButton%", String.valueOf(previousPageButton));
- +
- + html.replace("%nextPageButton%", nextPageButton);
- + html.replace("%pageCount%", currentPage + 1 + "/" + (maxPage + 1));
- + player.sendPacket(html);
- + }
- +
- + public static OfflineBufferManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final OfflineBufferManager _instance = new OfflineBufferManager();
- + }
- +
- + public static class BufferData
- + {
- + private final Player _owner;
- + private final String _saleTitle;
- + private final int _buffPrice;
- + private final Map<Integer, Skill> _buffs = new HashMap();
- +
- + public BufferData(Player player, String title, int price, List<Skill> buffs)
- + {
- + this._owner = player;
- + this._saleTitle = title;
- + this._buffPrice = price;
- + if (buffs != null)
- + {
- + for (Skill buff : buffs)
- + {
- + this._buffs.put(Integer.valueOf(buff.getId()), buff);
- + }
- + }
- + }
- +
- + public Player getOwner()
- + {
- + return this._owner;
- + }
- +
- + public String getSaleTitle()
- + {
- + return this._saleTitle;
- + }
- +
- + public int getBuffPrice()
- + {
- + return this._buffPrice;
- + }
- +
- + public Map<Integer, Skill> getBuffs()
- + {
- + return this._buffs;
- + }
- + }
- +}
- Index: dist/gameserver/data/html-en/command/buffstore/buff_store.htm
- ===================================================================
- --- dist/gameserver/data/html-en/command/buffstore/buff_store.htm (revision 0)
- +++ dist/gameserver/data/html-en/command/buffstore/buff_store.htm (working copy)
- @@ -0,0 +1,16 @@
- +<!-- HTML Buff Store en el Panel -->
- +<html noscrollbar><head><title>Buff Store</title><body scroll="no">
- +<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background=L2UI_CH3.refinewnd_back_Pattern>
- +<tr><td valign="top" align="center">
- + <table border=0 cellpadding=0 cellspacing=0>
- + <tr><td height=20></td></tr>
- + <tr><td align=center><font color=91785a name=GameDefault>Buff Store</font></td></tr>
- + <tr><td height=30></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>This new system allows you to sell your buffing services to other players easily.<br></font></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>It behaves almost exactly like a private store, but instead of items the players can buy the buffs you have to offer.<br></font></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>You can set the price you will charge for every buff and a title for your store</font></td></tr>
- + <tr><td height=40></td></tr>
- + <tr><td align=center><button value="%link%" action="%bypass%" width=200 height=31 back=L2UI_CT1.OlympiadWnd_DF_Watch_Down fore=L2UI_CT1.OlympiadWnd_DF_Watch></td></tr>
- + </table>
- +</td></tr></table>
- +</body></html>
- \ No newline at end of file
- Index: java/l2f/gameserver/handler/voicecommands/impl/OfflineBuffs.java
- ===================================================================
- --- java/l2f/gameserver/handler/voicecommands/impl/OfflineBuffs.java (revision 0)
- +++ java/l2f/gameserver/handler/voicecommands/impl/OfflineBuffs.java (working copy)
- @@ -0,0 +1,54 @@
- +package l2f.gameserver.handler.voicecommands.impl;
- +
- +import l2f.gameserver.Config;
- +import l2f.gameserver.handler.voicecommands.IVoicedCommandHandler;
- +import l2f.gameserver.model.Player;
- +import l2f.gameserver.network.serverpackets.NpcHtmlMessage;
- +import l2f.gameserver.scripts.Functions;
- +
- +public class OfflineBuffs extends Functions implements IVoicedCommandHandler
- +{
- + private static final String[] VOICED_COMMANDS =
- + {
- + "buffstore"
- + };
- +
- + @Override
- + public boolean useVoicedCommand(String command, Player activeChar, String params)
- + {
- + try
- + {
- + if (!Config.BUFF_STORE_ALLOWED_CLASS_LIST.contains(Integer.valueOf(activeChar.getClassId().getId())))
- + {
- + activeChar.sendMessage("Your profession is not allowed to set an Buff Store");
- + return false;
- + }
- + NpcHtmlMessage html = new NpcHtmlMessage(0);
- + html.setFile("command/buffstore/buff_store.htm");
- + if (activeChar.getPrivateStoreType() == 20)
- + {
- + html.replace("%link%", activeChar.isLangRus() ? "Остановить продажу" : "Stop Store");
- + html.replace("%bypass%", "bypass -h BuffStore stopstore");
- + }
- + else
- + {
- + html.replace("%link%", activeChar.isLangRus() ? "Создать продажу" : "Create Store");
- + html.replace("%bypass%", "bypass -h player_help command/buffstore/buff_store_create.htm");
- + }
- + activeChar.sendPacket(html);
- +
- + return true;
- + }
- + catch (Exception e)
- + {
- + activeChar.sendMessage("Use: .buffstore");
- + }
- + return false;
- + }
- +
- + @Override
- + public String[] getVoicedCommandList()
- + {
- + return VOICED_COMMANDS;
- + }
- +}
- Index: java/l2f/gameserver/network/clientpackets/EnterWorld.java
- ===================================================================
- --- java/l2f/gameserver/network/clientpackets/EnterWorld.java (revision 109)
- +++ java/l2f/gameserver/network/clientpackets/EnterWorld.java (working copy)
- @@ -77,6 +77,7 @@
- import l2f.gameserver.network.serverpackets.components.ChatType;
- import l2f.gameserver.network.serverpackets.components.SystemMsg;
- import l2f.gameserver.skills.AbnormalEffect;
- +import l2f.gameserver.tables.OfflineBuffersTable;
- import l2f.gameserver.tables.SkillTable;
- import l2f.gameserver.templates.item.ItemTemplate;
- import l2f.gameserver.utils.GameStats;
- @@ -95,30 +96,30 @@
- public class EnterWorld extends L2GameClientPacket
- {
- private static final Object _lock = new Object();
- -
- +
- private static final Logger _log = LoggerFactory.getLogger(EnterWorld.class);
- -
- +
- @Override
- protected void readImpl()
- {
- // readS(); - client always sends the string "narcasse"
- }
- -
- +
- @Override
- protected void runImpl()
- {
- GameClient client = getClient();
- Player activeChar = client.getActiveChar();
- -
- +
- if (activeChar == null)
- {
- client.closeNow(false);
- return;
- }
- -
- +
- int MyObjectId = activeChar.getObjectId();
- Long MyStoreId = activeChar.getStoredId();
- -
- +
- synchronized (_lock)// TODO [G1ta0] Th is for garbage, and why is it
- // here
- {
- @@ -142,15 +143,15 @@
- }
- }
- }
- -
- +
- GameStats.incrementPlayerEnterGame();
- // if(ConfigProtection.ALLOW_FGUARD)
- // {
- // ProtectionManager.SendSpecialSting(client);
- // }
- +
- + boolean first = activeChar.entering;
- - boolean first = activeChar.entering;
- -
- if (first)
- {
- activeChar.setOnlineStatus(true);
- @@ -158,11 +159,11 @@
- {
- activeChar.setInvisibleType(InvisibleType.NORMAL);
- }
- -
- +
- activeChar.setNonAggroTime(Long.MAX_VALUE);
- activeChar.spawnMe();
- activeChar.setPendingOlyEnd(false);
- -
- +
- if (activeChar.isInStoreMode())
- {
- if (!TradeHelper.checksIfCanOpenStore(activeChar, activeChar.getPrivateStoreType()))
- @@ -172,32 +173,32 @@
- activeChar.broadcastCharInfo();
- }
- }
- -
- +
- activeChar.setRunning();
- activeChar.standUp();
- activeChar.startTimers();
- }
- -
- +
- activeChar.sendPacket(new ExBR_PremiumState(activeChar, activeChar.hasBonus()));
- -
- +
- activeChar.getMacroses().sendUpdate();
- activeChar.sendPacket(new SSQInfo(), new HennaInfo(activeChar));
- activeChar.sendItemList(false);
- activeChar.sendPacket(new ShortCutInit(activeChar), new SkillList(activeChar), new SkillCoolTime(activeChar));
- activeChar.sendPacket(SystemMsg.WELCOME_TO_THE_WORLD_OF_LINEAGE_II);
- -
- +
- // New char is Hero
- if (Config.NEW_CHAR_IS_HERO)
- {
- activeChar.setHero(true);
- }
- -
- +
- // New char is NOBLE
- if (Config.NEW_CHAR_IS_NOBLE)
- {
- activeChar.setNoble(true);
- }
- -
- +
- if (Config.HTML_WELCOME)
- {
- String html = HtmCache.getInstance().getNotNull("welcome.htm", activeChar);
- @@ -205,28 +206,28 @@
- msg.setHtml(Strings.bbParse(html));
- activeChar.sendPacket(msg);
- }
- -
- +
- Announcements.getInstance().showAnnouncements(activeChar);
- -
- +
- if (first)
- {
- activeChar.getListeners().onEnter();
- }
- -
- +
- SevenSigns.getInstance().sendCurrentPeriodMsg(activeChar);
- -
- +
- if (first && (activeChar.getCreateTime() > 0))
- {
- Calendar create = Calendar.getInstance();
- create.setTimeInMillis(activeChar.getCreateTime());
- Calendar now = Calendar.getInstance();
- -
- +
- int day = create.get(Calendar.DAY_OF_MONTH);
- if ((create.get(Calendar.MONTH) == Calendar.FEBRUARY) && (day == 29))
- {
- day = 28;
- }
- -
- +
- int myBirthdayReceiveYear = activeChar.getVarInt(Player.MY_BIRTHDAY_RECEIVE_YEAR, 0);
- if ((create.get(Calendar.MONTH) == now.get(Calendar.MONTH)) && (create.get(Calendar.DAY_OF_MONTH) == day))
- {
- @@ -239,60 +240,60 @@
- mail.setReceiverName(activeChar.getName());
- mail.setTopic(StringHolder.getInstance().getNotNull(activeChar, "birthday.title"));
- mail.setBody(StringHolder.getInstance().getNotNull(activeChar, "birthday.text"));
- -
- +
- ItemInstance item = ItemFunctions.createItem(21169);
- item.setLocation(ItemInstance.ItemLocation.MAIL);
- item.setCount(1L);
- item.save();
- -
- +
- mail.addAttachment(item);
- mail.setUnread(true);
- mail.setType(Mail.SenderType.BIRTHDAY);
- mail.setExpireTime((720 * 3600) + (int) (System.currentTimeMillis() / 1000L));
- mail.save();
- -
- +
- activeChar.setVar(Player.MY_BIRTHDAY_RECEIVE_YEAR, String.valueOf(now.get(Calendar.YEAR)), -1);
- }
- }
- }
- -
- +
- if (activeChar.getClan() != null)
- {
- notifyClanMembers(activeChar);
- -
- +
- activeChar.sendPacket(activeChar.getClan().listAll());
- activeChar.sendPacket(new PledgeShowInfoUpdate(activeChar.getClan()), new PledgeSkillList(activeChar.getClan()));
- }
- -
- +
- // engage and notify Partner
- if (first && Config.ALLOW_WEDDING)
- {
- CoupleManager.getInstance().engage(activeChar);
- CoupleManager.getInstance().notifyPartner(activeChar);
- }
- -
- +
- if (Config.ENABLE_AUTO_HUNTING_REPORT)
- {
- AutoHuntingManager.getInstance().onEnter(activeChar);
- }
- -
- +
- if (first)
- {
- activeChar.getFriendList().notifyFriends(true);
- loadTutorial(activeChar);
- activeChar.restoreDisableSkills();
- }
- -
- +
- sendPacket(new L2FriendList(activeChar), new ExStorageMaxCount(activeChar), new QuestList(activeChar), new ExBasicActionList(activeChar), new EtcStatusUpdate(activeChar));
- -
- +
- activeChar.checkHpMessages(activeChar.getMaxHp(), activeChar.getCurrentHp());
- activeChar.checkDayNightMessages();
- -
- +
- if (Config.PETITIONING_ALLOWED)
- {
- PetitionManager.getInstance().checkPetitionMessages(activeChar);
- }
- -
- +
- if (!first)
- {
- if (activeChar.isCastingNow())
- @@ -305,31 +306,31 @@
- sendPacket(new MagicSkillUse(activeChar, castingTarget, castingSkill.getId(), castingSkill.getLevel(), (int) (animationEndTime - System.currentTimeMillis()), 0));
- }
- }
- -
- +
- if (activeChar.isInBoat())
- {
- activeChar.sendPacket(activeChar.getBoat().getOnPacket(activeChar, activeChar.getInBoatPosition()));
- }
- -
- +
- if (activeChar.isMoving || activeChar.isFollow)
- {
- sendPacket(activeChar.movePacket());
- }
- -
- +
- if (activeChar.getMountNpcId() != 0)
- {
- sendPacket(new Ride(activeChar));
- }
- -
- +
- if (activeChar.isFishing())
- {
- activeChar.stopFishing();
- }
- }
- -
- +
- activeChar.entering = false;
- activeChar.sendUserInfo(true);
- -
- +
- if (activeChar.isSitting())
- {
- activeChar.sendPacket(new ChangeWaitType(activeChar, ChangeWaitType.WT_SITTING));
- @@ -349,17 +350,17 @@
- sendPacket(new RecipeShopMsg(activeChar));
- }
- }
- -
- +
- if (activeChar.isDead())
- {
- sendPacket(new Die(activeChar));
- }
- -
- +
- activeChar.unsetVar("offline");
- -
- +
- // just in case
- activeChar.sendActionFailed();
- -
- +
- if (first && activeChar.isGM() && Config.SAVE_GM_EFFECTS && activeChar.getPlayerAccess().CanUseGMCommand)
- {
- // silence
- @@ -399,25 +400,32 @@
- {
- period /= 1000; // to seconds
- period /= 60; // to minutes
- -
- +
- activeChar.sendPacket(new Say2(0, ChatType.TELL, "Administration", "Sit left " + TimeUtils.minutesToFullString((int) period)));
- }
- }
- PlayerMessageStack.getInstance().CheckMessages(activeChar);
- -
- +
- sendPacket(ClientSetTime.STATIC, new ExSetCompassZoneCode(activeChar));
- -
- +
- Pair<Integer, OnAnswerListener> entry = activeChar.getAskListener(false);
- if ((entry != null) && (entry.getValue() instanceof ReviveAnswerListener))
- {
- sendPacket(new ConfirmDlg(SystemMsg.C1_IS_MAKING_AN_ATTEMPT_TO_RESURRECT_YOU_IF_YOU_CHOOSE_THIS_PATH_S2_EXPERIENCE_WILL_BE_RETURNED_FOR_YOU, 0).addString("Other player").addString("some"));
- }
- -
- +
- if (activeChar.isCursedWeaponEquipped())
- {
- CursedWeaponsManager.getInstance().showUsageTime(activeChar, activeChar.getCursedWeaponEquippedId());
- }
- -
- + if (first)
- + {
- + activeChar.sendUserInfo();
- + if (Config.BUFF_STORE_ENABLED)
- + {
- + OfflineBuffersTable.getInstance().onLogin(activeChar);
- + }
- + }
- if (!first)
- {
- // Characters left while viewing
- @@ -440,12 +448,12 @@
- {
- World.showObjectsToPlayer(activeChar);
- }
- -
- +
- if (activeChar.getPet() != null)
- {
- sendPacket(new PetInfo(activeChar.getPet()));
- }
- -
- +
- if (activeChar.isInParty())
- {
- Summon member_pet;
- @@ -453,7 +461,7 @@
- // we do all actions before adding member to a list, this speeds
- // things up a little
- sendPacket(new PartySmallWindowAll(activeChar.getParty(), activeChar));
- -
- +
- for (Player member : activeChar.getParty().getPartyMembers())
- {
- if (member != activeChar)
- @@ -463,11 +471,11 @@
- {
- sendPacket(new PartySpelled(member_pet, true));
- }
- -
- +
- sendPacket(RelationChanged.update(activeChar, member, activeChar));
- }
- }
- -
- +
- // If the party is in the CC, the newcomer send the package open
- // the CC
- if (activeChar.getParty().isInCommandChannel())
- @@ -475,12 +483,12 @@
- sendPacket(ExMPCCOpen.STATIC);
- }
- }
- -
- +
- for (int shotId : activeChar.getAutoSoulShot())
- {
- sendPacket(new ExAutoSoulShot(shotId, true));
- }
- -
- +
- for (Effect e : activeChar.getEffectList().getAllFirstEffects())
- {
- if (e.getSkill().isToggle())
- @@ -488,39 +496,39 @@
- sendPacket(new MagicSkillLaunched(activeChar.getObjectId(), e.getSkill().getId(), e.getSkill().getLevel(), activeChar));
- }
- }
- -
- +
- activeChar.broadcastCharInfo();
- }
- else
- {
- activeChar.sendUserInfo(); // Display right in clan
- }
- -
- +
- activeChar.updateEffectIcons();
- activeChar.updateStats();
- -
- +
- if (Config.ALT_PCBANG_POINTS_ENABLED)
- {
- activeChar.sendPacket(new ExPCCafePointInfo(activeChar, 0, 1, 2, 12));
- }
- -
- +
- if (!activeChar.getPremiumItemList().isEmpty())
- {
- activeChar.sendPacket(Config.GOODS_INVENTORY_ENABLED ? ExGoodsInventoryChangedNotify.STATIC : ExNotifyPremiumItem.STATIC);
- }
- -
- +
- if (activeChar.getVarB("HeroPeriod") && Config.SERVICES_HERO_SELL_ENABLED)
- {
- activeChar.setHero(true);
- }
- -
- +
- activeChar.sendVoteSystemInfo();
- activeChar.sendPacket(new ExReceiveShowPostFriend(activeChar));
- activeChar.getNevitSystem().onEnterWorld();
- -
- +
- checkNewMail(activeChar);
- }
- -
- +
- private static void notifyClanMembers(Player activeChar)
- {
- Clan clan = activeChar.getClan();
- @@ -529,15 +537,15 @@
- {
- return;
- }
- -
- +
- UnitMember member = subUnit.getUnitMember(activeChar.getObjectId());
- if (member == null)
- {
- return;
- }
- -
- +
- member.setPlayerInstance(activeChar, false);
- -
- +
- int sponsor = activeChar.getSponsor();
- int apprentice = activeChar.getApprentice();
- L2GameServerPacket msg = new SystemMessage2(SystemMsg.CLAN_MEMBER_S1_HAS_LOGGED_INTO_GAME).addName(activeChar);
- @@ -558,29 +566,29 @@
- clanMember.sendPacket(msg);
- }
- }
- -
- +
- if (!activeChar.isClanLeader())
- {
- return;
- }
- -
- +
- ClanHall clanHall = clan.getHasHideout() > 0 ? ResidenceHolder.getInstance().getResidence(ClanHall.class, clan.getHasHideout()) : null;
- - if ((clanHall == null) || (clanHall.getAuctionLength() != 0))
- - {
- - return;
- - }
- -
- + if ((clanHall == null) || (clanHall.getAuctionLength() != 0))
- + {
- + return;
- + }
- +
- if (clanHall.getSiegeEvent().getClass() != ClanHallAuctionEvent.class)
- - {
- - return;
- - }
- -
- + {
- + return;
- + }
- +
- if (clan.getWarehouse().getCountOf(ItemTemplate.ITEM_ID_ADENA) < clanHall.getRentalFee())
- - {
- - activeChar.sendPacket(new SystemMessage2(SystemMsg.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_ME_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW).addLong(clanHall.getRentalFee()));
- - }
- + {
- + activeChar.sendPacket(new SystemMessage2(SystemMsg.PAYMENT_FOR_YOUR_CLAN_HALL_HAS_NOT_BEEN_MADE_PLEASE_ME_PAYMENT_TO_YOUR_CLAN_WAREHOUSE_BY_S1_TOMORROW).addLong(clanHall.getRentalFee()));
- + }
- }
- -
- +
- private void loadTutorial(Player player)
- {
- Quest q = QuestManager.getQuest(255);
- @@ -589,7 +597,7 @@
- player.processQuestEvent(q.getName(), "UC", null);
- }
- }
- -
- +
- private void checkNewMail(Player activeChar)
- {
- for (Mail mail : MailDAO.getInstance().getReceivedMailByOwnerId(activeChar.getObjectId()))
- Index: dist/gameserver/data/html-en/command/buffstore/buff_store_create.htm
- ===================================================================
- --- dist/gameserver/data/html-en/command/buffstore/buff_store_create.htm (revision 0)
- +++ dist/gameserver/data/html-en/command/buffstore/buff_store_create.htm (working copy)
- @@ -0,0 +1,20 @@
- +<!-- HTML Buff Store en el Panel -->
- +<html noscrollbar><head><title>Buff Store</title><body scroll="no">
- +<table border=0 cellpadding=0 cellspacing=0 width=292 height=358 background=L2UI_CH3.refinewnd_back_Pattern>
- +<tr><td valign="top" align="center">
- + <table border=0 cellpadding=0 cellspacing=0>
- + <tr><td height=20></td></tr>
- + <tr><td align=center><font color=91785a name=GameDefault>Buff Store</font></td></tr>
- + <tr><td height=20></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>Here you can set a Private Buff Store.<br></font></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>Other players will be able to purchase your buffs directly from an interface when clicking on you.<br></font></td></tr>
- + <tr><td fixwidth=260><font color=b5b5b5>Set the title of your store and the price you want to charge for every buff you sell and you are done.<br></font></td></tr>
- + <tr><td height=5></td></tr>
- + <tr><td align=center>Title: <multiedit var="title" width=220 height=15></td></tr>
- + <tr><td height=15></td></tr>
- + <tr><td align=center>Price: <edit type="number" var="price" width=160 height=15></td></tr>
- + <tr><td height=25></td></tr>
- + <tr><td align=center><button value="Create Store" action="bypass -h BuffStore setstore $price $title" width=200 height=31 back=L2UI_CT1.OlympiadWnd_DF_Watch_Down fore=L2UI_CT1.OlympiadWnd_DF_Watch></td></tr>
- + </table>
- +</td></tr></table>
- +</body></html>
- \ No newline at end of file
- Index: java/l2f/gameserver/model/Zone.java
- ===================================================================
- --- java/l2f/gameserver/model/Zone.java (revision 109)
- +++ java/l2f/gameserver/model/Zone.java (working copy)
- @@ -64,6 +64,7 @@
- dummy,
- offshore,
- epic,
- + buff_store_only,
- }
- public enum ZoneTarget
- @@ -138,7 +139,7 @@
- }
- @Override
- - public void runImpl() throws Exception
- + public void runImpl()
- {
- if (!isActive())
- {
- @@ -258,8 +259,8 @@
- private final Lock readLock = lock.readLock();
- private final Lock writeLock = lock.writeLock();
- - private final List<Creature> _objects = new LazyArrayList<Creature>(32);
- - private final Map<Creature, ZoneTimer> _zoneTimers = new ConcurrentHashMap<Creature, ZoneTimer>();
- + private final List<Creature> _objects = new LazyArrayList<>(32);
- + private final Map<Creature, ZoneTimer> _zoneTimers = new ConcurrentHashMap<>();
- /**
- * Ордер в зонах, с ним мы и добавляем/убираем статы. TODO: сравнить ордер с оффом, пока от фонаря
- @@ -498,6 +499,10 @@
- if (actor.isPlayer())
- {
- + if (getType() == ZoneType.buff_store_only)
- + {
- + actor.sendMessage("You have entered a Buff Store Only Zone");
- + }
- if (getEnteringMessageId() != 0)
- {
- actor.sendPacket(new SystemMessage2(SystemMsg.valueOf(getEnteringMessageId())));
- @@ -550,6 +555,10 @@
- if (actor.isPlayer())
- {
- + if (getType() == ZoneType.buff_store_only)
- + {
- + actor.sendMessage("You have left the Buff Store Only Zone");
- + }
- if ((getLeavingMessageId() != 0) && actor.isPlayer())
- {
- actor.sendPacket(new SystemMessage2(SystemMsg.valueOf(getLeavingMessageId())));
- @@ -664,7 +673,7 @@
- * @param cha персонаж
- * @return подошел ли
- */
- - private boolean checkTarget(Creature cha)
- + boolean checkTarget(Creature cha)
- {
- switch (getZoneTarget())
- {
- @@ -722,7 +731,7 @@
- public List<Player> getInsidePlayers()
- {
- - List<Player> result = new LazyArrayList<Player>();
- + List<Player> result = new LazyArrayList<>();
- readLock.lock();
- try
- {
- @@ -744,7 +753,7 @@
- public List<Playable> getInsidePlayables()
- {
- - List<Playable> result = new LazyArrayList<Playable>();
- + List<Playable> result = new LazyArrayList<>();
- readLock.lock();
- try
- {
- @@ -766,7 +775,7 @@
- public List<NpcInstance> getInsideNpcs()
- {
- - List<NpcInstance> result = new LazyArrayList<NpcInstance>();
- + List<NpcInstance> result = new LazyArrayList<>();
- readLock.lock();
- try
- {
- Index: java/l2f/gameserver/model/Player.java
- ===================================================================
- --- java/l2f/gameserver/model/Player.java (revision 109)
- +++ java/l2f/gameserver/model/Player.java (working copy)
- @@ -81,6 +81,7 @@
- import l2f.gameserver.instancemanager.CursedWeaponsManager;
- import l2f.gameserver.instancemanager.DimensionalRiftManager;
- import l2f.gameserver.instancemanager.MatchingRoomManager;
- +import l2f.gameserver.instancemanager.OfflineBufferManager;
- import l2f.gameserver.instancemanager.QuestManager;
- import l2f.gameserver.instancemanager.ReflectionManager;
- import l2f.gameserver.instancemanager.games.HandysBlockCheckerManager;
- @@ -267,6 +268,7 @@
- import l2f.gameserver.stats.Stats;
- import l2f.gameserver.stats.funcs.FuncTemplate;
- import l2f.gameserver.tables.ClanTable;
- +import l2f.gameserver.tables.OfflineBuffersTable;
- import l2f.gameserver.tables.PetDataTable;
- import l2f.gameserver.tables.SkillTable;
- import l2f.gameserver.tables.SkillTreeTable;
- @@ -334,7 +336,7 @@
- public static final int STORE_PRIVATE_MANUFACTURE = 5;
- public static final int STORE_OBSERVING_GAMES = 7;
- public static final int STORE_PRIVATE_SELL_PACKAGE = 8;
- -
- + public static final int STORE_PRIVATE_BUFF = 20;
- public static final int RANK_VAGABOND = 0;
- public static final int RANK_VASSAL = 1;
- public static final int RANK_HEIR = 2;
- @@ -3523,6 +3525,10 @@
- sendPacket(new RecipeShopSellList(this, temp));
- sendActionFailed();
- }
- + else if (temp.getPrivateStoreType() == STORE_PRIVATE_BUFF)
- + {
- + OfflineBufferManager.getInstance().processBypass(this, "BuffStore bufflist " + temp.getObjectId());
- + }
- sendActionFailed();
- }
- else if (getAI().getIntention() != CtrlIntention.AI_INTENTION_INTERACT)
- @@ -7278,7 +7284,84 @@
- {
- return _partyMatchingVisible;
- }
- -
- +
- + public boolean isInBuffStore()
- + {
- + return getPrivateStoreType() == 20;
- + }
- +
- + public void offlineBuffStore()
- + {
- + if (this._connection != null)
- + {
- + this._connection.setActiveChar(null);
- + this._connection.close(ServerClose.STATIC);
- + setNetConnection(null);
- + }
- + setOfflineMode(true);
- +
- + Party party = getParty();
- + if (party != null)
- + {
- + if (isFestivalParticipant())
- + {
- + party.broadcastMessageToPartyMembers(getName() + " has been removed from the upcoming festival.");
- + }
- + leaveParty();
- + }
- + if (getPet() != null)
- + {
- + getPet().unSummon();
- + }
- + CursedWeaponsManager.getInstance().doLogout(this);
- + if ((isInOlympiadMode()) || (getOlympiadGame() != null))
- + {
- + Olympiad.logoutPlayer(this);
- + }
- + if (isInObserverMode())
- + {
- + if (getOlympiadObserveGame() == null)
- + {
- + leaveObserverMode();
- + }
- + else
- + {
- + leaveOlympiadObserverMode(true);
- + }
- + this._observerMode.set(0);
- + }
- + setNameColor(Config.BUFF_STORE_OFFLINE_NAME_COLOR);
- + broadcastCharInfo();
- +
- + OfflineBuffersTable.getInstance().onLogout(this);
- +
- + stopWaterTask();
- + stopBonusTask();
- + stopHourlyTask();
- + stopVitalityTask();
- + stopPcBangPointsTask();
- + stopAutoSaveTask();
- + stopRecomBonusTask(true);
- + stopQuestTimers();
- + getNevitSystem().stopTasksOnLogout();
- + try
- + {
- + getInventory().store();
- + }
- + catch (Throwable t)
- + {
- + _log.error("Error while storing Player Inventory", t);
- + }
- + try
- + {
- + store(false);
- + }
- + catch (Throwable t)
- + {
- + _log.error("Error while storing Player", t);
- + }
- + }
- +
- public void enterOlympiadObserverMode(Location loc, OlympiadGame game, Reflection reflect)
- {
- WorldRegion observerRegion = World.getRegion(loc);
- Index: java/l2f/gameserver/tables/OfflineBuffersTable.java
- ===================================================================
- --- java/l2f/gameserver/tables/OfflineBuffersTable.java (revision 0)
- +++ java/l2f/gameserver/tables/OfflineBuffersTable.java (working copy)
- @@ -0,0 +1,197 @@
- +package l2f.gameserver.tables;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.Collection;
- +
- +import l2f.commons.dbutils.DbUtils;
- +import l2f.gameserver.Config;
- +import l2f.gameserver.database.DatabaseFactory;
- +import l2f.gameserver.instancemanager.OfflineBufferManager;
- +import l2f.gameserver.model.Player;
- +import l2f.gameserver.model.Skill;
- +
- +import org.slf4j.Logger;
- +import org.slf4j.LoggerFactory;
- +
- +public class OfflineBuffersTable
- +{
- + private static final Logger _log = LoggerFactory.getLogger(OfflineBuffersTable.class);
- +
- + public void restoreOfflineBuffers()
- + {
- + _log.info(getClass().getSimpleName() + ": Loading offline buffers...");
- +
- + Connection con = null;
- + PreparedStatement statement = null;
- + ResultSet rset = null;
- + try
- + {
- + con = DatabaseFactory.getInstance().getConnection();
- +
- + statement = con.prepareStatement("SELECT * FROM character_offline_buffers WHERE charId > 0");
- + rset = statement.executeQuery();
- + int nBuffers = 0;
- + while (rset.next())
- + {
- + Player player = null;
- + try
- + {
- + player = Player.restore(rset.getInt("charId"));
- + if (player != null)
- + {
- + player.setOfflineMode(true);
- + player.setIsOnline(true);
- + player.updateOnlineStatus();
- + player.spawnMe();
- + if ((player.getClan() != null) && (player.getClan().getAnyMember(player.getObjectId()) != null))
- + {
- + player.getClan().getAnyMember(player.getObjectId()).setPlayerInstance(player, false);
- + }
- + OfflineBufferManager.BufferData buffer = new OfflineBufferManager.BufferData(player, rset.getString("title"), rset.getInt("price"), null);
- +
- + statement = con.prepareStatement("SELECT * FROM character_offline_buffer_buffs WHERE charId = ?");
- + try
- + {
- + statement.setInt(1, player.getObjectId());
- + rset = statement.executeQuery();
- + try
- + {
- + if (rset.next())
- + {
- + String[] skillIds = rset.getString("skillIds").split(",");
- + for (String skillId : skillIds)
- + {
- + Skill skill = player.getKnownSkill(Integer.parseInt(skillId));
- + if (skill != null)
- + {
- + buffer.getBuffs().put(Integer.valueOf(skill.getId()), skill);
- + }
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + OfflineBufferManager.getInstance().getBuffStores().put(Integer.valueOf(player.getObjectId()), buffer);
- + player.sitDown(null);
- + player.setTitleColor(Config.BUFF_STORE_TITLE_COLOR);
- + player.setTitle(buffer.getSaleTitle());
- + player.setNameColor(Config.BUFF_STORE_OFFLINE_NAME_COLOR);
- + player.setPrivateStoreType(20);
- + player.broadcastUserInfo(true);
- + nBuffers++;
- + }
- + }
- + catch (Exception e)
- + {
- + _log.warn(getClass().getSimpleName() + ": Error loading buffer: " + player, e);
- + if (player != null)
- + {
- + player.deleteMe();
- + }
- + }
- + }
- + _log.info(getClass().getSimpleName() + ": Loaded: " + nBuffers + " offline buffer(s)");
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + finally
- + {
- + DbUtils.closeQuietly(con, statement, rset);
- + }
- + }
- +
- + public synchronized void onLogin(Player trader)
- + {
- + Connection con = null;
- + PreparedStatement statement = null;
- + try
- + {
- + con = DatabaseFactory.getInstance().getConnection();
- + OfflineBufferManager.getInstance().getBuffStores().remove(Integer.valueOf(trader.getObjectId()));
- + statement = con.prepareStatement("DELETE FROM character_offline_buffers WHERE charId=?");
- + statement.setInt(1, trader.getObjectId());
- + statement.executeUpdate();
- +
- + statement = con.prepareStatement("DELETE FROM character_offline_buffer_buffs WHERE charId=?");
- + statement.setInt(1, trader.getObjectId());
- + statement.executeUpdate();
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + finally
- + {
- + DbUtils.closeQuietly(con, statement);
- + }
- + }
- +
- + public synchronized void onLogout(Player trader)
- + {
- + OfflineBufferManager.BufferData buffer = OfflineBufferManager.getInstance().getBuffStores().get(Integer.valueOf(trader.getObjectId()));
- + if (buffer == null)
- + {
- + return;
- + }
- + Connection con = null;
- + PreparedStatement statement = null;
- + try
- + {
- + con = DatabaseFactory.getInstance().getConnection();
- + statement = con.prepareStatement("REPLACE INTO character_offline_buffers VALUES (?,?,?)");
- +
- + statement.setInt(1, trader.getObjectId());
- + statement.setInt(2, buffer.getBuffPrice());
- + statement.setString(3, buffer.getSaleTitle());
- + statement.executeUpdate();
- +
- + statement = con.prepareStatement("REPLACE INTO character_offline_buffer_buffs VALUES (?,?)");
- + statement.setInt(1, trader.getObjectId());
- + statement.setString(2, joinAllSkillsToString(buffer.getBuffs().values()));
- + statement.executeUpdate();
- + }
- + catch (Exception e)
- + {
- + e.printStackTrace();
- + }
- + finally
- + {
- + DbUtils.closeQuietly(con, statement);
- + }
- + }
- +
- + private final String joinAllSkillsToString(Collection<Skill> skills)
- + {
- + if (skills.isEmpty())
- + {
- + return "";
- + }
- + String result = "";
- + for (Skill val : skills)
- + {
- + result = result + val.getId() + ",";
- + }
- + return result.substring(0, result.length() - 1);
- + }
- +
- + public static OfflineBuffersTable getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final OfflineBuffersTable _instance = new OfflineBuffersTable();
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement