Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Eclipse Workspace Patch 1.0
- #P Lisvus_DataPack
- Index: data/jscript/village_master/__init__.py
- ===================================================================
- --- data/jscript/village_master/__init__.py (revision 325)
- +++ data/jscript/village_master/__init__.py (working copy)
- @@ -1,41 +0,0 @@
- -__all__ = [
- -'7026_bitz_occupation_change',
- -'7031_biotin_occupation_change',
- -'7037_levian_occupation_change',
- -'7066_pabris_occupation_change',
- -'7070_sylvain_occupation_change',
- -'7109_hannavalt_occupation_change',
- -'7115_jurek_occupation_change',
- -'7120_maximilian_occupation_change',
- -'7154_asterios_occupation_change',
- -'7288_rains_occupation_change',
- -'7289_raymond_occupation_change',
- -'7290_xenos_occupation_change',
- -'7297_tobias_occupation_change',
- -'7358_thifiell_occupation_change',
- -'7373_ramos_occupation_change',
- -'7462_tronix_occupation_change',
- -'7474_angus_occupation_change',
- -'7498_moke_occupation_change',
- -'7499_tapoy_occupation_change',
- -'7500_osborn_occupation_change',
- -'7503_rikadio_occupation_change',
- -'7504_mendio_occupation_change',
- -'7505_drikus_occupation_change',
- -'7508_castor_occupation_change',
- -'7511_gesto_occupation_change',
- -'7512_kusto_occupation_change',
- -'7513_penatus_occupation_change',
- -'7520_reed_occupation_change',
- -'7525_bronk_occupation_change',
- -'7565_kakai_occupation_change',
- -'7594_ranspo_occupation_change',
- -'7595_opix_occupation_change',
- -'9000_clan',
- -'9001_alliance'
- -]
- -for name in __all__ :
- - try :
- - __import__('data.jscript.village_master.'+name,globals(), locals(), ['__init__'], -1)
- - except :
- - print "Failed to import village master : ",name
- \ No newline at end of file
- Index: data/scripts.cfg
- ===================================================================
- --- data/scripts.cfg (revision 0)
- +++ data/scripts.cfg (revision 0)
- @@ -0,0 +1,246 @@
- +# Author: Micr0 for L2JLisvus
- +
- +#Quests in Jython /__init__.py
- +quests/1_LettersOfLove1/__init__.py
- +quests/2_WhatWomenWant1/__init__.py
- +quests/3_ReleaseDarkelfElder1/__init__.py
- +quests/4_LongLiveLordOfFlame/__init__.py
- +quests/5_MinersFavor/__init__.py
- +quests/6_StepIntoTheFuture/__init__.py
- +quests/7_ATripBegins/__init__.py
- +quests/8_AnAdventureBegins/__init__.py
- +quests/9_IntoTheCityOfHumans/__init__.py
- +quests/10_IntoTheWorld/__init__.py
- +quests/19_GoToThePastureland/__init__.py
- +quests/31_SecretBuriedInTheSwamp/__init__.py
- +quests/32_AnObviousLie/__init__.py
- +quests/33_MakeAPairOfDressShoes/__init__.py
- +quests/34_InSearchOfClothes/__init__.py
- +quests/35_FindGlitteringJewelry/__init__.py
- +quests/36_MakeASewingKit/__init__.py
- +quests/37_PleaseMakeMeFormalWear/__init__.py
- +quests/39_RedEyedInvaders/__init__.py
- +quests/42_HelpTheUncle/__init__.py
- +quests/43_HelpTheSister/__init__.py
- +quests/44_HelpTheSon/__init__.py
- +quests/45_ToTalkingIsland/__init__.py
- +quests/46_OnceMoreInTheArmsOfTheMotherTree/__init__.py
- +quests/47_IntoTheDarkForest/__init__.py
- +quests/48_ToTheImmortalPlateau/__init__.py
- +quests/49_TheRoadHome/__init__.py
- +quests/101_SwordOfSolidarityQuest/__init__.py
- +quests/102_FungusFever/__init__.py
- +quests/103_SpiritOfCraftsman/__init__.py
- +quests/104_SpiritOfMirror/__init__.py
- +quests/105_SkirmishWithOrcs/__init__.py
- +quests/106_ForgottenTruth/__init__.py
- +quests/107_ShowNoMercy/__init__.py
- +quests/108_DiamondGambit/__init__.py
- +quests/151_SaveMySister1/__init__.py
- +quests/152_ShardsOfGolem/__init__.py
- +quests/153_WharfOldtimersFavor/__init__.py
- +quests/154_SacrificeToSea/__init__.py
- +quests/155_FindSirWindawood/__init__.py
- +quests/156_MillenniumLove/__init__.py
- +quests/157_RecoverSmuggled/__init__.py
- +quests/158_SeedOfEvil/__init__.py
- +quests/159_ProtectHeadsprings/__init__.py
- +quests/160_NerupasFavor/__init__.py
- +quests/161_FruitsOfMothertree/__init__.py
- +quests/162_CurseOfFortress/__init__.py
- +quests/163_LegacyOfPoet/__init__.py
- +quests/164_BloodFiend/__init__.py
- +quests/165_WildHunt/__init__.py
- +quests/166_DarkMass/__init__.py
- +quests/167_DwarvenKinship/__init__.py
- +quests/168_DeliverSupplies/__init__.py
- +quests/169_NightmareChildren/__init__.py
- +quests/170_DangerousAllure/__init__.py
- +quests/171_ActsOfEvil/__init__.py
- +quests/211_TrialOfChallenger/__init__.py
- +quests/212_TrialOfDuty/__init__.py
- +quests/213_TrialOfSeeker/__init__.py
- +quests/214_TrialOfScholar/__init__.py
- +quests/215_TrialOfPilgrim/__init__.py
- +quests/216_TrialOfGuildsman/__init__.py
- +quests/217_TestimonyOfTrust/__init__.py
- +quests/218_TestimonyOfLife/__init__.py
- +quests/219_TestimonyOfFate/__init__.py
- +quests/220_TestimonyOfGlory/__init__.py
- +quests/221_TestimonyOfProsperity/__init__.py
- +quests/222_TestOfDuelist/__init__.py
- +quests/223_TestOfChampion/__init__.py
- +quests/224_TestOfSagittarius/__init__.py
- +quests/225_TestOfSearcher/__init__.py
- +quests/226_TestOfHealer/__init__.py
- +quests/227_TestOfReformer/__init__.py
- +quests/228_TestOfMagus/__init__.py
- +quests/229_TestOfWitchcraft/__init__.py
- +quests/230_TestOfSummoner/__init__.py
- +quests/231_TestOfMaestro/__init__.py
- +quests/232_TestOfLord/__init__.py
- +quests/233_TestOfWarspirit/__init__.py
- +quests/234_FatesWhisper/__init__.py
- +quests/235_MimirsElixir/__init__.py
- +quests/241_PossessorOfAPreciousSoul_1/__init__.py
- +quests/242_PossessorOfAPreciousSoul_2/__init__.py
- +quests/246_PossessorOfAPreciousSoul_3/__init__.py
- +quests/247_PossessorOfAPreciousSoul_4/__init__.py
- +quests/257_GuardIsBusy1/__init__.py
- +quests/258_BringWolfPelt1/__init__.py
- +quests/259_RanchersPlea/__init__.py
- +quests/260_HuntForOrcs1/__init__.py
- +quests/261_DreamOfMoneylender1/__init__.py
- +quests/262_BringMeMushrooms1/__init__.py
- +quests/263_KillAllSylphs1/__init__.py
- +quests/264_KeenClaws/__init__.py
- +quests/265_ChainsOfSlavery/__init__.py
- +quests/266_PleaOfPixies/__init__.py
- +quests/267_WrathOfVerdure/__init__.py
- +quests/271_ProofOfValor/__init__.py
- +quests/272_WrathOfAncestors/__init__.py
- +quests/273_InvadersOfHolyland/__init__.py
- +quests/274_AgainstWolfMen/__init__.py
- +quests/275_BlackWingedSpies/__init__.py
- +quests/276_HestuiTotem/__init__.py
- +quests/277_GatekeepersOffering/__init__.py
- +quests/291_RedBonnetsRevenge/__init__.py
- +quests/292_CrushBrigands/__init__.py
- +quests/293_HiddenVein/__init__.py
- +quests/294_CovertBusiness/__init__.py
- +quests/295_DreamsOfFlight/__init__.py
- +quests/296_SilkOfTarantula/__init__.py
- +quests/297_GatekeepersFavor/__init__.py
- +quests/298_LizardmensConspiracy/__init__.py
- +quests/299_GatherIngredientsForPie/__init__.py
- +quests/303_CollectArrowheads/__init__.py
- +quests/306_CrystalOfFireice/__init__.py
- +quests/313_CollectSpores/__init__.py
- +quests/316_DestroyPlaguebringers/__init__.py
- +quests/317_CatchTheWind/__init__.py
- +quests/319_ScentOfDeath/__init__.py
- +quests/320_BonesTellFuture/__init__.py
- +quests/324_SweetestVenom/__init__.py
- +quests/325_GrimCollector/__init__.py
- +quests/326_VanquishRemnants/__init__.py
- +quests/327_ReclaimTheLand/__init__.py
- +quests/328_SenseForBusiness/__init__.py
- +quests/329_CuriosityOfDwarf/__init__.py
- +quests/330_AdeptOfTaste/__init__.py
- +quests/331_ArrowForVengeance/__init__.py
- +quests/333_BlackLionHunt/__init__.py
- +quests/334_TheWishingPotion/__init__.py
- +quests/336_CoinOfMagic/__init__.py
- +quests/338_AlligatorHunter/__init__.py
- +quests/341_HuntingForWildBeasts/__init__.py
- +quests/343_UnderTheShadowOfTheIvoryTower/__init__.py
- +quests/345_MethodToRaiseTheDead/__init__.py
- +quests/347_GoGetTheCalculator/__init__.py
- +quests/348_ArrogantSearch/__init__.py
- +quests/350_EnhanceYourWeapon/__init__.py
- +quests/351_BlackSwan/__init__.py
- +quests/352_HelpRoodRaiseANewPet/__init__.py
- +quests/354_ConquestOfAlligatorIsland/__init__.py
- +quests/355_FamilyHonor/__init__.py
- +quests/356_DigUpTheSeaOfSpores/__init__.py
- +quests/357_WarehouseKeepersAmbition/__init__.py
- +quests/358_IllegitimateChildOfAGoddess/__init__.py
- +quests/359_ForSleeplessDeadmen/__init__.py
- +quests/360_PlunderTheirSupplies/__init__.py
- +quests/362_BardsMandolin/__init__.py
- +quests/363_SorrowfulSoundofFlute/__init__.py
- +quests/364_JovialAccordion/__init__.py
- +quests/365_DevilsLegacy/__init__.py
- +quests/368_TrespassingIntoTheSacredArea/__init__.py
- +quests/370_AWisemanSowsSeeds/__init__.py
- +quests/372_LegacyOfInsolence/__init__.py
- +quests/373_SupplierOfReagents/__init__.py
- +quests/374_WhisperOfDreams1/__init__.py
- +quests/375_WhisperOfDreams2/__init__.py
- +quests/376_GiantsExploration1/__init__.py
- +quests/377_GiantsExploration2/__init__.py
- +quests/383_SearchingForTreasure/__init__.py
- +quests/385_YokeofthePast/__init__.py
- +quests/386_StolenDignity/__init__.py
- +quests/401_PathToWarrior/__init__.py
- +quests/402_PathToKnight/__init__.py
- +quests/403_PathToRogue/__init__.py
- +quests/404_PathToWizard/__init__.py
- +quests/405_PathToCleric/__init__.py
- +quests/406_PathToElvenKnight/__init__.py
- +quests/407_PathToElvenScout/__init__.py
- +quests/408_PathToElvenwizard/__init__.py
- +quests/409_PathToOracle/__init__.py
- +quests/410_PathToPalusKnight/__init__.py
- +quests/411_PathToAssassin/__init__.py
- +quests/412_PathToDarkwizard/__init__.py
- +quests/413_PathToShillienOracle/__init__.py
- +quests/414_PathToOrcRaider/__init__.py
- +quests/415_PathToOrcMonk/__init__.py
- +quests/416_PathToOrcShaman/__init__.py
- +quests/417_PathToScavenger/__init__.py
- +quests/418_PathToArtisan/__init__.py
- +quests/419_GetAPet/__init__.py
- +quests/420_LittleWings/__init__.py
- +quests/421_LittleWingAdventures/__init__.py
- +quests/426_FishingShot/__init__.py
- +quests/431_WeddingMarch/__init__.py
- +quests/432_BirthdayPartySong/__init__.py
- +quests/501_ProofOfClanAlliance/__init__.py
- +quests/503_PursuitClanAmbition/__init__.py
- +quests/621_EggDelivery/__init__.py
- +quests/622_DeliveryOfSpecialLiquor/__init__.py
- +quests/626_ADarkTwilight/__init__.py
- +quests/627_HeartInSearchOfPower/__init__.py
- +quests/634_InSearchofDimensionalFragments/__init__.py
- +quests/999_C3Tutorial/__init__.py
- +
- +#Custom
- +custom/12535_WakeBaium/__init__.py
- +custom/3995_echo/__init__.py
- +custom/7000_HeroItems/__init__.py
- +
- +#teleports
- +teleports/1100_teleport_with_charm/__init__.py
- +teleports/1101_teleport_to_race_track/__init__.py
- +teleports/1102_toivortex_blue/__init__.py
- +teleports/1102_toivortex_green/__init__.py
- +teleports/1102_toivortex_red/__init__.py
- +teleports/1103_OracleTeleport/__init__.py
- +teleports/2000_NoblesseTeleport/__init__.py
- +
- +#village master
- +village_master/7026_bitz_occupation_change/__init__.py
- +village_master/7031_biotin_occupation_change/__init__.py
- +village_master/7037_levian_occupation_change/__init__.py
- +village_master/7066_pabris_occupation_change/__init__.py
- +village_master/7070_sylvain_occupation_change/__init__.py
- +village_master/7109_hannavalt_occupation_change/__init__.py
- +village_master/7115_jurek_occupation_change/__init__.py
- +village_master/7120_maximilian_occupation_change/__init__.py
- +village_master/7154_asterios_occupation_change/__init__.py
- +village_master/7288_rains_occupation_change/__init__.py
- +village_master/7289_raymond_occupation_change/__init__.py
- +village_master/7290_xenos_occupation_change/__init__.py
- +village_master/7297_tobias_occupation_change/__init__.py
- +village_master/7358_thifiell_occupation_change/__init__.py
- +village_master/7373_ramos_occupation_change/__init__.py
- +village_master/7462_tronix_occupation_change/__init__.py
- +village_master/7474_angus_occupation_change/__init__.py
- +village_master/7498_moke_occupation_change/__init__.py
- +village_master/7499_tapoy_occupation_change/__init__.py
- +village_master/7500_osborn_occupation_change/__init__.py
- +village_master/7503_rikadio_occupation_change/__init__.py
- +village_master/7504_mendio_occupation_change/__init__.py
- +village_master/7505_drikus_occupation_change/__init__.py
- +village_master/7508_castor_occupation_change/__init__.py
- +village_master/7511_gesto_occupation_change/__init__.py
- +village_master/7512_kusto_occupation_change/__init__.py
- +village_master/7513_penatus_occupation_change/__init__.py
- +village_master/7520_reed_occupation_change/__init__.py
- +village_master/7525_bronk_occupation_change/__init__.py
- +village_master/7565_kakai_occupation_change/__init__.py
- +village_master/7594_ranspo_occupation_change/__init__.py
- +village_master/7595_opix_occupation_change/__init__.py
- +village_master/9000_clan/__init__.py
- +village_master/9001_alliance/__init__.py
- \ No newline at end of file
- Index: data/jscript/teleports/__init__.py
- ===================================================================
- --- data/jscript/teleports/__init__.py (revision 325)
- +++ data/jscript/teleports/__init__.py (working copy)
- @@ -1,14 +0,0 @@
- -__all__ = [
- -'1100_teleport_with_charm',
- -'1101_teleport_to_race_track',
- -'1102_toivortex_green',
- -'1102_toivortex_blue',
- -'1102_toivortex_red',
- -'1103_OracleTeleport',
- -'2000_NoblesseTeleport'
- -]
- -for name in __all__ :
- - try :
- - __import__('data.jscript.teleports.'+name,globals(), locals(), ['__init__'], -1)
- - except :
- - print "Failed to import teleport : ",name
- \ No newline at end of file
- Index: data/jscript/__init__.py
- ===================================================================
- --- data/jscript/__init__.py (revision 325)
- +++ data/jscript/__init__.py (working copy)
- @@ -1,10 +0,0 @@
- -__all__ = [
- -'quests',
- -'custom',
- -'teleports',
- -'village_master'
- -]
- -import quests
- -import custom
- -import teleports
- -import village_master
- Index: data/jscript/custom/__init__.py
- ===================================================================
- --- data/jscript/custom/__init__.py (revision 325)
- +++ data/jscript/custom/__init__.py (working copy)
- @@ -1,10 +0,0 @@
- -__all__ = [
- -'3995_echo',
- -'12535_WakeBaium',
- -'7000_HeroItems'
- -]
- -for name in __all__ :
- - try :
- - __import__('data.jscript.custom.'+name,globals(), locals(), ['__init__'], -1)
- - except :
- - print "Failed to import custom : ",name
- \ No newline at end of file
- Index: data/jscript/quests/__init__.py
- ===================================================================
- --- data/jscript/quests/__init__.py (revision 325)
- +++ data/jscript/quests/__init__.py (working copy)
- @@ -1,200 +0,0 @@
- -__all__ = [
- -'1_LettersOfLove1',
- -'2_WhatWomenWant1',
- -'3_ReleaseDarkelfElder1',
- -'4_LongLiveLordOfFlame',
- -'5_MinersFavor',
- -'6_StepIntoTheFuture',
- -'7_ATripBegins',
- -'8_AnAdventureBegins',
- -'9_IntoTheCityOfHumans',
- -'10_IntoTheWorld',
- -'19_GoToThePastureland',
- -'31_SecretBuriedInTheSwamp',
- -'32_AnObviousLie',
- -'33_MakeAPairOfDressShoes',
- -'34_InSearchOfClothes',
- -'35_FindGlitteringJewelry',
- -'36_MakeASewingKit',
- -'37_PleaseMakeMeFormalWear',
- -'39_RedEyedInvaders',
- -'42_HelpTheUncle',
- -'43_HelpTheSister',
- -'44_HelpTheSon',
- -'45_ToTalkingIsland',
- -'46_OnceMoreInTheArmsOfTheMotherTree',
- -'47_IntoTheDarkForest',
- -'48_ToTheImmortalPlateau',
- -'49_TheRoadHome',
- -'101_SwordOfSolidarityQuest',
- -'102_FungusFever',
- -'103_SpiritOfCraftsman',
- -'104_SpiritOfMirror',
- -'105_SkirmishWithOrcs',
- -'106_ForgottenTruth',
- -'107_ShowNoMercy',
- -'108_DiamondGambit',
- -'151_SaveMySister1',
- -'152_ShardsOfGolem',
- -'153_WharfOldtimersFavor',
- -'154_SacrificeToSea',
- -'155_FindSirWindawood',
- -'156_MillenniumLove',
- -'157_RecoverSmuggled',
- -'158_SeedOfEvil',
- -'159_ProtectHeadsprings',
- -'160_NerupasFavor',
- -'161_FruitsOfMothertree',
- -'162_CurseOfFortress',
- -'163_LegacyOfPoet',
- -'164_BloodFiend',
- -'165_WildHunt',
- -'166_DarkMass',
- -'167_DwarvenKinship',
- -'168_DeliverSupplies',
- -'169_NightmareChildren',
- -'170_DangerousAllure',
- -'171_ActsOfEvil',
- -'211_TrialOfChallenger',
- -'212_TrialOfDuty',
- -'213_TrialOfSeeker',
- -'214_TrialOfScholar',
- -'215_TrialOfPilgrim',
- -'216_TrialOfGuildsman',
- -'217_TestimonyOfTrust',
- -'218_TestimonyOfLife',
- -'219_TestimonyOfFate',
- -'220_TestimonyOfGlory',
- -'221_TestimonyOfProsperity',
- -'222_TestOfDuelist',
- -'223_TestOfChampion',
- -'224_TestOfSagittarius',
- -'225_TestOfSearcher',
- -'226_TestOfHealer',
- -'227_TestOfReformer',
- -'228_TestOfMagus',
- -'229_TestOfWitchcraft',
- -'230_TestOfSummoner',
- -'231_TestOfMaestro',
- -'232_TestOfLord',
- -'233_TestOfWarspirit',
- -'234_FatesWhisper',
- -'235_MimirsElixir',
- -'241_PossessorOfAPreciousSoul_1',
- -'242_PossessorOfAPreciousSoul_2',
- -'246_PossessorOfAPreciousSoul_3',
- -'247_PossessorOfAPreciousSoul_4',
- -'257_GuardIsBusy1',
- -'258_BringWolfPelt1',
- -'259_RanchersPlea',
- -'260_HuntForOrcs1',
- -'261_DreamOfMoneylender1',
- -'262_BringMeMushrooms1',
- -'263_KillAllSylphs1',
- -'264_KeenClaws',
- -'265_ChainsOfSlavery',
- -'266_PleaOfPixies',
- -'267_WrathOfVerdure',
- -'271_ProofOfValor',
- -'272_WrathOfAncestors',
- -'273_InvadersOfHolyland',
- -'274_AgainstWolfMen',
- -'275_BlackWingedSpies',
- -'276_HestuiTotem',
- -'277_GatekeepersOffering',
- -'291_RedBonnetsRevenge',
- -'292_CrushBrigands',
- -'293_HiddenVein',
- -'294_CovertBusiness',
- -'295_DreamsOfFlight',
- -'296_SilkOfTarantula',
- -'297_GatekeepersFavor',
- -'298_LizardmensConspiracy',
- -'299_GatherIngredientsForPie',
- -'303_CollectArrowheads',
- -'306_CrystalOfFireice',
- -'313_CollectSpores',
- -'316_DestroyPlaguebringers',
- -'317_CatchTheWind',
- -'319_ScentOfDeath',
- -'320_BonesTellFuture',
- -'324_SweetestVenom',
- -'325_GrimCollector',
- -'326_VanquishRemnants',
- -'327_ReclaimTheLand',
- -'328_SenseForBusiness',
- -'329_CuriosityOfDwarf',
- -'330_AdeptOfTaste',
- -'331_ArrowForVengeance',
- -'333_BlackLionHunt',
- -'334_TheWishingPotion',
- -'336_CoinOfMagic',
- -'338_AlligatorHunter',
- -'341_HuntingForWildBeasts',
- -'343_UnderTheShadowOfTheIvoryTower',
- -'345_MethodToRaiseTheDead',
- -'347_GoGetTheCalculator',
- -'348_ArrogantSearch',
- -'350_EnhanceYourWeapon',
- -'351_BlackSwan',
- -'352_HelpRoodRaiseANewPet',
- -'354_ConquestOfAlligatorIsland',
- -'355_FamilyHonor',
- -'356_DigUpTheSeaOfSpores',
- -'357_WarehouseKeepersAmbition',
- -'358_IllegitimateChildOfAGoddess',
- -'359_ForSleeplessDeadmen',
- -'360_PlunderTheirSupplies',
- -'362_BardsMandolin',
- -'363_SorrowfulSoundofFlute',
- -'364_JovialAccordion',
- -'365_DevilsLegacy',
- -'368_TrespassingIntoTheSacredArea',
- -'370_AWisemanSowsSeeds',
- -'372_LegacyOfInsolence',
- -'373_SupplierOfReagents',
- -'374_WhisperOfDreams1',
- -'375_WhisperOfDreams2',
- -'376_GiantsExploration1',
- -'377_GiantsExploration2',
- -'383_SearchingForTreasure',
- -'385_YokeofthePast',
- -'386_StolenDignity',
- -'401_PathToWarrior',
- -'402_PathToKnight',
- -'403_PathToRogue',
- -'404_PathToWizard',
- -'405_PathToCleric',
- -'406_PathToElvenKnight',
- -'407_PathToElvenScout',
- -'408_PathToElvenwizard',
- -'409_PathToOracle',
- -'410_PathToPalusKnight',
- -'411_PathToAssassin',
- -'412_PathToDarkwizard',
- -'413_PathToShillienOracle',
- -'414_PathToOrcRaider',
- -'415_PathToOrcMonk',
- -'416_PathToOrcShaman',
- -'417_PathToScavenger',
- -'418_PathToArtisan',
- -'419_GetAPet',
- -'420_LittleWings',
- -'421_LittleWingAdventures',
- -'426_FishingShot',
- -'431_WeddingMarch',
- -'432_BirthdayPartySong',
- -'501_ProofOfClanAlliance',
- -'503_PursuitClanAmbition',
- -'621_EggDelivery',
- -'622_DeliveryOfSpecialLiquor',
- -'626_ADarkTwilight',
- -'627_HeartInSearchOfPower',
- -'634_InSearchofDimensionalFragments',
- -'999_C3Tutorial'
- -]
- -for name in __all__ :
- - try :
- - __import__('data.jscript.quests.'+name,globals(), locals(), ['__init__'], -1)
- - except :
- - print "Failed to import quest : ",name
- \ No newline at end of file
- #P Lisvus_GameServer
- Index: build/dist/gameserver/config/l2j-version.properties
- ===================================================================
- --- build/dist/gameserver/config/l2j-version.properties (revision 0)
- +++ build/dist/gameserver/config/l2j-version.properties (revision 0)
- @@ -0,0 +1,10 @@
- +
- + version=svn: E155036: Working copy 'D:\Programs\WorkSpace\micr0\Lisvus_GameServer' is too old (format 10, created by Subversion 1.6)
- + builddate=20130217_0348
- +
- + Detailed Info:
- + https://subversion.assembla.com/svn/L2JLisvus/trunk/Lisvus_GameServer
- +https://subversion.assembla.com/svn/L2JLisvus
- +
- +
- +
- Index: java/net/sf/l2j/gameserver/model/quest/Quest.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/quest/Quest.java (revision 325)
- +++ java/net/sf/l2j/gameserver/model/quest/Quest.java (working copy)
- @@ -27,6 +27,7 @@
- import java.util.logging.Level;
- import java.util.logging.Logger;
- +import javolution.util.FastList;
- import javolution.util.FastMap;
- import net.sf.l2j.Config;
- import net.sf.l2j.L2DatabaseFactory;
- @@ -35,374 +36,509 @@
- import net.sf.l2j.gameserver.model.L2Character;
- import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.script.scripting.ManagedScript;
- +import net.sf.l2j.gameserver.script.scripting.ScriptManager;
- import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
- import net.sf.l2j.gameserver.serverpackets.SystemMessage;
- import net.sf.l2j.gameserver.templates.L2NpcTemplate;
- /**
- * @author Luis Arias
- - *
- + *
- */
- -public abstract class Quest
- +public class Quest extends ManagedScript
- {
- - protected static Logger _log = Logger.getLogger(Quest.class.getName());
- + protected static Logger _log = Logger.getLogger(Quest.class.getName());
- - /** HashMap containing events from String value of the event */
- - private static Map<String, Quest> allEventsS = new FastMap<String, Quest>();
- + /** HashMap containing events from String value of the event */
- + private static Map<String, Quest> allEventsS = new FastMap<String, Quest>();
- + private static Map<String, FastList<QuestTimer>> _allEventTimers = new FastMap<>();
- - private final int _questId;
- - private final String _name;
- - private final String _descr;
- - private State initialState;
- - private Map<String, State> states;
- -
- - /**
- - * Return collection view of the values contains in the allEventS
- - * @return Collection<Quest>
- - */
- - public static Collection<Quest> findAllEvents()
- - {
- - return allEventsS.values();
- - }
- -
- - /**
- - * (Constructor)Add values to class variables and put the quest in HashMaps.
- - * @param questId : int pointing out the ID of the quest
- - * @param name : String corresponding to the name of the quest
- - * @param descr : String for the description of the quest
- - */
- - public Quest(int questId, String name, String descr)
- - {
- + private final int _questId;
- + private final String _name;
- + private final String _descr;
- + private State initialState;
- + private Map<String, State> states;
- - _questId = questId;
- - _name = name;
- - _descr = descr;
- + /**
- + * Return collection view of the values contains in the allEventS
- + *
- + * @return Collection<Quest>
- + */
- + public static Collection<Quest> findAllEvents()
- + {
- + return allEventsS.values();
- + }
- - states = new FastMap<String, State>();
- - if (questId != 0)
- - {
- - QuestManager.getInstance().getQuests().add(Quest.this);
- - }
- - else
- - {
- - allEventsS.put(name, this);
- - }
- - }
- + /**
- + * (Constructor)Add values to class variables and put the quest in HashMaps.
- + *
- + * @param questId : int pointing out the ID of the quest
- + * @param name : String corresponding to the name of the quest
- + * @param descr : String for the description of the quest
- + */
- + public Quest(int questId, String name, String descr)
- + {
- - /**
- - * Return ID of the quest
- - * @return int
- - */
- - public int getQuestIntId()
- + _questId = questId;
- + _name = name;
- + _descr = descr;
- +
- + states = new FastMap<String, State>();
- + if (questId != 0)
- {
- - return _questId;
- - }
- -
- - /**
- - * Set the initial state of the quest with parameter "state"
- - * @param state
- - */
- - public void setInitialState(State state)
- + QuestManager.getInstance().addQuest(this);
- + }
- + else
- {
- - this.initialState = state;
- - }
- -
- - /**
- - * Add a new QuestState to the database and return it.
- - * @param player
- - * @return QuestState : QuestState created
- - */
- - public QuestState newQuestState(L2PcInstance player)
- - {
- - QuestState qs = new QuestState(this, player, getInitialState(), false);
- - Quest.createQuestInDb(qs);
- - return qs;
- - }
- -
- - /**
- - * Return initial state of the quest
- - * @return State
- - */
- - public State getInitialState()
- - {
- - return initialState;
- - }
- -
- - /**
- - * Return name of the quest
- - * @return String
- - */
- - public String getName()
- - {
- - return _name;
- - }
- -
- - /**
- - * Return description of the quest
- - * @return String
- - */
- - public String getDescr()
- - {
- - return _descr;
- - }
- + allEventsS.put(name, this);
- + }
- + init_LoadGlobalData();
- + }
- - /**
- - * Add a state to the quest
- - * @param state
- - * @return state added
- - */
- + /**
- + * The function init_LoadGlobalData is, by default, called by the constructor of all quests.<br> Children
- + * of this class can implement this function in order to define what variables to load and what structures
- + * to save them in.<br> By default, nothing is loaded.
- + */
- + protected void init_LoadGlobalData()
- + {
- +
- + }
- +
- + /**
- + * The function saveGlobalData is, by default, called at shutdown, for all quests, by the
- + * QuestManager.<br> Children of this class can implement this function in order to convert their
- + * structures<br> into <var, value> tuples and make calls to save them to the database, if needed.<br> By
- + * default, nothing is saved.
- + */
- + public void saveGlobalData()
- + {
- +
- + }
- +
- + /**
- + * Return ID of the quest
- + *
- + * @return int
- + */
- + public int getQuestIntId()
- + {
- + return _questId;
- + }
- +
- + /**
- + * Set the initial state of the quest with parameter "state"
- + *
- + * @param state
- + */
- + public void setInitialState(State state)
- + {
- + this.initialState = state;
- + }
- +
- + /**
- + * Add a new QuestState to the database and return it.
- + *
- + * @param player
- + * @return QuestState : QuestState created
- + */
- + public QuestState newQuestState(L2PcInstance player)
- + {
- + QuestState qs = new QuestState(this, player, getInitialState(), false);
- + Quest.createQuestInDb(qs);
- + return qs;
- + }
- +
- + /**
- + * Return initial state of the quest
- + *
- + * @return State
- + */
- + public State getInitialState()
- + {
- + return initialState;
- + }
- +
- + /**
- + * Return name of the quest
- + *
- + * @return String
- + */
- + public String getName()
- + {
- + return _name;
- + }
- +
- + /**
- + * Return description of the quest
- + *
- + * @return String
- + */
- + public String getDescr()
- + {
- + return _descr;
- + }
- +
- + /**
- + * Add a state to the quest
- + *
- + * @param state
- + * @return state added
- + */
- public State addState(State state)
- {
- states.put(state.getName(), state);
- - return state;
- + return state;
- }
- -
- +
- /**
- * Add the quest to the NPC's startQuest
- + *
- * @param npcId
- * @return L2NpcTemplate : Start NPC
- */
- public L2NpcTemplate addStartNpc(int npcId)
- {
- - L2NpcTemplate t = NpcTable.getInstance().getTemplate(npcId);
- - if (t != null) {
- - t.addStartQuests(this);
- - }
- - return t;
- + L2NpcTemplate t = NpcTable.getInstance().getTemplate(npcId);
- + if (t != null)
- + {
- + t.addStartQuests(this);
- + }
- + return t;
- }
- -
- - // these are methods to call from java
- - public final boolean notifyAttack(L2NpcInstance npc, QuestState qs) {
- +
- + // these are methods to call from java
- + public final boolean notifyAttack(L2NpcInstance npc, QuestState qs)
- + {
- String res = null;
- - try { res = onAttack(npc, qs); } catch (Exception e) { return showError(qs, e); }
- + try
- + {
- + res = onAttack(npc, qs);
- + }
- + catch (Exception e)
- + {
- + return showError(qs, e);
- + }
- return showResult(qs, res);
- - }
- - public final boolean notifyDeath(L2NpcInstance npc, L2Character character, QuestState qs) {
- + }
- +
- + public final boolean notifyDeath(L2NpcInstance npc, L2Character character, QuestState qs)
- + {
- String res = null;
- - try { res = onDeath(npc, character, qs); } catch (Exception e) { return showError(qs, e); }
- + try
- + {
- + res = onDeath(npc, character, qs);
- + }
- + catch (Exception e)
- + {
- + return showError(qs, e);
- + }
- return showResult(qs, res);
- - }
- - public final boolean notifyEvent(String event, QuestState qs) {
- + }
- +
- + public final boolean notifyEvent(String event, QuestState qs)
- + {
- String res = null;
- - try { res = onEvent(event, qs); } catch (Exception e) { return showError(qs, e); }
- + try
- + {
- + res = onEvent(event, qs);
- + }
- + catch (Exception e)
- + {
- + return showError(qs, e);
- + }
- return showResult(qs, res);
- - }
- - public final boolean notifyKill (L2NpcInstance npc, QuestState qs) {
- - String res = null;
- - try { res = onKill(npc, qs); } catch (Exception e) { return showError(qs, e); }
- - return showResult(qs, res);
- - }
- - public final boolean notifyTalk (L2NpcInstance npc, QuestState qs) {
- - String res = null;
- - try { res = onTalk(npc, qs); } catch (Exception e) { return showError(qs, e); }
- + }
- +
- + public final boolean notifyKill(L2NpcInstance npc, QuestState qs)
- + {
- + String res = null;
- + try
- + {
- + res = onKill(npc, qs);
- + }
- + catch (Exception e)
- + {
- + return showError(qs, e);
- + }
- + return showResult(qs, res);
- + }
- +
- + public final boolean notifyTalk(L2NpcInstance npc, QuestState qs)
- + {
- + String res = null;
- + try
- + {
- + res = onTalk(npc, qs);
- + }
- + catch (Exception e)
- + {
- + return showError(qs, e);
- + }
- qs.getPlayer().setLastQuestNpcObject(npc.getObjectId());
- - return showResult(qs, res);
- - }
- + return showResult(qs, res);
- + }
- - // these are methods that java calls to invoke scripts
- - @SuppressWarnings("unused") public String onAttack(L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
- - @SuppressWarnings("unused") public String onDeath (L2NpcInstance npc, L2Character character, QuestState qs) { return onEvent("", qs); }
- - @SuppressWarnings("unused") public String onEvent(String event, QuestState qs) { return null; }
- - @SuppressWarnings("unused") public String onKill (L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
- - @SuppressWarnings("unused") public String onTalk (L2NpcInstance npc, QuestState qs) { return onEvent("", qs); }
- -
- - /**
- - * Show message error to player who has an access level greater than 0
- - * @param qs : QuestState
- - * @param t : Throwable
- - * @return boolean
- - */
- - private boolean showError(QuestState qs, Throwable t) {
- - _log.log(Level.WARNING, "", t);
- - if (qs.getPlayer().getAccessLevel() > 0) {
- - StringWriter sw = new StringWriter();
- - PrintWriter pw = new PrintWriter(sw);
- - t.printStackTrace(pw);
- - pw.close();
- - String res = "<html><body><title>Script error</title>"+sw.toString()+"</body></html>";
- - return showResult(qs, res);
- - }
- - return false;
- - }
- -
- - /**
- - * Show a message to player.<BR><BR>
- - * <U><I>Concept : </I></U><BR>
- - * 3 cases are managed according to the value of the parameter "res" :<BR>
- - * <LI><U>"res" ends with string ".html" :</U> an HTML is opened in order to be shown in a dialog box</LI>
- - * <LI><U>"res" starts with "<html>" :</U> the message hold in "res" is shown in a dialog box</LI>
- - * <LI><U>otherwise :</U> the message hold in "res" is shown in chat box</LI>
- - * @param qs : QuestState
- - * @param res : String pointing out the message to show at the player
- - * @return boolean
- - */
- - private boolean showResult(QuestState qs, String res) {
- - if (res == null)
- - return true;
- - if (res.endsWith(".htm")) {
- - qs.showHtmlFile(res);
- - }
- - else if (res.startsWith("<html>")) {
- - NpcHtmlMessage npcReply = new NpcHtmlMessage(5);
- - npcReply.setHtml(res);
- - qs.getPlayer().sendPacket(npcReply);
- - }
- - else {
- - SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
- - sm.addString(res);
- - qs.getPlayer().sendPacket(sm);
- - }
- - return false;
- - }
- -
- - /**
- - * Add quests to the L2PCInstance of the player.<BR><BR>
- - * <U><I>Action : </U></I><BR>
- - * Add state of quests, drops and variables for quests in the HashMap _quest of L2PcInstance
- - * @param player : Player who is entering the world
- - */
- - public static void playerEnter(L2PcInstance player) {
- + // these are methods that java calls to invoke scripts
- + public String onAttack(L2NpcInstance npc, QuestState qs)
- + {
- + return onEvent("", qs);
- + }
- + public String onDeath(L2NpcInstance npc, L2Character character, QuestState qs)
- + {
- + return onEvent("", qs);
- + }
- +
- + public String onEvent(String event, QuestState qs)
- + {
- + return null;
- + }
- +
- + public String onKill(L2NpcInstance npc, QuestState qs)
- + {
- + return onEvent("", qs);
- + }
- +
- + public String onTalk(L2NpcInstance npc, QuestState qs)
- + {
- + return onEvent("", qs);
- + }
- +
- + /**
- + * Show message error to player who has an access level greater than 0
- + *
- + * @param qs : QuestState
- + * @param t : Throwable
- + * @return boolean
- + */
- + private boolean showError(QuestState qs, Throwable t)
- + {
- + _log.log(Level.WARNING, "", t);
- + if (qs.getPlayer().getAccessLevel() > 0)
- + {
- + StringWriter sw = new StringWriter();
- + PrintWriter pw = new PrintWriter(sw);
- + t.printStackTrace(pw);
- + pw.close();
- + String res = "<html><body><title>Script error</title>" + sw.toString() + "</body></html>";
- + return showResult(qs, res);
- + }
- + return false;
- + }
- +
- + /**
- + * Show a message to player.<BR><BR> <U><I>Concept : </I></U><BR> 3 cases are managed according to the
- + * value of the parameter "res" :<BR> <LI><U>"res" ends with string ".html" :</U> an HTML is opened in
- + * order to be shown in a dialog box</LI> <LI><U>"res" starts with "<html>" :</U> the message hold in
- + * "res" is shown in a dialog box</LI> <LI><U>otherwise :</U> the message hold in "res" is shown in chat
- + * box</LI>
- + *
- + * @param qs : QuestState
- + * @param res : String pointing out the message to show at the player
- + * @return boolean
- + */
- + private boolean showResult(QuestState qs, String res)
- + {
- + if (res == null) return true;
- + if (res.endsWith(".htm"))
- + {
- + qs.showHtmlFile(res);
- + }
- + else if (res.startsWith("<html>"))
- + {
- + NpcHtmlMessage npcReply = new NpcHtmlMessage(5);
- + npcReply.setHtml(res);
- + qs.getPlayer().sendPacket(npcReply);
- + }
- + else
- + {
- + SystemMessage sm = new SystemMessage(SystemMessage.S1_S2);
- + sm.addString(res);
- + qs.getPlayer().sendPacket(sm);
- + }
- + return false;
- + }
- +
- + /**
- + * Add quests to the L2PCInstance of the player.<BR><BR> <U><I>Action : </U></I><BR> Add state of quests,
- + * drops and variables for quests in the HashMap _quest of L2PcInstance
- + *
- + * @param player : Player who is entering the world
- + */
- + public static void playerEnter(L2PcInstance player)
- + {
- +
- java.sql.Connection con = null;
- try
- {
- - // Get list of quests owned by the player from database
- + // Get list of quests owned by the player from database
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement;
- -
- - PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? and name=?");
- - PreparedStatement invalidQuestDataVar = con.prepareStatement("delete FROM character_quests WHERE char_id=? and name=? and var=?");
- -
- +
- + PreparedStatement invalidQuestData = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? and name=?");
- + PreparedStatement invalidQuestDataVar = con.prepareStatement("delete FROM character_quests WHERE char_id=? and name=? and var=?");
- +
- statement = con.prepareStatement("SELECT name,value FROM character_quests WHERE char_id=? AND var=?");
- statement.setInt(1, player.getObjectId());
- statement.setString(2, "<state>");
- - ResultSet rs = statement.executeQuery();
- - while (rs.next()) {
- -
- - // Get ID of the quest and ID of its state
- - String questId = rs.getString("name");
- - String stateId = rs.getString("value");
- -
- - // Search quest associated with the ID
- - Quest q = QuestManager.getInstance().getQuest(questId);
- - if (q == null) {
- - _log.finer("Unknown quest "+questId+" for player "+player.getName());
- - if (Config.AUTODELETE_INVALID_QUEST_DATA){
- + ResultSet rs = statement.executeQuery();
- + while (rs.next())
- + {
- +
- + // Get ID of the quest and ID of its state
- + String questId = rs.getString("name");
- + String stateId = rs.getString("value");
- +
- + // Search quest associated with the ID
- + Quest q = QuestManager.getInstance().getQuest(questId);
- + if (q == null)
- + {
- + _log.finer("Unknown quest " + questId + " for player " + player.getName());
- + if (Config.AUTODELETE_INVALID_QUEST_DATA)
- + {
- invalidQuestData.setInt(1, player.getObjectId());
- invalidQuestData.setString(2, questId);
- invalidQuestData.executeUpdate();
- - }
- - continue;
- - }
- -
- - // Identify the state of the quest for the player
- - boolean completed = false;
- - if (stateId.length() > 0 && stateId.charAt(0) == '*') { // probably obsolete check
- - completed = true;
- - stateId = stateId.substring(1);
- - }
- - if (stateId.equals("Completed"))
- - completed = true;
- + }
- + continue;
- + }
- - // Create an object State containing the state of the quest
- - State state = q.states.get(stateId);
- - if (state == null) {
- - _log.finer("Unknown state "+state+" in quest "+questId+" for player "+player.getName());
- - if (Config.AUTODELETE_INVALID_QUEST_DATA){
- - invalidQuestData.setInt(1, player.getObjectId());
- + // Identify the state of the quest for the player
- + boolean completed = false;
- + if (stateId.length() > 0 && stateId.charAt(0) == '*')
- + { // probably obsolete check
- + completed = true;
- + stateId = stateId.substring(1);
- + }
- + if (stateId.equals("Completed")) completed = true;
- +
- + // Create an object State containing the state of the quest
- + State state = q.states.get(stateId);
- + if (state == null)
- + {
- + _log.finer("Unknown state " + state + " in quest " + questId + " for player "
- + + player.getName());
- + if (Config.AUTODELETE_INVALID_QUEST_DATA)
- + {
- + invalidQuestData.setInt(1, player.getObjectId());
- invalidQuestData.setString(2, questId);
- invalidQuestData.executeUpdate();
- - }
- - continue;
- - }
- - // Create a new QuestState for the player that will be added to the player's list of quests
- - new QuestState(q, player, state, completed);
- - }
- - rs.close();
- + }
- + continue;
- + }
- + // Create a new QuestState for the player that will be added to the player's list of quests
- + new QuestState(q, player, state, completed);
- + }
- + rs.close();
- invalidQuestData.close();
- statement.close();
- // Get list of quests owned by the player from the DB in order to add variables used in the quest.
- statement = con.prepareStatement("SELECT name,var,value FROM character_quests WHERE char_id=?");
- - statement.setInt(1,player.getObjectId());
- - rs = statement.executeQuery();
- - while (rs.next()) {
- - String questId = rs.getString("name");
- - String var = rs.getString("var");
- - String value = rs.getString("value");
- - // Get the QuestState saved in the loop before
- - QuestState qs = player.getQuestState(questId);
- - if (qs == null) {
- - _log.finer("Lost variable "+var+" in quest "+questId+" for player "+player.getName());
- - if (Config.AUTODELETE_INVALID_QUEST_DATA){
- - invalidQuestDataVar.setInt (1,player.getObjectId());
- - invalidQuestDataVar.setString(2,questId);
- - invalidQuestDataVar.setString(3,var);
- + statement.setInt(1, player.getObjectId());
- + rs = statement.executeQuery();
- + while (rs.next())
- + {
- + String questId = rs.getString("name");
- + String var = rs.getString("var");
- + String value = rs.getString("value");
- + // Get the QuestState saved in the loop before
- + QuestState qs = player.getQuestState(questId);
- + if (qs == null)
- + {
- + _log.finer("Lost variable " + var + " in quest " + questId + " for player "
- + + player.getName());
- + if (Config.AUTODELETE_INVALID_QUEST_DATA)
- + {
- + invalidQuestDataVar.setInt(1, player.getObjectId());
- + invalidQuestDataVar.setString(2, questId);
- + invalidQuestDataVar.setString(3, var);
- invalidQuestDataVar.executeUpdate();
- - }
- - continue;
- - }
- - // Add parameter to the quest
- - qs.setInternal(var, value);
- - }
- - rs.close();
- + }
- + continue;
- + }
- + // Add parameter to the quest
- + qs.setInternal(var, value);
- + }
- + rs.close();
- invalidQuestDataVar.close();
- statement.close();
- -
- - } catch (Exception e) {
- - _log.log(Level.WARNING, "could not insert char quest:", e);
- - } finally {
- - try { con.close(); } catch (Exception e) {}
- +
- }
- -
- - // events
- - for (String name : allEventsS.keySet()) {
- - player.processQuestEvent(name, "enter");
- - }
- - }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "could not insert char quest:", e);
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + // events
- + for (String name : allEventsS.keySet())
- + {
- + player.processQuestEvent(name, "enter");
- + }
- + }
- - /**
- - * Insert in the database the quest for the player.
- - * @param qs : QuestState pointing out the state of the quest
- - * @param var : String designating the name of the variable for the quest
- - * @param value : String designating the value of the variable for the quest
- - */
- - public static void createQuestVarInDb(QuestState qs, String var, String value) {
- + /**
- + * Insert in the database the quest for the player.
- + *
- + * @param qs : QuestState pointing out the state of the quest
- + * @param var : String designating the name of the variable for the quest
- + * @param value : String designating the value of the variable for the quest
- + */
- + public static void createQuestVarInDb(QuestState qs, String var, String value)
- + {
- java.sql.Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement;
- statement = con.prepareStatement("INSERT INTO character_quests (char_id,name,var,value) VALUES (?,?,?,?)");
- - statement.setInt (1, qs.getPlayer().getObjectId());
- + statement.setInt(1, qs.getPlayer().getObjectId());
- statement.setString(2, qs.getQuest().getName());
- statement.setString(3, var);
- statement.setString(4, value);
- - statement.executeUpdate();
- + statement.executeUpdate();
- statement.close();
- - } catch (Exception e) {
- - _log.log(Level.WARNING, "could not insert char quest:", e);
- - } finally {
- - try { con.close(); } catch (Exception e) {}
- }
- - }
- -
- - /**
- - * Update the value of the variable "var" for the quest.<BR><BR>
- - * <U><I>Actions :</I></U><BR>
- - * The selection of the right record is made with :
- - * <LI>char_id = qs.getPlayer().getObjectID()</LI>
- - * <LI>name = qs.getQuest().getName()</LI>
- - * <LI>var = var</LI>
- - * <BR><BR>
- - * The modification made is :
- - * <LI>value = parameter value</LI>
- - * @param qs : Quest State
- - * @param var : String designating the name of the variable for quest
- - * @param value : String designating the value of the variable for quest
- - */
- - public static void updateQuestVarInDb(QuestState qs, String var, String value) {
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "could not insert char quest:", e);
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + /**
- + * Update the value of the variable "var" for the quest.<BR><BR> <U><I>Actions :</I></U><BR> The selection
- + * of the right record is made with : <LI>char_id = qs.getPlayer().getObjectID()</LI> <LI>name =
- + * qs.getQuest().getName()</LI> <LI>var = var</LI> <BR><BR> The modification made is : <LI>value =
- + * parameter value</LI>
- + *
- + * @param qs : Quest State
- + * @param var : String designating the name of the variable for quest
- + * @param value : String designating the value of the variable for quest
- + */
- + public static void updateQuestVarInDb(QuestState qs, String var, String value)
- + {
- java.sql.Connection con = null;
- try
- {
- @@ -410,95 +546,184 @@
- PreparedStatement statement;
- statement = con.prepareStatement("UPDATE character_quests SET value=? WHERE char_id=? AND name=? AND var = ?");
- statement.setString(1, value);
- - statement.setInt (2, qs.getPlayer().getObjectId());
- + statement.setInt(2, qs.getPlayer().getObjectId());
- statement.setString(3, qs.getQuest().getName());
- statement.setString(4, var);
- - statement.executeUpdate();
- + statement.executeUpdate();
- statement.close();
- - } catch (Exception e) {
- - _log.log(Level.WARNING, "could not update char quest:", e);
- - } finally {
- - try { con.close(); } catch (Exception e) {}
- }
- - }
- -
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "could not update char quest:", e);
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- /**
- * Delete a variable of player's quest from the database.
- + *
- * @param qs : object QuestState pointing out the player's quest
- * @param var : String designating the variable characterizing the quest
- */
- - public static void deleteQuestVarInDb(QuestState qs, String var) {
- + public static void deleteQuestVarInDb(QuestState qs, String var)
- + {
- java.sql.Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement;
- statement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? AND name=? AND var=?");
- - statement.setInt (1, qs.getPlayer().getObjectId());
- + statement.setInt(1, qs.getPlayer().getObjectId());
- statement.setString(2, qs.getQuest().getName());
- statement.setString(3, var);
- - statement.executeUpdate();
- + statement.executeUpdate();
- statement.close();
- - } catch (Exception e) {
- - _log.log(Level.WARNING, "could not delete char quest:", e);
- - } finally {
- - try { con.close(); } catch (Exception e) {}
- }
- - }
- -
- - /**
- - * Delete the player's quest from database.
- - * @param qs : QuestState pointing out the player's quest
- - */
- - public static void deleteQuestInDb(QuestState qs) {
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "could not delete char quest:", e);
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + /**
- + * Delete the player's quest from database.
- + *
- + * @param qs : QuestState pointing out the player's quest
- + */
- + public static void deleteQuestInDb(QuestState qs)
- + {
- java.sql.Connection con = null;
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- PreparedStatement statement;
- statement = con.prepareStatement("DELETE FROM character_quests WHERE char_id=? AND name=?");
- - statement.setInt (1, qs.getPlayer().getObjectId());
- + statement.setInt(1, qs.getPlayer().getObjectId());
- statement.setString(2, qs.getQuest().getName());
- - statement.executeUpdate();
- + statement.executeUpdate();
- statement.close();
- - } catch (Exception e) {
- - _log.log(Level.WARNING, "could not delete char quest:", e);
- - } finally {
- - try { con.close(); } catch (Exception e) {}
- }
- - }
- -
- - /**
- - * Create a record in database for quest.<BR><BR>
- - * <U><I>Actions :</I></U><BR>
- - * Use fucntion createQuestVarInDb() with following parameters :<BR>
- - * <LI>QuestState : parameter sq that puts in fields of database :
- - * <UL type="square">
- - * <LI>char_id : ID of the player</LI>
- - * <LI>name : name of the quest</LI>
- - * </UL>
- - * </LI>
- - * <LI>var : string "<state>" as the name of the variable for the quest</LI>
- - * <LI>val : string corresponding at the ID of the state (in fact, initial state)</LI>
- - * @param qs : QuestState
- - */
- - public static void createQuestInDb(QuestState qs) {
- - createQuestVarInDb(qs, "<state>", qs.getStateId());
- - }
- -
- - /**
- - * Update informations regarding quest in database.<BR>
- - * <U><I>Actions :</I></U><BR>
- - * <LI>Get ID state of the quest recorded in object qs</LI>
- - * <LI>Test if quest is completed. If true, add a star (*) before the ID state</LI>
- - * <LI>Save in database the ID state (with or without the star) for the variable called "<state>" of the quest</LI>
- - * @param qs : QuestState
- - */
- - public static void updateQuestInDb(QuestState qs)
- + catch (Exception e)
- {
- - String val = qs.getStateId();
- - //if (qs.isCompleted())
- - // val = "*" + val;
- - updateQuestVarInDb(qs, "<state>", val);
- - }
- + _log.log(Level.WARNING, "could not delete char quest:", e);
- + }
- + finally
- + {
- + try
- + {
- + con.close();
- + }
- + catch (Exception e)
- + {
- + }
- + }
- + }
- +
- + /**
- + * Create a record in database for quest.<BR><BR> <U><I>Actions :</I></U><BR> Use fucntion
- + * createQuestVarInDb() with following parameters :<BR> <LI>QuestState : parameter sq that puts in fields
- + * of database : <UL type="square"> <LI>char_id : ID of the player</LI> <LI>name : name of the quest</LI>
- + * </UL> </LI> <LI>var : string "<state>" as the name of the variable for the quest</LI> <LI>val :
- + * string corresponding at the ID of the state (in fact, initial state)</LI>
- + *
- + * @param qs : QuestState
- + */
- + public static void createQuestInDb(QuestState qs)
- + {
- + createQuestVarInDb(qs, "<state>", qs.getStateId());
- + }
- +
- + /**
- + * Update informations regarding quest in database.<BR> <U><I>Actions :</I></U><BR> <LI>Get ID state of
- + * the quest recorded in object qs</LI> <LI>Test if quest is completed. If true, add a star (*) before the
- + * ID state</LI> <LI>Save in database the ID state (with or without the star) for the variable called
- + * "<state>" of the quest</LI>
- + *
- + * @param qs : QuestState
- + */
- + public static void updateQuestInDb(QuestState qs)
- + {
- + String val = qs.getStateId();
- + // if (qs.isCompleted())
- + // val = "*" + val;
- + updateQuestVarInDb(qs, "<state>", val);
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ManagedScript#getScriptName()
- + */
- + @Override
- + public String getScriptName()
- + {
- + return this.getName();
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ManagedScript#setActive(boolean)
- + */
- + @Override
- + public void setActive(boolean status)
- + {
- + // TODO implement me
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ManagedScript#reload()
- + */
- + @Override
- + public boolean reload()
- + {
- + unload();
- + return super.reload();
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ManagedScript#unload()
- + */
- + @Override
- + public boolean unload()
- + {
- + this.saveGlobalData();
- + // cancel all pending timers before reloading.
- + // if timers ought to be restarted, the quest can take care of it
- + // with its code (example: save global data indicating what timer must
- + // be restarted).
- + for (FastList<QuestTimer> timers : _allEventTimers.values())
- + {
- + for (QuestTimer timer : timers)
- + {
- + timer.cancel();
- + }
- + }
- + _allEventTimers.clear();
- + return QuestManager.getInstance().removeQuest(this);
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ManagedScript#getScriptManager()
- + */
- + @Override
- + public ScriptManager<?> getScriptManager()
- + {
- + return QuestManager.getInstance();
- + }
- }
- Index: java/net/sf/l2j/gameserver/script/scripting/ScriptManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/script/scripting/ScriptManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/script/scripting/ScriptManager.java (revision 0)
- @@ -0,0 +1,45 @@
- +/*
- + * Copyright (C) 2004-2013 L2J Server
- + *
- + * This file is part of L2J Server.
- + *
- + * L2J Server is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2J Server is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.script.scripting;
- +
- +/**
- + * @author KenM
- + * @param <S>
- + */
- +public abstract class ScriptManager<S extends ManagedScript>
- +{
- + public abstract Iterable<S> getAllManagedScripts();
- +
- + public boolean reload(S ms)
- + {
- + return ms.reload();
- + }
- +
- + public boolean unload(S ms)
- + {
- + return ms.unload();
- + }
- +
- + public void setActive(S ms, boolean status)
- + {
- + ms.setActive(status);
- + }
- +
- + public abstract String getScriptManagerName();
- +}
- Index: java/net/sf/l2j/gameserver/instancemanager/QuestManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/instancemanager/QuestManager.java (revision 325)
- +++ java/net/sf/l2j/gameserver/instancemanager/QuestManager.java (working copy)
- @@ -1,55 +1,49 @@
- /*
- - * This program is free software; you can redistribute it and/or modify
- - * it under the terms of the GNU General Public License as published by
- - * the Free Software Foundation; either version 2, or (at your option)
- - * any later version.
- - *
- - * This program is distributed in the hope that it will be useful,
- - * but WITHOUT ANY WARRANTY; without even the implied warranty of
- - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- - * GNU General Public License for more details.
- - *
- - * You should have received a copy of the GNU General Public License
- - * along with this program; if not, write to the Free Software
- - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- - * 02111-1307, USA.
- - *
- - * http://www.gnu.org/copyleft/gpl.html
- + * This program is free software: you can redistribute it and/or modify it under
- + * the terms of the GNU General Public License as published by the Free Software
- + * Foundation, either version 3 of the License, or (at your option) any later
- + * version.
- + *
- + * This program is distributed in the hope that it will be useful, but WITHOUT
- + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- + * details.
- + *
- + * You should have received a copy of the GNU General Public License along with
- + * this program. If not, see <http://www.gnu.org/licenses/>.
- */
- package net.sf.l2j.gameserver.instancemanager;
- -import java.util.List;
- +import java.util.Map;
- import java.util.logging.Logger;
- -import javolution.util.FastList;
- -import net.sf.l2j.Config;
- +import javolution.util.FastMap;
- import net.sf.l2j.gameserver.model.quest.Quest;
- -import net.sf.l2j.gameserver.model.quest.jython.QuestJython;
- +import net.sf.l2j.gameserver.script.scripting.ScriptManager;
- -public class QuestManager
- +
- +public class QuestManager extends ScriptManager<Quest>
- {
- - protected static Logger _log = Logger.getLogger(QuestManager.class.getName());
- + protected static final Logger _log = Logger.getLogger(QuestManager.class.getName());
- // =========================================================
- - private static QuestManager _Instance;
- + private static QuestManager _instance;
- public static final QuestManager getInstance()
- {
- - if (_Instance == null)
- + if (_instance == null)
- {
- - System.out.println("Initializing QuestManager");
- - _Instance = new QuestManager();
- - if (!Config.ALT_DEV_NO_QUESTS)
- - _Instance.load();
- + _log.info("Initializing QuestManager");
- + _instance = new QuestManager();
- }
- - return _Instance;
- + return _instance;
- }
- // =========================================================
- -
- +
- // =========================================================
- // Data Field
- - private List<Quest> _Quests;
- -
- + private Map<String, Quest> _quests = new FastMap<String, Quest>();
- +
- // =========================================================
- // Constructor
- public QuestManager()
- @@ -58,65 +52,125 @@
- // =========================================================
- // Method - Public
- - // NOT WORKING CORRECTLY BECAUSE BSFMANAGER DOEN'T UNLOAD JYTHON SCRIPT
- - // NEED TO FIND THE SOLUTION BEFORE THIS WILL WORK CORRECLY
- - public final void reload()
- + public final boolean reload(String questFolder)
- {
- - /* Re-add later just incase problem exist now
- - this.getQuests().clear();
- - this.load();
- - */
- + Quest q = getQuest(questFolder);
- + if (q == null)
- + {
- + return false;
- + }
- + return q.reload();
- }
- -
- - // =========================================================
- - // Method - Private
- - private final void load()
- +
- + /**
- + * Reloads a the quest given by questId.<BR>
- + * <B>NOTICE: Will only work if the quest name is equal the quest folder name</B>
- + * @param questId The id of the quest to be reloaded
- + * @return true if reload was succesful, false otherwise
- + */
- + public final boolean reload(int questId)
- {
- - QuestJython.init();
- - System.out.println("Loaded: " + getQuests().size() + " quests");
- + Quest q = this.getQuest(questId);
- + if (q == null)
- + {
- + return false;
- + }
- + return q.reload();
- }
- +
- + public final void report()
- + {
- + _log.info("Loaded: " + getQuests().size() + " quests");
- + }
- +
- + public final void save()
- + {
- + for (Quest q: getQuests().values())
- + {
- + q.saveGlobalData();
- + }
- + }
- // =========================================================
- // Property - Public
- public final Quest getQuest(String name)
- {
- - int index = getQuestIndex(name);
- - if (index >= 0) return getQuests().get(index);
- - return null;
- + return getQuests().get(name);
- }
- public final Quest getQuest(int questId)
- {
- - int index = getQuestIndex(questId);
- - if (index >= 0) return getQuests().get(index);
- + for (Quest q: getQuests().values())
- + {
- + if (q.getQuestIntId() == questId)
- + return q;
- + }
- return null;
- }
- - public final int getQuestIndex(String name)
- +
- + public final void addQuest(Quest newQuest)
- {
- - Quest quest;
- - for (int i = 0; i < getQuests().size(); i++)
- + if (newQuest == null)
- {
- - quest = getQuests().get(i);
- - if (quest != null && quest.getName().equalsIgnoreCase(name)) return i;
- + throw new IllegalArgumentException("Quest argument cannot be null");
- }
- - return -1;
- + Quest old = this.getQuests().get(newQuest.getName());
- +
- + // FIXME: unloading the old quest at this point is a tad too late.
- + // the new quest has already initialized itself and read the data, starting
- + // an unpredictable number of tasks with that data. The old quest will now
- + // save data which will never be read.
- + // However, requesting the newQuest to re-read the data is not necessarily a
- + // good option, since the newQuest may have already started timers, spawned NPCs
- + // or taken any other action which it might re-take by re-reading the data.
- + // the current solution properly closes the running tasks of the old quest but
- + // ignores the data; perhaps the least of all evils...
- + if (old != null)
- + {
- + old.unload();
- + _log.info("Replaced: ("+old.getName()+") with a new version ("+newQuest.getName()+")");
- +
- + }
- + this.getQuests().put(newQuest.getName(), newQuest);
- }
- - public final int getQuestIndex(int questId)
- + public final boolean removeQuest(Quest q)
- {
- - Quest quest;
- - for (int i = 0; i < getQuests().size(); i++)
- - {
- - quest = getQuests().get(i);
- - if (quest != null && quest.getQuestIntId() == questId) return i;
- - }
- - return -1;
- + return this.getQuests().remove(q.getName()) != null;
- }
- +
- + public final FastMap<String, Quest> getQuests()
- + {
- + if (_quests == null) _quests = new FastMap<String, Quest>();
- + return (FastMap<String, Quest>) _quests;
- + }
- - public final List<Quest> getQuests()
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ScriptManager#getAllManagedScripts()
- + */
- + @Override
- + public Iterable<Quest> getAllManagedScripts()
- {
- - if (_Quests == null) _Quests = new FastList<Quest>();
- - return _Quests;
- + return _quests.values();
- }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ScriptManager#unload(net.sf.l2j.gameserver.scripting.ManagedScript)
- + */
- + @Override
- + public boolean unload(Quest ms)
- + {
- + ms.saveGlobalData();
- + return this.removeQuest(ms);
- + }
- +
- + /**
- + * @see net.sf.l2j.gameserver.scripting.ScriptManager#getScriptManagerName()
- + */
- + @Override
- + public String getScriptManagerName()
- + {
- + return "QuestManager";
- + }
- }
- Index: lib/jython-engine-2.2.1.jar
- ===================================================================
- Cannot display: file marked as a binary type.
- svn:mime-type = application/octet-stream
- Property changes on: lib\jython-engine-2.2.1.jar
- ___________________________________________________________________
- Added: svn:mime-type
- + application/octet-stream
- Index: build.xml
- ===================================================================
- --- build.xml (revision 325)
- +++ build.xml (working copy)
- @@ -42,6 +42,8 @@
- <include name="jython.jar"/>
- <include name="javolution.jar"/>
- <include name="hibernate3.jar"/>
- + <include name="jython-engine-2.2.1.jar"/>
- + <include name="java-engine-1.7.1.jar"/>
- </fileset>
- </path>
- Index: java/net/sf/l2j/gameserver/script/scripting/ManagedScript.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/script/scripting/ManagedScript.java (revision 0)
- +++ java/net/sf/l2j/gameserver/script/scripting/ManagedScript.java (revision 0)
- @@ -0,0 +1,98 @@
- +/*
- + * Copyright (C) 2004-2013 L2J Server
- + *
- + * This file is part of L2J Server.
- + *
- + * L2J Server is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2J Server is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.script.scripting;
- +
- +import java.io.File;
- +
- +import javax.script.ScriptException;
- +
- +/**
- + * Abstract class for classes that are meant to be implemented by scripts.<BR>
- + * @author KenM
- + */
- +public abstract class ManagedScript
- +{
- + private final File _scriptFile;
- + private long _lastLoadTime;
- + private boolean _isActive;
- +
- + public ManagedScript()
- + {
- + _scriptFile = L2ScriptEngineManager.getInstance().getCurrentLoadingScript();
- + setLastLoadTime(System.currentTimeMillis());
- + }
- +
- + /**
- + * Attempts to reload this script and to refresh the necessary bindings with it ScriptControler.<BR>
- + * Subclasses of this class should override this method to properly refresh their bindings when necessary.
- + * @return true if and only if the script was reloaded, false otherwise.
- + */
- + public boolean reload()
- + {
- + try
- + {
- + L2ScriptEngineManager.getInstance().executeScript(getScriptFile());
- + return true;
- + }
- + catch (ScriptException e)
- + {
- + return false;
- + }
- + }
- +
- + public abstract boolean unload();
- +
- + public void setActive(boolean status)
- + {
- + _isActive = status;
- + }
- +
- + public boolean isActive()
- + {
- + return _isActive;
- + }
- +
- + /**
- + * @return Returns the scriptFile.
- + */
- + public File getScriptFile()
- + {
- + return _scriptFile;
- + }
- +
- + /**
- + * @param lastLoadTime The lastLoadTime to set.
- + */
- + protected void setLastLoadTime(long lastLoadTime)
- + {
- + _lastLoadTime = lastLoadTime;
- + }
- +
- + /**
- + * @return Returns the lastLoadTime.
- + */
- + protected long getLastLoadTime()
- + {
- + return _lastLoadTime;
- + }
- +
- + public abstract String getScriptName();
- +
- + public abstract ScriptManager<?> getScriptManager();
- +}
- Index: java/net/sf/l2j/gameserver/GameServer.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/GameServer.java (revision 325)
- +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
- @@ -20,6 +20,7 @@
- import java.io.File;
- import java.io.FileInputStream;
- +import java.io.IOException;
- import java.io.InputStream;
- import java.util.Calendar;
- import java.util.logging.Level;
- @@ -64,6 +65,7 @@
- import net.sf.l2j.gameserver.model.entity.Hero;
- import net.sf.l2j.gameserver.pathfinding.geonodes.GeoPathFinding;
- import net.sf.l2j.gameserver.script.faenor.FaenorScriptEngine;
- +import net.sf.l2j.gameserver.script.scripting.L2ScriptEngineManager;
- import net.sf.l2j.gameserver.taskmanager.KnownListUpdateTaskManager;
- import net.sf.l2j.gameserver.taskmanager.TaskManager;
- import net.sf.l2j.gameserver.util.DynamicExtension;
- @@ -139,8 +141,9 @@
- new File(Config.DATAPACK_ROOT, "data/clans").mkdirs();
- new File(Config.DATAPACK_ROOT, "data/crests").mkdirs();
- +
- + L2ScriptEngineManager.getInstance();
- -
- // start game time control early
- GameTimeController.getInstance();
- @@ -250,6 +253,17 @@
- + try
- + {
- + _log.info("Loading Server Scripts");
- + File scripts = new File("data/scripts.cfg");
- + L2ScriptEngineManager.getInstance().executeScriptList(scripts);
- + }
- + catch (IOException ioe)
- + {
- + _log.severe("Failed loading scripts.cfg, no script going to be loaded");
- + }
- +
- if (Config.SAVE_DROPPED_ITEM)
- ItemsOnGroundManager.getInstance();
- Index: java/net/sf/l2j/Config.java
- ===================================================================
- --- java/net/sf/l2j/Config.java (revision 325)
- +++ java/net/sf/l2j/Config.java (working copy)
- @@ -29,7 +29,6 @@
- import java.util.logging.Logger;
- import javolution.util.FastList;
- -import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- /**
- * This class containce global server configuration.<br>
- @@ -42,6 +41,12 @@
- public final class Config
- {
- protected static Logger _log = Logger.getLogger(Config.class.getName());
- +
- + // --------------------------------------------------
- + // Constants
- + // --------------------------------------------------
- + public static final String EOL = System.getProperty("line.separator");
- +
- /** Debug/release mode */
- public static boolean DEBUG;
- /** Enable/disable assertions */
- @@ -1077,6 +1082,7 @@
- public static byte BUFFS_MAX_AMOUNT;
- /** Alt Settings for devs */
- + public static boolean ALT_DEV_NO_HANDLERS;
- public static boolean ALT_DEV_NO_QUESTS;
- public static boolean ALT_DEV_NO_SPAWNS;
- @@ -1648,6 +1654,7 @@
- ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Integer.parseInt(altSettings.getProperty("AltLottery2and1NumberPrize","200"));
- BUFFS_MAX_AMOUNT = Byte.parseByte(altSettings.getProperty("maxbuffamount","20"));
- ALT_DEV_NO_QUESTS = Boolean.parseBoolean(altSettings.getProperty("AltDevNoQuests", "False"));
- + ALT_DEV_NO_HANDLERS = Boolean.parseBoolean(altSettings.getProperty("AltDevNoHandlers", "False"));
- ALT_DEV_NO_SPAWNS = Boolean.parseBoolean(altSettings.getProperty("AltDevNoSpawns", "False"));
- }
- catch (Exception e)
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminQuest.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminQuest.java (revision 325)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminQuest.java (working copy)
- @@ -28,12 +28,16 @@
- */
- package net.sf.l2j.gameserver.handler.admincommandhandlers;
- +import java.io.File;
- import java.util.StringTokenizer;
- +import javax.script.ScriptException;
- +
- import net.sf.l2j.Config;
- import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
- import net.sf.l2j.gameserver.instancemanager.QuestManager;
- import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
- +import net.sf.l2j.gameserver.script.scripting.L2ScriptEngineManager;
- public class AdminQuest implements IAdminCommandHandler
- {
- @@ -61,7 +65,36 @@
- if (actualCommand.equalsIgnoreCase("admin_quest_reload"))
- {
- - QuestManager.getInstance().reload();
- + String[] parts = command.split(" ");
- + if (parts.length < 2)
- + {
- + // activeChar.sendMessage("Example: //script_load <questFolder>/<questSubFolders...>/<filename>.<ext> ");
- + activeChar.sendMessage("Example: //script_load quests/SagasSuperclass/__init__.py");
- + }
- + else
- + {
- + File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, parts[1]);
- + if (file.isFile())
- + {
- + try
- + {
- + L2ScriptEngineManager.getInstance().executeScript(file);
- + }
- + catch (ScriptException e)
- + {
- + activeChar.sendMessage("Failed loading: " + parts[1]);
- + L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
- + }
- + catch (Exception e)
- + {
- + activeChar.sendMessage("Failed loading: " + parts[1]);
- + }
- + }
- + else
- + {
- + activeChar.sendMessage("File Not Found: " + parts[1]);
- + }
- + }
- }
- return true;
- }
- Index: .classpath
- ===================================================================
- --- .classpath (revision 325)
- +++ .classpath (working copy)
- @@ -20,5 +20,7 @@
- <classpathentry kind="lib" path="lib/cglib-2.1.3.jar"/>
- <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
- <classpathentry kind="lib" path="lib/jta.jar"/>
- + <classpathentry kind="lib" path="lib/jython-engine-2.2.1.jar"/>
- + <classpathentry kind="lib" path="lib/java-engine-1.7.1.jar"/>
- <classpathentry kind="output" path="bin"/>
- </classpath>
- Index: java/config/altsettings.properties
- ===================================================================
- --- java/config/altsettings.properties (revision 325)
- +++ java/config/altsettings.properties (working copy)
- @@ -282,4 +282,6 @@
- # Don't load quests
- AltDevNoQuests = False
- # Don't load spawntable
- -AltDevNoSpawns = False
- \ No newline at end of file
- +AltDevNoSpawns = False
- +# Don't load masterhandler
- +AltDevNoHandlers = False
- \ No newline at end of file
- Index: java/net/sf/l2j/gameserver/script/scripting/L2ScriptEngineManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/script/scripting/L2ScriptEngineManager.java (revision 0)
- +++ java/net/sf/l2j/gameserver/script/scripting/L2ScriptEngineManager.java (revision 0)
- @@ -0,0 +1,535 @@
- +/*
- + * Copyright (C) 2004-2013 L2J Server
- + *
- + * This file is part of L2J Server.
- + *
- + * L2J Server is free software: you can redistribute it and/or modify
- + * it under the terms of the GNU General Public License as published by
- + * the Free Software Foundation, either version 3 of the License, or
- + * (at your option) any later version.
- + *
- + * L2J Server is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * General Public License for more details.
- + *
- + * You should have received a copy of the GNU General Public License
- + * along with this program. If not, see <http://www.gnu.org/licenses/>.
- + */
- +package net.sf.l2j.gameserver.script.scripting;
- +
- +import java.io.BufferedReader;
- +import java.io.File;
- +import java.io.FileInputStream;
- +import java.io.FileOutputStream;
- +import java.io.IOException;
- +import java.io.InputStreamReader;
- +import java.io.LineNumberReader;
- +import java.util.LinkedList;
- +import java.util.List;
- +import java.util.Map;
- +import java.util.logging.Level;
- +import java.util.logging.Logger;
- +
- +import javax.script.Compilable;
- +import javax.script.CompiledScript;
- +import javax.script.ScriptContext;
- +import javax.script.ScriptEngine;
- +import javax.script.ScriptEngineFactory;
- +import javax.script.ScriptEngineManager;
- +import javax.script.ScriptException;
- +import javax.script.SimpleScriptContext;
- +
- +import com.l2jserver.script.jython.JythonScriptEngine;
- +
- +import javolution.util.FastMap;
- +
- +import net.sf.l2j.Config;
- +
- +/**
- + * Caches script engines and provides functionality for executing and managing scripts.
- + * @author KenM
- + */
- +public final class L2ScriptEngineManager
- +{
- + private static final Logger _log = Logger.getLogger(L2ScriptEngineManager.class.getName());
- +
- + public static final File SCRIPT_FOLDER = new File(Config.DATAPACK_ROOT.getAbsolutePath(), "data/jscript");
- +
- + public static L2ScriptEngineManager getInstance()
- + {
- + return SingletonHolder._instance;
- + }
- +
- + private final Map<String, ScriptEngine> _nameEngines = new FastMap<String, ScriptEngine>();
- + private final Map<String, ScriptEngine> _extEngines = new FastMap<String, ScriptEngine>();
- + private final List<ScriptManager<?>> _scriptManagers = new LinkedList<ScriptManager<?>>();
- +
- + private File _currentLoadingScript;
- +
- + // Configs
- + // TODO move to config file
- + /**
- + * Informs(logs) the scripts being loaded.<BR>
- + * Apply only when executing script from files.<BR>
- + */
- + private static final boolean VERBOSE_LOADING = false;
- +
- + /**
- + * If the script engine supports compilation the script is compiled before execution.<BR>
- + */
- + private static final boolean ATTEMPT_COMPILATION = true;
- +
- + /**
- + * Clean an previous error log(if such exists) for the script being loaded before trying to load.<BR>
- + * Apply only when executing script from files.<BR>
- + */
- + private static final boolean PURGE_ERROR_LOG = true;
- +
- + protected L2ScriptEngineManager()
- + {
- + ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
- + List<ScriptEngineFactory> factories = scriptEngineManager.getEngineFactories();
- +
- + for (ScriptEngineFactory factory : factories)
- + {
- + try
- + {
- + ScriptEngine engine = factory.getScriptEngine();
- + boolean reg = false;
- + for (String name : factory.getNames())
- + {
- + ScriptEngine existentEngine = _nameEngines.get(name);
- +
- + if (existentEngine != null)
- + {
- + double engineVer = Double.parseDouble(factory.getEngineVersion());
- + double existentEngVer = Double.parseDouble(existentEngine.getFactory().getEngineVersion());
- +
- + if (engineVer <= existentEngVer)
- + {
- + continue;
- + }
- + }
- +
- + reg = true;
- + _nameEngines.put(name, engine);
- + }
- +
- + if (reg)
- + {
- + _log.info("Script Engine: " + factory.getEngineName() + " " + factory.getEngineVersion() + " - Language: " + factory.getLanguageName() + " - Language Version: " + factory.getLanguageVersion());
- + }
- +
- + for (String ext : factory.getExtensions())
- + {
- + if (!ext.equals("java") || factory.getLanguageName().equals("java"))
- + {
- + _extEngines.put(ext, engine);
- + }
- + }
- + }
- + catch (Exception e)
- + {
- + _log.log(Level.WARNING, "Failed initializing factory: " + e.getMessage(), e);
- + }
- + }
- +
- + preConfigure();
- + }
- +
- + private void preConfigure()
- + {
- + // Jython sys.path
- + String dataPackDirForwardSlashes = SCRIPT_FOLDER.getPath().replaceAll("\\\\", "/");
- + String configScript = "import sys;sys.path.insert(0,'" + dataPackDirForwardSlashes + "');";
- + try
- + {
- + eval("jython", configScript);
- + }
- + catch (ScriptException e)
- + {
- + _log.severe("Failed preconfiguring jython: " + e.getMessage());
- + }
- + }
- +
- + private ScriptEngine getEngineByName(String name)
- + {
- + return _nameEngines.get(name);
- + }
- +
- + private ScriptEngine getEngineByExtension(String ext)
- + {
- + return _extEngines.get(ext);
- + }
- +
- + public void executeScriptList(File list) throws IOException
- + {
- + File file;
- +
- + if (!Config.ALT_DEV_NO_HANDLERS && Config.ALT_DEV_NO_QUESTS)
- + {
- + file = new File(SCRIPT_FOLDER, "handlers/MasterHandler.java");
- +
- + try
- + {
- + executeScript(file);
- + _log.info("Handlers loaded, all other scripts skipped");
- + return;
- + }
- + catch (ScriptException se)
- + {
- + _log.log(Level.WARNING, "", se);
- + }
- + }
- +
- + if (Config.ALT_DEV_NO_QUESTS)
- + {
- + return;
- + }
- +
- + if (list.isFile())
- + {
- + try (FileInputStream fis = new FileInputStream(list);
- + InputStreamReader isr = new InputStreamReader(fis);
- + LineNumberReader lnr = new LineNumberReader(isr))
- + {
- + String line;
- + while ((line = lnr.readLine()) != null)
- + {
- + if (Config.ALT_DEV_NO_HANDLERS && line.contains("MasterHandler.java"))
- + {
- + continue;
- + }
- +
- + String[] parts = line.trim().split("#");
- +
- + if ((parts.length > 0) && !parts[0].isEmpty() && (parts[0].charAt(0) != '#'))
- + {
- + line = parts[0];
- +
- + if (line.endsWith("/**"))
- + {
- + line = line.substring(0, line.length() - 3);
- + }
- + else if (line.endsWith("/*"))
- + {
- + line = line.substring(0, line.length() - 2);
- + }
- +
- + file = new File(SCRIPT_FOLDER, line);
- +
- + if (file.isDirectory() && parts[0].endsWith("/**"))
- + {
- + executeAllScriptsInDirectory(file, true, 32);
- + }
- + else if (file.isDirectory() && parts[0].endsWith("/*"))
- + {
- + executeAllScriptsInDirectory(file);
- + }
- + else if (file.isFile())
- + {
- + try
- + {
- + executeScript(file);
- + }
- + catch (ScriptException e)
- + {
- + reportScriptFileError(file, e);
- + }
- + }
- + else
- + {
- + _log.warning("Failed loading: (" + file.getCanonicalPath() + ") @ " + list.getName() + ":" + lnr.getLineNumber() + " - Reason: doesnt exists or is not a file.");
- + }
- + }
- + }
- + }
- + }
- + else
- + {
- + throw new IllegalArgumentException("Argument must be an file containing a list of scripts to be loaded");
- + }
- + }
- +
- + public void executeAllScriptsInDirectory(File dir)
- + {
- + executeAllScriptsInDirectory(dir, false, 0);
- + }
- +
- + public void executeAllScriptsInDirectory(File dir, boolean recurseDown, int maxDepth)
- + {
- + executeAllScriptsInDirectory(dir, recurseDown, maxDepth, 0);
- + }
- +
- + private void executeAllScriptsInDirectory(File dir, boolean recurseDown, int maxDepth, int currentDepth)
- + {
- + if (dir.isDirectory())
- + {
- + for (File file : dir.listFiles())
- + {
- + if (file.isDirectory() && recurseDown && (maxDepth > currentDepth))
- + {
- + if (VERBOSE_LOADING)
- + {
- + _log.info("Entering folder: " + file.getName());
- + }
- + executeAllScriptsInDirectory(file, recurseDown, maxDepth, currentDepth + 1);
- + }
- + else if (file.isFile())
- + {
- + try
- + {
- + String name = file.getName();
- + int lastIndex = name.lastIndexOf('.');
- + String extension;
- + if (lastIndex != -1)
- + {
- + extension = name.substring(lastIndex + 1);
- + ScriptEngine engine = getEngineByExtension(extension);
- + if (engine != null)
- + {
- + executeScript(engine, file);
- + }
- + }
- + }
- + catch (ScriptException e)
- + {
- + reportScriptFileError(file, e);
- + }
- + }
- + }
- + }
- + else
- + {
- + throw new IllegalArgumentException("The argument directory either doesnt exists or is not an directory.");
- + }
- + }
- +
- + public void executeScript(File file) throws ScriptException
- + {
- + String name = file.getName();
- + int lastIndex = name.lastIndexOf('.');
- + String extension;
- + if (lastIndex != -1)
- + {
- + extension = name.substring(lastIndex + 1);
- + }
- + else
- + {
- + throw new ScriptException("Script file (" + name + ") doesnt has an extension that identifies the ScriptEngine to be used.");
- + }
- +
- + ScriptEngine engine = getEngineByExtension(extension);
- + if (engine == null)
- + {
- + throw new ScriptException("No engine registered for extension (" + extension + ")");
- + }
- + executeScript(engine, file);
- + }
- +
- + public void executeScript(String engineName, File file) throws ScriptException
- + {
- + ScriptEngine engine = getEngineByName(engineName);
- + if (engine == null)
- + {
- + throw new ScriptException("No engine registered with name (" + engineName + ")");
- + }
- + executeScript(engine, file);
- + }
- +
- + public void executeScript(ScriptEngine engine, File file) throws ScriptException
- + {
- + if (VERBOSE_LOADING)
- + {
- + _log.info("Loading Script: " + file.getAbsolutePath());
- + }
- +
- + if (PURGE_ERROR_LOG)
- + {
- + String name = file.getAbsolutePath() + ".error.log";
- + File errorLog = new File(name);
- + if (errorLog.isFile())
- + {
- + errorLog.delete();
- + }
- + }
- +
- + final String relativeName = file.getAbsolutePath().substring(SCRIPT_FOLDER.getAbsolutePath().length() + 1).replace('\\', '/');
- + try (FileInputStream fis = new FileInputStream(file);
- + InputStreamReader isr = new InputStreamReader(fis);
- + BufferedReader reader = new BufferedReader(isr))
- + {
- + if ((engine instanceof Compilable) && ATTEMPT_COMPILATION)
- + {
- + ScriptContext context = new SimpleScriptContext();
- + context.setAttribute("mainClass", getClassForFile(file).replace('/', '.').replace('\\', '.'), ScriptContext.ENGINE_SCOPE);
- + context.setAttribute(ScriptEngine.FILENAME, relativeName, ScriptContext.ENGINE_SCOPE);
- + context.setAttribute("classpath", SCRIPT_FOLDER.getAbsolutePath(), ScriptContext.ENGINE_SCOPE);
- + context.setAttribute("sourcepath", SCRIPT_FOLDER.getAbsolutePath(), ScriptContext.ENGINE_SCOPE);
- + context.setAttribute(JythonScriptEngine.JYTHON_ENGINE_INSTANCE, engine, ScriptContext.ENGINE_SCOPE);
- +
- + setCurrentLoadingScript(file);
- + ScriptContext ctx = engine.getContext();
- + try
- + {
- + engine.setContext(context);
- + Compilable eng = (Compilable) engine;
- + CompiledScript cs = eng.compile(reader);
- + cs.eval(context);
- + }
- + finally
- + {
- + engine.setContext(ctx);
- + setCurrentLoadingScript(null);
- + context.removeAttribute(ScriptEngine.FILENAME, ScriptContext.ENGINE_SCOPE);
- + context.removeAttribute("mainClass", ScriptContext.ENGINE_SCOPE);
- + }
- + }
- + else
- + {
- + ScriptContext context = new SimpleScriptContext();
- + context.setAttribute("mainClass", getClassForFile(file).replace('/', '.').replace('\\', '.'), ScriptContext.ENGINE_SCOPE);
- + context.setAttribute(ScriptEngine.FILENAME, relativeName, ScriptContext.ENGINE_SCOPE);
- + context.setAttribute("classpath", SCRIPT_FOLDER.getAbsolutePath(), ScriptContext.ENGINE_SCOPE);
- + context.setAttribute("sourcepath", SCRIPT_FOLDER.getAbsolutePath(), ScriptContext.ENGINE_SCOPE);
- + setCurrentLoadingScript(file);
- + try
- + {
- + engine.eval(reader, context);
- + }
- + finally
- + {
- + setCurrentLoadingScript(null);
- + engine.getContext().removeAttribute(ScriptEngine.FILENAME, ScriptContext.ENGINE_SCOPE);
- + engine.getContext().removeAttribute("mainClass", ScriptContext.ENGINE_SCOPE);
- + }
- +
- + }
- + }
- + catch (IOException e)
- + {
- + _log.log(Level.WARNING, "Error executing script!", e);
- + }
- + }
- +
- + public static String getClassForFile(File script)
- + {
- + String path = script.getAbsolutePath();
- + String scpPath = SCRIPT_FOLDER.getAbsolutePath();
- + if (path.startsWith(scpPath))
- + {
- + int idx = path.lastIndexOf('.');
- + return path.substring(scpPath.length() + 1, idx);
- + }
- + return null;
- + }
- +
- + public ScriptContext getScriptContext(ScriptEngine engine)
- + {
- + return engine.getContext();
- + }
- +
- + public ScriptContext getScriptContext(String engineName)
- + {
- + ScriptEngine engine = getEngineByName(engineName);
- + if (engine == null)
- + {
- + throw new IllegalStateException("No engine registered with name (" + engineName + ")");
- + }
- + return getScriptContext(engine);
- + }
- +
- + public Object eval(ScriptEngine engine, String script, ScriptContext context) throws ScriptException
- + {
- + if ((engine instanceof Compilable) && ATTEMPT_COMPILATION)
- + {
- + Compilable eng = (Compilable) engine;
- + CompiledScript cs = eng.compile(script);
- + return context != null ? cs.eval(context) : cs.eval();
- + }
- + return context != null ? engine.eval(script, context) : engine.eval(script);
- + }
- +
- + public Object eval(String engineName, String script) throws ScriptException
- + {
- + return eval(engineName, script, null);
- + }
- +
- + public Object eval(String engineName, String script, ScriptContext context) throws ScriptException
- + {
- + ScriptEngine engine = getEngineByName(engineName);
- + if (engine == null)
- + {
- + throw new ScriptException("No engine registered with name (" + engineName + ")");
- + }
- + return eval(engine, script, context);
- + }
- +
- + public Object eval(ScriptEngine engine, String script) throws ScriptException
- + {
- + return eval(engine, script, null);
- + }
- +
- + public void reportScriptFileError(File script, ScriptException e)
- + {
- + String dir = script.getParent();
- + String name = script.getName() + ".error.log";
- + if (dir != null)
- + {
- + final File file = new File(dir + "/" + name);
- + try (FileOutputStream fos = new FileOutputStream(file))
- + {
- + String errorHeader = "Error on: " + file.getCanonicalPath() + Config.EOL + "Line: " + e.getLineNumber() + " - Column: " + e.getColumnNumber() + Config.EOL + Config.EOL;
- + fos.write(errorHeader.getBytes());
- + fos.write(e.getMessage().getBytes());
- + _log.warning("Failed executing script: " + script.getAbsolutePath() + ". See " + file.getName() + " for details.");
- + }
- + catch (IOException ioe)
- + {
- + _log.log(Level.WARNING, "Failed executing script: " + script.getAbsolutePath() + Config.EOL + e.getMessage() + "Additionally failed when trying to write an error report on script directory. Reason: " + ioe.getMessage(), ioe);
- + }
- + }
- + else
- + {
- + _log.log(Level.WARNING, "Failed executing script: " + script.getAbsolutePath() + Config.EOL + e.getMessage() + "Additionally failed when trying to write an error report on script directory.", e);
- + }
- + }
- +
- + public void registerScriptManager(ScriptManager<?> manager)
- + {
- + _scriptManagers.add(manager);
- + }
- +
- + public void removeScriptManager(ScriptManager<?> manager)
- + {
- + _scriptManagers.remove(manager);
- + }
- +
- + public List<ScriptManager<?>> getScriptManagers()
- + {
- + return _scriptManagers;
- +
- + }
- +
- + /**
- + * @param currentLoadingScript The currentLoadingScript to set.
- + */
- + protected void setCurrentLoadingScript(File currentLoadingScript)
- + {
- + _currentLoadingScript = currentLoadingScript;
- + }
- +
- + /**
- + * @return Returns the currentLoadingScript.
- + */
- + protected File getCurrentLoadingScript()
- + {
- + return _currentLoadingScript;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final L2ScriptEngineManager _instance = new L2ScriptEngineManager();
- + }
- +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement