Premium account manager from latest projects.

Custom community board from latest projects.
Fixed existing hexid replacement issue.
This commit is contained in:
MobiusDev 2017-07-24 14:05:36 +00:00
parent 8661b3aa24
commit 3753109f29
18 changed files with 1088 additions and 218 deletions

View File

@ -1,7 +1,6 @@
DROP TABLE IF EXISTS `account_premium`; DROP TABLE IF EXISTS `account_premium`;
CREATE TABLE `account_premium` ( CREATE TABLE `account_premium` (
`account_name` varchar(45) NOT NULL DEFAULT '', `account_name` varchar(45) NOT NULL DEFAULT '',
`premium_service` int(1) NOT NULL DEFAULT '0',
`enddate` decimal(20,0) NOT NULL DEFAULT '0', `enddate` decimal(20,0) NOT NULL DEFAULT '0',
PRIMARY KEY (`account_name`) PRIMARY KEY (`account_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -575,7 +575,7 @@ ShopMinRangeFromNpc = 100
# Enable Custom Community Board. # Enable Custom Community Board.
# Default: False # Default: False
CustomCommunityBoard = False CustomCommunityBoard = True
# Currency used by the Community Board (itemId). # Currency used by the Community Board (itemId).
# Default: 57 (Adena) # Default: 57 (Adena)
@ -593,6 +593,10 @@ CommunityEnableTeleports = True
# Default: True # Default: True
CommunityEnableBuffs = True CommunityEnableBuffs = True
# Enable Heal.
# Default: True
CommunityEnableHeal = True
# Price for Teleports. # Price for Teleports.
# Default: 0 (free) # Default: 0 (free)
CommunityTeleportPrice = 0 CommunityTeleportPrice = 0
@ -601,6 +605,10 @@ CommunityTeleportPrice = 0
# Default: 0 (free) # Default: 0 (free)
CommunityBuffPrice = 0 CommunityBuffPrice = 0
# Price for Heal.
# Default: 0 (free)
CommunityHealPrice = 0
# Disable Community Board while in combat. # Disable Community Board while in combat.
# Default: True # Default: True
CommunityCombatDisabled = True CommunityCombatDisabled = True
@ -609,6 +617,22 @@ CommunityCombatDisabled = True
# Default: True # Default: True
CommunityKarmaDisabled = True CommunityKarmaDisabled = True
# Cast animations of each buff.
# Default: False
CommunityCastAnimations = False
# Enable buying premium from community board.
# Premium System must be enabled.
# Default: False
CommunityPremiumSystem = False
# ItemID for buying premium in community board.
# Check data/html/CommunityBoard/Custom/premium/main.html
CommunityPremiumBuyCoinId = 57
# Amount of coins needed for each premium day bought.
CommunityPremiumPricePerDay = 1000000
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Premium System (VIP) # Premium System (VIP)

View File

@ -8,24 +8,7 @@
<table width=20> <table width=20>
<tr> <tr>
<td> <td>
<table valign="top"> %navigation%
<tr>
<td height=25></td>
</tr>
<tr>
<td><button value="Home" action="bypass _bbstop;home.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Area_Down" fore="L2UI_CT1.HtmlWnd_DF_Area"></td>
</tr>
<tr>
<td><button value="Buffer" action="bypass _bbstop;buffer/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Level_Down" fore="L2UI_CT1.HtmlWnd_DF_Level"></td>
</tr>
<tr>
<td><button value="Merchant" action="bypass _bbstop;merchant/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_BuyEquip_Down" fore="L2UI_CT1.OlympiadWnd_DF_BuyEquip"></td>
</tr>
<tr>
<td><button value="Gatekeeper" action="bypass _bbstop;gatekeeper/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Campaign_Down" fore="L2UI_CT1.HtmlWnd_DF_Campaign"></td>
</tr>
</center>
</table>
</td> </td>
<td> <td>
<center> <center>
@ -69,41 +52,47 @@
<td align="center"> <td align="center">
<table align=center border="0" height=85 > <table align=center border="0" height=85 >
<tr> <tr>
<td align=center width=40><button value="." action="bypass _bbsbuff;1077,3,buffer/main" width=32 height=32 back="icon.skill1077" fore="icon.skill1077"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1077,3;buffer/main" width=32 height=32 back="icon.skill1077" fore="icon.skill1077"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1240,3,buffer/main" width=32 height=32 back="icon.skill1240" fore="icon.skill1240"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1240,3;buffer/main" width=32 height=32 back="icon.skill1240" fore="icon.skill1240"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1086,2,buffer/main" width=32 height=32 back="icon.skill1086" fore="icon.skill1086"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1086,2;buffer/main" width=32 height=32 back="icon.skill1086" fore="icon.skill1086"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1032,3,buffer/main" width=32 height=32 back="icon.skill1032" fore="icon.skill1032"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1032,3;buffer/main" width=32 height=32 back="icon.skill1032" fore="icon.skill1032"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1073,2,buffer/main" width=32 height=32 back="icon.skill1073" fore="icon.skill1073"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1073,2;buffer/main" width=32 height=32 back="icon.skill1073" fore="icon.skill1073"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1036,2,buffer/main" width=32 height=32 back="icon.skill1036" fore="icon.skill1036"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1036,2;buffer/main" width=32 height=32 back="icon.skill1036" fore="icon.skill1036"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1035,4,buffer/main" width=32 height=32 back="icon.skill1035" fore="icon.skill1035"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1035,4;buffer/main" width=32 height=32 back="icon.skill1035" fore="icon.skill1035"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1068,3,buffer/main" width=32 height=32 back="icon.skill1068" fore="icon.skill1068"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1068,3;buffer/main" width=32 height=32 back="icon.skill1068" fore="icon.skill1068"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1040,3,buffer/main" width=32 height=32 back="icon.skill1040" fore="icon.skill1040"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1040,3;buffer/main" width=32 height=32 back="icon.skill1040" fore="icon.skill1040"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1044,3,buffer/main" width=32 height=32 back="icon.skill1044" fore="icon.skill1044"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1044,3;buffer/main" width=32 height=32 back="icon.skill1044" fore="icon.skill1044"></td>
</tr> </tr>
<tr> <tr>
<td align=center width=40><button value="." action="bypass _bbsbuff;1182,3,buffer/main" width=32 height=32 back="icon.skill1182" fore="icon.skill1182"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1182,3;buffer/main" width=32 height=32 back="icon.skill1182" fore="icon.skill1182"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1191,3,buffer/main" width=32 height=32 back="icon.skill1191" fore="icon.skill1191"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1191,3;buffer/main" width=32 height=32 back="icon.skill1191" fore="icon.skill1191"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1033,3,buffer/main" width=32 height=32 back="icon.skill1033" fore="icon.skill1033"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1033,3;buffer/main" width=32 height=32 back="icon.skill1033" fore="icon.skill1033"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1189,3,buffer/main" width=32 height=32 back="icon.skill1189" fore="icon.skill1189"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1189,3;buffer/main" width=32 height=32 back="icon.skill1189" fore="icon.skill1189"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1392,3,buffer/main" width=32 height=32 back="icon.skill1392" fore="icon.skill1392"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1392,3;buffer/main" width=32 height=32 back="icon.skill1392" fore="icon.skill1392"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1393,3,buffer/main" width=32 height=32 back="icon.skill1393" fore="icon.skill1393"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1393,3;buffer/main" width=32 height=32 back="icon.skill1393" fore="icon.skill1393"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1303,2,buffer/main" width=32 height=32 back="icon.skill1303" fore="icon.skill1303"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1303,2;buffer/main" width=32 height=32 back="icon.skill1303" fore="icon.skill1303"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1059,3,buffer/main" width=32 height=32 back="icon.skill1059" fore="icon.skill1059"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1059,3;buffer/main" width=32 height=32 back="icon.skill1059" fore="icon.skill1059"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1242,3,buffer/main" width=32 height=32 back="icon.skill1242" fore="icon.skill1242"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1242,3;buffer/main" width=32 height=32 back="icon.skill1242" fore="icon.skill1242"></td>
<td align=center width=40><button value="." action="bypass _bbsbuff;1268,4,buffer/main" width=32 height=32 back="icon.skill1268" fore="icon.skill1268"></td> <td align=center width=40><button value="." action="bypass _bbsbuff;1268,4;buffer/main" width=32 height=32 back="icon.skill1268" fore="icon.skill1268"></td>
</tr> </tr>
<tr> <tr>
<td height=15></td> <td height=15></td>
</tr> </tr>
</table> </table>
<table align=center border="0"> <table align=center border="0">
<tr>
<td align=center>Heal</td>
</tr>
<tr>
<td align=center><button value="." action="bypass _bbsheal;buffer/main" width=32 height=32 back="icon.skill1027" fore="icon.skill1027"></td>
</tr>
<tr> <tr>
<td> <td>
<center><img src="L2UI.SquareGray" width=500 height=1></center> <center><img src="L2UI.SquareGray" width=500 height=1></center>
</td> </td>
</tr> </tr>
<tr> <tr>
<td height=10></td> <td height=15></td>
</tr> </tr>
</table> </table>
</td> </td>
@ -114,7 +103,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td height=150></td> <td height=120></td>
</tr> </tr>
</table> </table>
<table border=0 cellpadding=0 cellspacing=0 width=555> <table border=0 cellpadding=0 cellspacing=0 width=555>

View File

@ -0,0 +1,90 @@
<html noscrollbar>
<body>
<table width=700>
<tr>
<td height=10></td>
</tr>
</table>
<table width=20>
<tr>
<td>
%navigation%
</td>
<td>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=555 height=455 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=25></td>
</tr>
<tr>
<td height=25 align="center"><font name="hs12" color="CDB67F">Drop Search</font></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=200 height=1></center>
</td>
</tr>
<tr>
<td height=20></td>
</tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. Input item name or partial name to search for items.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. Choose item icon to search for drops.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. Select an NPC, you can see it's location on the world map.</font></td></tr> <tr>
<td height=10></td>
</tr>
<tr>
<td height=15 align="center">
<table>
<tr>
<td width=70>ItemName:</td><td><edit width=200 var="itemname"></td>
<td><button value="Search" action="bypass _bbs_search_item $itemname" width=60 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
</td>
</tr>
<tr><td height=15 align="center"></td></tr>
<tr>
<td height=10></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=500 height=1></center>
</td>
</tr>
<tr>
<td height=20></td>
</tr>
<tr>
<td align="center">
<table align=center border="0" height=250>
%searchResult%
</table>
<table align=center border="0">
%pages%
</table>
</td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555>
<tr>
<td height=10></td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=17></td>
</tr>
<tr>
<td align=center><font color=696969>LINEAGE II - COMMUNITY BOARD</font></td>
</tr>
<tr>
<td height=15></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>

View File

@ -8,24 +8,7 @@
<table width=20> <table width=20>
<tr> <tr>
<td> <td>
<table valign="top"> %navigation%
<tr>
<td height=25></td>
</tr>
<tr>
<td><button value="Home" action="bypass _bbstop;home.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Area_Down" fore="L2UI_CT1.HtmlWnd_DF_Area"></td>
</tr>
<tr>
<td><button value="Buffer" action="bypass _bbstop;buffer/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Level_Down" fore="L2UI_CT1.HtmlWnd_DF_Level"></td>
</tr>
<tr>
<td><button value="Merchant" action="bypass _bbstop;merchant/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_BuyEquip_Down" fore="L2UI_CT1.OlympiadWnd_DF_BuyEquip"></td>
</tr>
<tr>
<td><button value="Gatekeeper" action="bypass _bbstop;gatekeeper/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Campaign_Down" fore="L2UI_CT1.HtmlWnd_DF_Campaign"></td>
</tr>
</center>
</table>
</td> </td>
<td> <td>
<center> <center>
@ -77,10 +60,11 @@
</tr> </tr>
<tr> <tr>
<td><button value="Gludio" action="bypass _bbsteleport;-14225,123540,-3121" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Gludio" action="bypass _bbsteleport;-14225,123540,-3121" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Gludin" action="bypass _bbsteleport;-83063,150791,-3133" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Schuttgart" action="bypass _bbsteleport;87358,-141982,-1341" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Schuttgart" action="bypass _bbsteleport;87358,-141982,-1341" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Heine" action="bypass _bbsteleport;111115,219017,-3547" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr> </tr>
<tr> <tr>
<td><button value="Gludin" action="bypass _bbsteleport;-83063,150791,-3133" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Hunters" action="bypass _bbsteleport;116589,76268,-2734" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Hunters" action="bypass _bbsteleport;116589,76268,-2734" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr> </tr>
</table> </table>
@ -106,6 +90,7 @@
<tr> <tr>
<td><button value="Dark Elven" action="bypass _bbsteleport;12428,16551,-4588" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Dark Elven" action="bypass _bbsteleport;12428,16551,-4588" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Elven" action="bypass _bbsteleport;45873,49288,-3064" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Elven" action="bypass _bbsteleport;45873,49288,-3064" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Kamael" action="bypass _bbsteleport;-116934,46616,368" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr> </tr>
</table> </table>
</td> </td>

View File

@ -8,24 +8,7 @@
<table width=20> <table width=20>
<tr> <tr>
<td> <td>
<table valign="top"> %navigation%
<tr>
<td height=25></td>
</tr>
<tr>
<td><button value="Home" action="bypass _bbstop;home.html" width=200 height=30 back="l2ui_ct1.button.button_df_small_down" fore="l2ui_ct1.button.button_df_small"></td>
</tr>
<tr>
<td><button value="Buffer" action="bypass _bbstop;buffer/main.html" width=200 height=30 back="l2ui_ct1.button.button_df_small_down" fore="l2ui_ct1.button.button_df_small"></td>
</tr>
<tr>
<td><button value="Merchant" action="bypass _bbstop;merchant/main.html" width=200 height=30 back="l2ui_ct1.button.button_df_small_down" fore="l2ui_ct1.button.button_df_small"></td>
</tr>
<tr>
<td><button value="Gatekeeper" action="bypass _bbstop;gatekeeper/main.html" width=200 height=30 back="l2ui_ct1.button.button_df_small_down" fore="l2ui_ct1.button.button_df_small"></td>
</tr>
</center>
</table>
</td> </td>
<td> <td>
<center> <center>

View File

@ -8,24 +8,7 @@
<table width=20> <table width=20>
<tr> <tr>
<td> <td>
<table valign="top"> %navigation%
<tr>
<td height=25></td>
</tr>
<tr>
<td><button value="Home" action="bypass _bbstop;home.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Area_Down" fore="L2UI_CT1.HtmlWnd_DF_Area"></td>
</tr>
<tr>
<td><button value="Buffer" action="bypass _bbstop;buffer/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Level_Down" fore="L2UI_CT1.HtmlWnd_DF_Level"></td>
</tr>
<tr>
<td><button value="Merchant" action="bypass _bbstop;merchant/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_BuyEquip_Down" fore="L2UI_CT1.OlympiadWnd_DF_BuyEquip"></td>
</tr>
<tr>
<td><button value="Gatekeeper" action="bypass _bbstop;gatekeeper/main.html" width=200 height=30 back="L2UI_CT1.HtmlWnd_DF_Campaign_Down" fore="L2UI_CT1.HtmlWnd_DF_Campaign"></td>
</tr>
</center>
</table>
</td> </td>
<td> <td>
<center> <center>

View File

@ -0,0 +1,23 @@
<table valign="top">
<tr>
<td height=25></td>
</tr>
<tr>
<td><button value="Home" action="bypass _bbstop;home.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"></td></tr>
</tr>
<tr>
<td><button value="Buffer" action="bypass _bbstop;buffer/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"></td></tr>
</tr>
<tr>
<td><button value="Merchant" action="bypass _bbstop;merchant/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"></td></tr>
</tr>
<tr>
<td><button value="Gatekeeper" action="bypass _bbstop;gatekeeper/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"></td></tr>
</tr>
<tr>
<td><button value="Drop Search" action="bypass _bbstop;dropsearch/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Info_Down" fore="L2UI_CT1.OlympiadWnd_DF_Info"></td></tr>
</tr>
<tr>
<td><button value="Premium" action="bypass _bbstop;premium/main.html" width=200 height=30 back="L2UI_CT1.OlympiadWnd_DF_Reward_Down" fore="L2UI_CT1.OlympiadWnd_DF_Reward"></td>
</tr>
</table>

View File

@ -0,0 +1,116 @@
<html noscrollbar>
<body>
<table width=700>
<tr>
<td height=10></td>
</tr>
</table>
<table width=20>
<tr>
<td>
%navigation%
</td>
<td>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=555 height=455 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=25></td>
</tr>
<tr>
<td height=25 align="center"><font name="hs12" color="CDB67F">Premium Manager</font></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=200 height=1></center>
</td>
</tr>
<tr>
<td height=20></td>
</tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. Premium benefits CAN NOT BE TRANSFERED.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. Premium does not effect party members.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. Premium benefits effect ALL characters in same account.</font></td></tr>
<tr>
<td height=20></td>
</tr>
<tr><td height=15 align="center"></td></tr>
<tr><td height=15 align="center"></td></tr>
<tr>
<td height=10></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=500 height=1></center>
</td>
</tr>
<tr>
<td height=25></td>
</tr>
<tr>
<td align="center">
<table align=center border="0" height=85 >
<!-- // example _bbspremium;1,2, (first number: day count; second number: Price -->
<tr>
<td align=center><button value="1 Day [Price 1kk]" action="bypass _bbspremium;1" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td align=center><button value="3 Day [Price 3kk]" action="bypass _bbspremium;3" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td align=center><button value="7 Day [Price 7kk]" action="bypass _bbspremium;7" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
<tr>
<td align=center><button value="15 Day [Price 15kk]" action="bypass _bbspremium;15" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td align=center><button value="20 Day [Price 20kk]" action="bypass _bbspremium;20" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td align=center><button value="30 Day [Price 30kk]" action="bypass _bbspremium;30" width=140 height=27 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
<tr>
<td height=15></td>
</tr>
</table>
<table align=center border="0">
<tr>
<td>
<center><img src="L2UI.SquareGray" width=500 height=1></center>
</td>
</tr>
<tr>
<td height=10></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<center><img src="L2UI_CH3.herotower_deco" width=256 height=32></center>
</td>
</tr>
<tr>
<td height=150 align="center">
<br>
<font name="hs12" color="CDB67F">Your premium status can be checked
<br1>
by typing following command in chat</font>
<br1>
<font name="hs12" color="00A5FF">.premium</font>
</td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555>
<tr>
<td height=10></td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=17></td>
</tr>
<tr>
<td align=center><font color=696969>LINEAGE II - COMMUNITY BOARD</font></td>
</tr>
<tr>
<td height=15></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>

View File

@ -0,0 +1,105 @@
<html noscrollbar>
<body>
<table width=700>
<tr>
<td height=10></td>
</tr>
</table>
<table width=20>
<tr>
<td>
%navigation%
</td>
<td>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=555 height=455 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=25></td>
</tr>
<tr>
<td height=25 align="center"><font name="hs12" color="CDB67F">Premium Manager</font></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=200 height=1></center>
</td>
</tr>
<tr>
<td height=20></td>
</tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1. Premium benefits CAN NOT BE TRANSFERED.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2. Premium does not effect party members.<br1></font></td></tr>
<tr><td align="left"> <font color="CDB67F">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3. Premium benefits effect ALL characters in same account.</font></td></tr>
<tr>
<td height=20></td>
</tr>
<tr><td height=15 align="center"></td></tr>
<tr><td height=15 align="center"></td></tr>
<tr>
<td height=10></td>
</tr>
<tr>
<td>
<center><img src="L2UI.SquareGray" width=500 height=1></center>
</td>
</tr>
<tr>
<td height=25></td>
</tr>
<tr>
<td align="center">
<table align=center border="0" height=85 >
<tr>
<td align=center width=500><font name="hs12" color="CDB67F">Thank you!</font></td>
</tr>
</table>
<table align=center border="0">
<tr>
<td>
<center><img src="L2UI.SquareGray" width=500 height=1></center>
</td>
</tr>
<tr>
<td height=10></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<center><img src="L2UI_CH3.herotower_deco" width=256 height=32></center>
</td>
</tr>
<tr>
<td height=150 align="center">
<br>
<font name="hs12" color="CDB67F">Your premium status can be checked
<br1>
by typing following command in chat</font>
<br1>
<font name="hs12" color="00A5FF">.premium</font>
</td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555>
<tr>
<td height=10></td>
</tr>
</table>
<table border=0 cellpadding=0 cellspacing=0 width=555 background="L2UI_CT1.Windows_DF_TooltipBG">
<tr>
<td height=17></td>
</tr>
<tr>
<td align=center><font color=696969>LINEAGE II - COMMUNITY BOARD</font></td>
</tr>
<tr>
<td height=15></td>
</tr>
</table>
</center>
</td>
</tr>
</table>
</body>
</html>

View File

@ -174,6 +174,7 @@ import handlers.chathandlers.ChatShout;
import handlers.chathandlers.ChatTrade; import handlers.chathandlers.ChatTrade;
import handlers.chathandlers.ChatWhisper; import handlers.chathandlers.ChatWhisper;
import handlers.communityboard.ClanBoard; import handlers.communityboard.ClanBoard;
import handlers.communityboard.DropSearchBoard;
import handlers.communityboard.FavoriteBoard; import handlers.communityboard.FavoriteBoard;
import handlers.communityboard.FriendsBoard; import handlers.communityboard.FriendsBoard;
import handlers.communityboard.HomeBoard; import handlers.communityboard.HomeBoard;
@ -459,6 +460,7 @@ public class MasterHandler
{ {
// Community Board // Community Board
ClanBoard.class, ClanBoard.class,
DropSearchBoard.class,
FavoriteBoard.class, FavoriteBoard.class,
FriendsBoard.class, FriendsBoard.class,
HomeBoard.class, HomeBoard.class,

View File

@ -17,6 +17,7 @@
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.HtmCache; import com.l2jmobius.gameserver.cache.HtmCache;
@ -118,15 +119,21 @@ public class AdminPremium implements IAdminCommandHandler
} }
// TODO: Add check if account exists XD // TODO: Add check if account exists XD
PremiumManager.getInstance().updatePremiumData(months, accountName); PremiumManager.getInstance().addPremiumTime(accountName, months * 30, TimeUnit.DAYS);
admin.sendMessage("Account " + accountName + " will now have premium status until " + String.valueOf(new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumEndDate(accountName))) + "."); admin.sendMessage("Account " + accountName + " will now have premium status until " + new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumExpiration(accountName)) + ".");
} }
private void viewPremiumInfo(L2PcInstance admin, String accountName) private void viewPremiumInfo(L2PcInstance admin, String accountName)
{ {
if (PremiumManager.getInstance().getPremiumEndDate(accountName) > 0) if (!Config.PREMIUM_SYSTEM_ENABLED)
{ {
admin.sendMessage("Account " + accountName + " has premium status until " + String.valueOf(new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumEndDate(accountName))) + "."); admin.sendMessage("Premium system is disabled.");
return;
}
if (PremiumManager.getInstance().getPremiumExpiration(accountName) > 0)
{
admin.sendMessage("Account " + accountName + " has premium status until " + new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumExpiration(accountName)) + ".");
} }
else else
{ {
@ -136,7 +143,13 @@ public class AdminPremium implements IAdminCommandHandler
private void removePremium(L2PcInstance admin, String accountName) private void removePremium(L2PcInstance admin, String accountName)
{ {
if (PremiumManager.getInstance().getPremiumEndDate(accountName) > 0) if (!Config.PREMIUM_SYSTEM_ENABLED)
{
admin.sendMessage("Premium system is disabled.");
return;
}
if (PremiumManager.getInstance().getPremiumExpiration(accountName) > 0)
{ {
PremiumManager.getInstance().removePremiumStatus(accountName); PremiumManager.getInstance().removePremiumStatus(accountName);
admin.sendMessage("Account " + accountName + " has no longer premium status."); admin.sendMessage("Account " + accountName + " has no longer premium status.");

View File

@ -0,0 +1,331 @@
/*
* This file is part of the L2J Mobius project.
*
* 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 handlers.communityboard;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringJoiner;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IParseBoardHandler;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.model.drops.DropListScope;
import com.l2jmobius.gameserver.model.drops.GeneralDropItem;
import com.l2jmobius.gameserver.model.drops.GroupedGeneralDropItem;
import com.l2jmobius.gameserver.model.drops.IDropItem;
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
import com.l2jmobius.gameserver.model.items.L2Item;
/**
* @author yksdtc
*/
public class DropSearchBoard implements IParseBoardHandler
{
private static final String NAVIGATION_PATH = "data/html/CommunityBoard/Custom/navigation.html";
private static final String[] COMMAND =
{
"_bbs_search_item",
"_bbs_search_drop",
"_bbs_npc_trace"
};
class DropHolder
{
int itemId;
int npcId;
byte npcLevel;
long basemin;
long basemax;
double baseGroupChance;
double basechance;
boolean isSweep;
public DropHolder(L2NpcTemplate npc, GeneralDropItem item, double groupChance, boolean isSweep)
{
itemId = item.getItemId();
npcId = npc.getId();
npcLevel = npc.getLevel();
basemin = item.getMin();
basemax = item.getMax();
baseGroupChance = groupChance;
basechance = item.getChance();
this.isSweep = isSweep;
}
/**
* only for debug'/;
*/
@Override
public String toString()
{
return "DropHolder [itemId=" + itemId + ", npcId=" + npcId + ", npcLevel=" + npcLevel + ", basemin=" + basemin + ", basemax=" + basemax + ", baseGroupChance=" + baseGroupChance + ", basechance=" + basechance + ", isSweep=" + isSweep + "]";
}
}
private final Map<Integer, List<DropHolder>> DROP_INDEX_CACHE = new HashMap<>();
// nonsupport items
private final Set<Integer> BLOCK_ID = new HashSet<>();
{
BLOCK_ID.add(Inventory.ADENA_ID);
}
public DropSearchBoard()
{
buildDropIndex();
}
private void buildDropIndex()
{
NpcData.getInstance().getTemplates(npc -> npc.getDropLists() != null).forEach(npcTemplate ->
{
for (Entry<DropListScope, List<IDropItem>> entry : npcTemplate.getDropLists().entrySet())
{
entry.getValue().forEach(idrop ->
{
if (idrop instanceof GroupedGeneralDropItem)
{
GroupedGeneralDropItem ggd = (GroupedGeneralDropItem) idrop;
ggd.getItems().stream().forEach(gd -> addToDropList(npcTemplate, gd, ggd.getChance(), entry.getKey() == DropListScope.CORPSE));
}
else
{
GeneralDropItem gd = (GeneralDropItem) idrop;
addToDropList(npcTemplate, gd, 100.0, entry.getKey() == DropListScope.CORPSE);
}
});
}
});
DROP_INDEX_CACHE.values().stream().forEach(l -> l.sort((d1, d2) -> Byte.valueOf(d1.npcLevel).compareTo(Byte.valueOf(d2.npcLevel))));
}
private void addToDropList(L2NpcTemplate npcTemplate, GeneralDropItem gd, double groupChance, boolean isSweep)
{
if (BLOCK_ID.contains(gd.getItemId()))
{
return;
}
List<DropHolder> dropList = DROP_INDEX_CACHE.get(gd.getItemId());
if (dropList == null)
{
dropList = new ArrayList<>();
DROP_INDEX_CACHE.put(gd.getItemId(), dropList);
}
dropList.add(new DropHolder(npcTemplate, gd, groupChance, isSweep));
}
@Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance player)
{
final String navigation = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), NAVIGATION_PATH);
String[] params = command.split(" ");
String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/CommunityBoard/Custom/dropsearch/main.html");
switch (params[0])
{
case "_bbs_search_item":
{
String itemName = buildItemName(params);
String result = buildItemSearchResult(itemName);
html = html.replace("%searchResult%", result);
break;
}
case "_bbs_search_drop":
{
final DecimalFormat chanceFormat = new DecimalFormat("0.00##");
int itemId = Integer.parseInt(params[1]);
int page = Integer.parseInt(params[2]);
List<DropHolder> list = DROP_INDEX_CACHE.get(itemId);
int pages = list.size() / 14;
if (pages == 0)
{
pages++;
}
int start = (page - 1) * 14;
int end = Math.min(list.size() - 1, start + 14);
StringBuilder builder = new StringBuilder();
for (int index = start; index <= end; index++)
{
DropHolder dropHolder = list.get(index);
builder.append("<tr>");
builder.append("<td width=30>").append(dropHolder.npcLevel).append("</td>");
builder.append("<td width=170>").append("<a action=\"bypass _bbs_npc_trace " + dropHolder.npcId + "\">").append("&@").append(dropHolder.npcId).append(";").append("</a>").append("</td>");
builder.append("<td width=80 align=CENTER>").append(dropHolder.basemin).append("-").append(dropHolder.basemax).append("</td>");
builder.append("<td width=50 align=CENTER>").append(chanceFormat.format((dropHolder.basechance * dropHolder.baseGroupChance) / 100)).append("%").append("</td>");
builder.append("<td width=50 align=CENTER>").append(dropHolder.isSweep ? "Sweep" : "Drop").append("</td>");
builder.append("</tr>");
}
html = html.replace("%searchResult%", builder.toString());
builder.setLength(0);
builder.append("<tr>");
for (page = 1; page <= pages; page++)
{
builder.append("<td>").append("<a action=\"bypass -h _bbs_search_drop " + itemId + " " + page + " $order $level\">").append(page).append("</a>").append("</td>");
}
builder.append("</tr>");
html = html.replace("%pages%", builder.toString());
break;
}
case "_bbs_npc_trace":
{
int npcId = Integer.parseInt(params[1]);
L2Spawn spawn = SpawnTable.getInstance().findAny(npcId);
if (spawn == null)
{
player.sendMessage("cant find any spawn maybe boss or instance mob");
}
else
{
player.getRadar().addMarker(spawn.getX(), spawn.getY(), spawn.getZ());
}
break;
}
}
if (html != null)
{
html = html.replace("%navigation%", navigation);
CommunityBoardHandler.separateAndSend(html, player);
}
return false;
}
/**
* @param itemName
* @return
*/
private String buildItemSearchResult(String itemName)
{
int limit = 0;
Set<Integer> existInDropData = DROP_INDEX_CACHE.keySet();
List<L2Item> items = new ArrayList<>();
for (L2Item item : ItemTable.getInstance().getAllItems())
{
if (item == null)
{
continue;
}
if (!existInDropData.contains(item.getId()))
{
continue;
}
if (item.getName().toLowerCase().contains(itemName.toLowerCase()))
{
items.add(item);
limit++;
}
if (limit == 14)
{
break;
}
}
if (items.isEmpty())
{
return "<tr><td width=100 align=CENTER>No Match</td></tr>";
}
int line = 0;
StringBuilder builder = new StringBuilder(items.size() * 28);
int i = 0;
for (L2Item item : items)
{
i++;
if (i == 1)
{
line++;
builder.append("<tr>");
}
String icon = item.getIcon();
if (icon == null)
{
icon = "icon.etc_question_mark_i00";
}
builder.append("<td>");
builder.append("<button value=\".\" action=\"bypass _bbs_search_drop " + item.getId() + " 1 $order $level\" width=32 height=32 back=\"" + icon + "\" fore=\"" + icon + "\">");
builder.append("</td>");
builder.append("<td width=200>");
builder.append("&#").append(item.getId()).append(";");
builder.append("</td>");
if (i == 2)
{
builder.append("</tr>");
i = 0;
}
}
if ((i % 2) == 1)
{
builder.append("</tr>");
}
if (line < 7)
{
for (i = 0; i < (7 - line); i++)
{
builder.append("<tr><td height=36></td></tr>");
}
}
return builder.toString();
}
/**
* @param params
* @return
*/
private String buildItemName(String[] params)
{
StringJoiner joiner = new StringJoiner(" ");
for (int i = 1; i < params.length; i++)
{
joiner.add(params[i]);
}
return joiner.toString();
}
@Override
public String[] getCommunityBoardCommands()
{
return COMMAND;
}
}

View File

@ -19,6 +19,14 @@ package handlers.communityboard;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory; import com.l2jmobius.commons.database.DatabaseFactory;
@ -29,10 +37,15 @@ import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
import com.l2jmobius.gameserver.datatables.SkillData; import com.l2jmobius.gameserver.datatables.SkillData;
import com.l2jmobius.gameserver.handler.CommunityBoardHandler; import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IParseBoardHandler; import com.l2jmobius.gameserver.handler.IParseBoardHandler;
import com.l2jmobius.gameserver.instancemanager.PremiumManager;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.model.zone.ZoneId; import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.serverpackets.BuyList; import com.l2jmobius.gameserver.network.serverpackets.BuyList;
import com.l2jmobius.gameserver.network.serverpackets.ExBuySellList; import com.l2jmobius.gameserver.network.serverpackets.ExBuySellList;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.ShowBoard; import com.l2jmobius.gameserver.network.serverpackets.ShowBoard;
/** /**
@ -43,50 +56,80 @@ public final class HomeBoard implements IParseBoardHandler
{ {
// SQL Queries // SQL Queries
private static final String COUNT_FAVORITES = "SELECT COUNT(*) AS favorites FROM `bbs_favorites` WHERE `playerId`=?"; private static final String COUNT_FAVORITES = "SELECT COUNT(*) AS favorites FROM `bbs_favorites` WHERE `playerId`=?";
private static final String NAVIGATION_PATH = "data/html/CommunityBoard/Custom/navigation.html";
private static final String[] COMMANDS = private static final String[] COMMANDS =
{ {
"_bbshome", "_bbshome",
"_bbstop", "_bbstop",
"_bbsmultisell",
"_bbssell",
"_bbsteleport",
"_bbsbuff"
}; };
private static final String[] CUSTOM_COMMANDS =
{
Config.PREMIUM_SYSTEM_ENABLED && Config.COMMUNITY_PREMIUM_SYSTEM_ENABLED ? "_bbspremium" : null,
Config.COMMUNITYBOARD_ENABLE_MULTISELLS ? "_bbsmultisell" : null,
Config.COMMUNITYBOARD_ENABLE_MULTISELLS ? "_bbssell" : null,
Config.COMMUNITYBOARD_ENABLE_TELEPORTS ? "_bbsteleport" : null,
Config.COMMUNITYBOARD_ENABLE_BUFFS ? "_bbsbuff" : null,
Config.COMMUNITYBOARD_ENABLE_HEAL ? "_bbsheal" : null
};
public static final BiPredicate<String, L2PcInstance> COMBAT_CHECK = (command, activeChar) ->
{
boolean commandCheck = false;
for (String c : CUSTOM_COMMANDS)
{
if ((c != null) && command.startsWith(c))
{
commandCheck = true;
break;
}
}
return commandCheck && (activeChar.isInCombat() || activeChar.isInDuel() || activeChar.isInOlympiadMode() || activeChar.isInsideZone(ZoneId.SIEGE) || activeChar.isInsideZone(ZoneId.PVP));
};
public static final Predicate<L2PcInstance> KARMA_CHECK = player -> Config.COMMUNITYBOARD_KARMA_DISABLED && (player.getKarma() > 0);
@Override @Override
public String[] getCommunityBoardCommands() public String[] getCommunityBoardCommands()
{ {
return COMMANDS; List<String> commands = new ArrayList<>();
commands.addAll(Arrays.asList(COMMANDS));
commands.addAll(Arrays.asList(CUSTOM_COMMANDS));
return commands.stream().filter(Objects::nonNull).toArray(String[]::new);
} }
@Override @Override
public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar) public boolean parseCommunityBoardCommand(String command, L2PcInstance activeChar)
{ {
if (Config.CUSTOM_CB_ENABLED) // Old custom conditions check move to here
{ if (COMBAT_CHECK.test(command, activeChar))
if (Config.COMMUNITYBOARD_COMBAT_DISABLED && (activeChar.isInCombat() || activeChar.isInDuel() || activeChar.isInOlympiadMode() || activeChar.isInsideZone(ZoneId.SIEGE) || activeChar.isInsideZone(ZoneId.PVP)))
{ {
activeChar.sendMessage("You can't use the Community Board right now."); activeChar.sendMessage("You can't use the Community Board right now.");
return false; return false;
} }
if (Config.COMMUNITYBOARD_KARMA_DISABLED && (activeChar.getKarma() > 0))
if (KARMA_CHECK.test(activeChar))
{ {
activeChar.sendMessage("Players with Karma cannot use the Community Board."); activeChar.sendMessage("Players with Karma cannot use the Community Board.");
return false; return false;
} }
}
String returnHtml = null;
final String navigation = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), NAVIGATION_PATH);
if (command.equals("_bbshome") || command.equals("_bbstop")) if (command.equals("_bbshome") || command.equals("_bbstop"))
{ {
final String customPath = Config.CUSTOM_CB_ENABLED ? "Custom/" : ""; final String customPath = Config.CUSTOM_CB_ENABLED ? "Custom/" : "";
CommunityBoardHandler.getInstance().addBypass(activeChar, "Home", command); CommunityBoardHandler.getInstance().addBypass(activeChar, "Home", command);
String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + customPath + "home.html"); returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + customPath + "home.html");
html = html.replaceAll("%fav_count%", Integer.toString(getFavoriteCount(activeChar))); if (!Config.CUSTOM_CB_ENABLED)
html = html.replaceAll("%region_count%", Integer.toString(getRegionCount(activeChar))); {
html = html.replaceAll("%clan_count%", Integer.toString(ClanTable.getInstance().getClanCount())); returnHtml = returnHtml.replaceAll("%fav_count%", Integer.toString(getFavoriteCount(activeChar)));
CommunityBoardHandler.separateAndSend(html, activeChar); returnHtml = returnHtml.replaceAll("%region_count%", Integer.toString(getRegionCount(activeChar)));
returnHtml = returnHtml.replaceAll("%clan_count%", Integer.toString(ClanTable.getInstance().getClanCount()));
}
} }
else if (command.startsWith("_bbstop;")) else if (command.startsWith("_bbstop;"))
{ {
@ -94,31 +137,26 @@ public final class HomeBoard implements IParseBoardHandler
final String path = command.replace("_bbstop;", ""); final String path = command.replace("_bbstop;", "");
if ((path.length() > 0) && path.endsWith(".html")) if ((path.length() > 0) && path.endsWith(".html"))
{ {
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + customPath + path); returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/" + customPath + path);
CommunityBoardHandler.separateAndSend(html, activeChar);
} }
} }
else if (Config.CUSTOM_CB_ENABLED && Config.COMMUNITYBOARD_ENABLE_MULTISELLS && command.startsWith("_bbsmultisell")) else if (command.startsWith("_bbsmultisell"))
{ {
final String fullBypass = command.replace("_bbsmultisell;", ""); final String fullBypass = command.replace("_bbsmultisell;", "");
final String[] buypassOptions = fullBypass.split(","); final String[] buypassOptions = fullBypass.split(",");
final int multisellId = Integer.parseInt(buypassOptions[0]); final int multisellId = Integer.parseInt(buypassOptions[0]);
final String page = buypassOptions[1]; final String page = buypassOptions[1];
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html"); returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html");
CommunityBoardHandler.separateAndSend(html, activeChar);
MultisellData.getInstance().separateAndSend(multisellId, activeChar, null, false); MultisellData.getInstance().separateAndSend(multisellId, activeChar, null, false);
return true;
} }
else if (Config.CUSTOM_CB_ENABLED && Config.COMMUNITYBOARD_ENABLE_MULTISELLS && command.startsWith("_bbssell")) else if (command.startsWith("_bbssell"))
{ {
final String page = command.replace("_bbssell;", ""); final String page = command.replace("_bbssell;", "");
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html"); returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html");
CommunityBoardHandler.separateAndSend(html, activeChar);
activeChar.sendPacket(new BuyList(BuyListData.getInstance().getBuyList(423), activeChar.getAdena(), 0)); activeChar.sendPacket(new BuyList(BuyListData.getInstance().getBuyList(423), activeChar.getAdena(), 0));
activeChar.sendPacket(new ExBuySellList(activeChar, false)); activeChar.sendPacket(new ExBuySellList(activeChar, false));
return true;
} }
else if (Config.CUSTOM_CB_ENABLED && Config.COMMUNITYBOARD_ENABLE_TELEPORTS && command.startsWith("_bbsteleport")) else if (command.startsWith("_bbsteleport"))
{ {
final String fullBypass = command.replace("_bbsteleport;", ""); final String fullBypass = command.replace("_bbsteleport;", "");
final String[] buypassOptions = fullBypass.split(","); final String[] buypassOptions = fullBypass.split(",");
@ -128,30 +166,103 @@ public final class HomeBoard implements IParseBoardHandler
if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITYBOARD_CURRENCY, -1) < Config.COMMUNITYBOARD_TELEPORT_PRICE) if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITYBOARD_CURRENCY, -1) < Config.COMMUNITYBOARD_TELEPORT_PRICE)
{ {
activeChar.sendMessage("Not enough currency!"); activeChar.sendMessage("Not enough currency!");
return false;
} }
else
{
activeChar.sendPacket(new ShowBoard()); activeChar.sendPacket(new ShowBoard());
activeChar.getInventory().destroyItemByItemId("CB_Teleport", Config.COMMUNITYBOARD_CURRENCY, Config.COMMUNITYBOARD_TELEPORT_PRICE, activeChar, activeChar); activeChar.destroyItemByItemId("CB_Teleport", Config.COMMUNITYBOARD_CURRENCY, Config.COMMUNITYBOARD_TELEPORT_PRICE, activeChar, true);
activeChar.teleToLocation(x, y, z, 0); activeChar.teleToLocation(x, y, z, 0);
} }
else if (Config.CUSTOM_CB_ENABLED && Config.COMMUNITYBOARD_ENABLE_BUFFS && command.startsWith("_bbsbuff")) }
else if (command.startsWith("_bbsbuff"))
{ {
final String fullBypass = command.replace("_bbsbuff;", ""); final String fullBypass = command.replace("_bbsbuff;", "");
final String[] buypassOptions = fullBypass.split(","); final String[] buypassOptions = fullBypass.split(";");
final int buffId = Integer.parseInt(buypassOptions[0]); final int buffCount = buypassOptions.length - 1;
final int buffLevel = Integer.parseInt(buypassOptions[1]); final String page = buypassOptions[buffCount];
final String page = buypassOptions[2]; if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITYBOARD_CURRENCY, -1) < (Config.COMMUNITYBOARD_BUFF_PRICE * buffCount))
if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITYBOARD_CURRENCY, -1) < Config.COMMUNITYBOARD_BUFF_PRICE)
{ {
activeChar.sendMessage("Not enough currency!"); activeChar.sendMessage("Not enough currency!");
} }
else else
{ {
activeChar.getInventory().destroyItemByItemId("CB_Buff", Config.COMMUNITYBOARD_CURRENCY, Config.COMMUNITYBOARD_BUFF_PRICE, activeChar, activeChar); activeChar.destroyItemByItemId("CB_Buff", Config.COMMUNITYBOARD_CURRENCY, Config.COMMUNITYBOARD_BUFF_PRICE * buffCount, activeChar, true);
SkillData.getInstance().getSkill(buffId, buffLevel).applyEffects(activeChar, activeChar); final L2Summon pet = activeChar.getSummon();
List<L2Character> targets = new ArrayList<>(4);
targets.add(activeChar);
if (pet != null)
{
targets.add(pet);
} }
final String html = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html");
CommunityBoardHandler.separateAndSend(html, activeChar); for (int i = 0; i < buffCount; i++)
{
final Skill skill = SkillData.getInstance().getSkill(Integer.parseInt(buypassOptions[i].split(",")[0]), Integer.parseInt(buypassOptions[i].split(",")[1]));
targets.stream().filter(target -> !target.isSummon()).forEach(target ->
{
skill.applyEffects(activeChar, target);
if (Config.COMMUNITYBOARD_CAST_ANIMATIONS)
{
activeChar.sendPacket(new MagicSkillUse(activeChar, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
// not recommend broadcast
// activeChar.broadcastPacket(new MagicSkillUse(activeChar, target, skill.getId(), skill.getLevel(), skill.getHitTime(), skill.getReuseDelay()));
}
});
}
}
returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html");
}
else if (command.startsWith("_bbsheal"))
{
final String page = command.replace("_bbsheal;", "");
if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITYBOARD_CURRENCY, -1) < (Config.COMMUNITYBOARD_HEAL_PRICE))
{
activeChar.sendMessage("Not enough currency!");
}
else
{
activeChar.destroyItemByItemId("CB_Heal", Config.COMMUNITYBOARD_CURRENCY, Config.COMMUNITYBOARD_HEAL_PRICE, activeChar, true);
activeChar.setCurrentHp(activeChar.getMaxHp());
activeChar.setCurrentMp(activeChar.getMaxMp());
activeChar.setCurrentCp(activeChar.getMaxCp());
if (activeChar.hasSummon())
{
activeChar.getSummon().setCurrentHp(activeChar.getSummon().getMaxHp());
activeChar.getSummon().setCurrentMp(activeChar.getSummon().getMaxMp());
activeChar.getSummon().setCurrentCp(activeChar.getSummon().getMaxCp());
}
activeChar.sendMessage("You used heal!");
}
returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/" + page + ".html");
}
else if (command.startsWith("_bbspremium"))
{
final String fullBypass = command.replace("_bbspremium;", "");
final String[] buypassOptions = fullBypass.split(",");
final int premiumDays = Integer.parseInt(buypassOptions[0]);
if (activeChar.getInventory().getInventoryItemCount(Config.COMMUNITY_PREMIUM_COIN_ID, -1) < (Config.COMMUNITY_PREMIUM_PRICE_PER_DAY * premiumDays))
{
activeChar.sendMessage("Not enough currency!");
}
else
{
activeChar.destroyItemByItemId("CB_Premium", Config.COMMUNITY_PREMIUM_COIN_ID, Config.COMMUNITY_PREMIUM_PRICE_PER_DAY * premiumDays, activeChar, true);
PremiumManager.getInstance().addPremiumTime(activeChar.getAccountName(), premiumDays, TimeUnit.DAYS);
activeChar.sendMessage("Your account will now have premium status until " + new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumExpiration(activeChar.getAccountName())) + ".");
returnHtml = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/CommunityBoard/Custom/premium/thankyou.html");
}
}
if (returnHtml != null)
{
if (Config.CUSTOM_CB_ENABLED)
{
returnHtml = returnHtml.replace("%navigation%", navigation);
}
CommunityBoardHandler.separateAndSend(returnHtml, activeChar);
} }
return false; return false;
} }

View File

@ -37,7 +37,7 @@ public class Premium implements IVoicedCommandHandler
if (command.startsWith("premium") && Config.PREMIUM_SYSTEM_ENABLED) if (command.startsWith("premium") && Config.PREMIUM_SYSTEM_ENABLED)
{ {
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm"); final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
final long endDate = PremiumManager.getInstance().getPremiumEndDate(activeChar.getAccountName()); final long endDate = PremiumManager.getInstance().getPremiumExpiration(activeChar.getAccountName());
final NpcHtmlMessage msg = new NpcHtmlMessage(5); final NpcHtmlMessage msg = new NpcHtmlMessage(5);
final StringBuilder html = new StringBuilder(); final StringBuilder html = new StringBuilder();
if (endDate == 0) if (endDate == 0)

View File

@ -801,10 +801,16 @@ public final class Config
public static boolean COMMUNITYBOARD_ENABLE_MULTISELLS; public static boolean COMMUNITYBOARD_ENABLE_MULTISELLS;
public static boolean COMMUNITYBOARD_ENABLE_TELEPORTS; public static boolean COMMUNITYBOARD_ENABLE_TELEPORTS;
public static boolean COMMUNITYBOARD_ENABLE_BUFFS; public static boolean COMMUNITYBOARD_ENABLE_BUFFS;
public static boolean COMMUNITYBOARD_ENABLE_HEAL;
public static int COMMUNITYBOARD_TELEPORT_PRICE; public static int COMMUNITYBOARD_TELEPORT_PRICE;
public static int COMMUNITYBOARD_BUFF_PRICE; public static int COMMUNITYBOARD_BUFF_PRICE;
public static int COMMUNITYBOARD_HEAL_PRICE;
public static boolean COMMUNITYBOARD_COMBAT_DISABLED; public static boolean COMMUNITYBOARD_COMBAT_DISABLED;
public static boolean COMMUNITYBOARD_KARMA_DISABLED; public static boolean COMMUNITYBOARD_KARMA_DISABLED;
public static boolean COMMUNITYBOARD_CAST_ANIMATIONS;
public static boolean COMMUNITY_PREMIUM_SYSTEM_ENABLED;
public static int COMMUNITY_PREMIUM_COIN_ID;
public static int COMMUNITY_PREMIUM_PRICE_PER_DAY;
public static boolean PREMIUM_SYSTEM_ENABLED; public static boolean PREMIUM_SYSTEM_ENABLED;
public static float PREMIUM_RATE_XP; public static float PREMIUM_RATE_XP;
public static float PREMIUM_RATE_SP; public static float PREMIUM_RATE_SP;
@ -2595,10 +2601,16 @@ public final class Config
COMMUNITYBOARD_ENABLE_MULTISELLS = CustomSettings.getBoolean("CommunityEnableMultisells", true); COMMUNITYBOARD_ENABLE_MULTISELLS = CustomSettings.getBoolean("CommunityEnableMultisells", true);
COMMUNITYBOARD_ENABLE_TELEPORTS = CustomSettings.getBoolean("CommunityEnableTeleports", true); COMMUNITYBOARD_ENABLE_TELEPORTS = CustomSettings.getBoolean("CommunityEnableTeleports", true);
COMMUNITYBOARD_ENABLE_BUFFS = CustomSettings.getBoolean("CommunityEnableBuffs", true); COMMUNITYBOARD_ENABLE_BUFFS = CustomSettings.getBoolean("CommunityEnableBuffs", true);
COMMUNITYBOARD_ENABLE_HEAL = CustomSettings.getBoolean("CommunityEnableHeal", true);
COMMUNITYBOARD_TELEPORT_PRICE = CustomSettings.getInt("CommunityTeleportPrice", 0); COMMUNITYBOARD_TELEPORT_PRICE = CustomSettings.getInt("CommunityTeleportPrice", 0);
COMMUNITYBOARD_BUFF_PRICE = CustomSettings.getInt("CommunityBuffPrice", 0); COMMUNITYBOARD_BUFF_PRICE = CustomSettings.getInt("CommunityBuffPrice", 0);
COMMUNITYBOARD_HEAL_PRICE = CustomSettings.getInt("CommunityHealPrice", 0);
COMMUNITYBOARD_COMBAT_DISABLED = CustomSettings.getBoolean("CommunityCombatDisabled", true); COMMUNITYBOARD_COMBAT_DISABLED = CustomSettings.getBoolean("CommunityCombatDisabled", true);
COMMUNITYBOARD_KARMA_DISABLED = CustomSettings.getBoolean("CommunityKarmaDisabled", true); COMMUNITYBOARD_KARMA_DISABLED = CustomSettings.getBoolean("CommunityKarmaDisabled", true);
COMMUNITYBOARD_CAST_ANIMATIONS = CustomSettings.getBoolean("CommunityCastAnimations", false);
COMMUNITY_PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("CommunityPremiumSystem", false);
COMMUNITY_PREMIUM_COIN_ID = CustomSettings.getInt("CommunityPremiumBuyCoinId", 57);
COMMUNITY_PREMIUM_PRICE_PER_DAY = CustomSettings.getInt("CommunityPremiumPricePerDay", 1000000);
PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false); PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false);
PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2); PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2);
@ -2959,12 +2971,15 @@ public final class Config
final Properties hexSetting = new Properties(); final Properties hexSetting = new Properties();
final File file = new File(fileName); final File file = new File(fileName);
// Create a new empty file only if it doesn't exist // Create a new empty file only if it doesn't exist
file.createNewFile(); if (!file.exists())
{
try (OutputStream out = new FileOutputStream(file)) try (OutputStream out = new FileOutputStream(file))
{ {
hexSetting.setProperty("ServerID", String.valueOf(serverId)); hexSetting.setProperty("ServerID", String.valueOf(serverId));
hexSetting.setProperty("HexID", hexId); hexSetting.setProperty("HexID", hexId);
hexSetting.store(out, "The HexId to Auth into LoginServer"); hexSetting.store(out, "The HexId to Auth into LoginServer");
_log.log(Level.INFO, "Gameserver: Generated new HexID file for server id " + serverId + ".");
}
} }
} }
catch (Exception e) catch (Exception e)

View File

@ -408,6 +408,11 @@ public class ItemTable
return _weapons.keySet(); return _weapons.keySet();
} }
public L2Item[] getAllItems()
{
return _allTemplates;
}
public int getArraySize() public int getArraySize()
{ {
return _allTemplates.length; return _allTemplates.length;

View File

@ -20,107 +20,203 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Calendar; import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory; import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.ThreadPoolManager;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.Containers;
import com.l2jmobius.gameserver.model.events.EventType;
import com.l2jmobius.gameserver.model.events.ListenersContainer;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogin;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerLogout;
import com.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener;
/** /**
* @author Mobius * @author Mobius
*/ */
public class PremiumManager public class PremiumManager
{ {
private long endDate = 0; private final static Logger LOGGER = Logger.getLogger(PremiumManager.class.getName());
public long getPremiumEndDate(String accountName) // SQL Statement
private final static String LOAD_SQL = "SELECT account_name,enddate FROM account_premium";
private final static String UPDATE_SQL = "UPDATE account_premium SET enddate = ? WHERE account_name = ?";
private final static String ADD_SQL = "INSERT INTO account_premium (enddate,account_name) VALUE (?,?)";
class PremiumExpireTask implements Runnable
{ {
try (Connection con = DatabaseFactory.getInstance().getConnection()) final L2PcInstance player;
PremiumExpireTask(L2PcInstance player)
{
this.player = player;
}
@Override
public void run()
{
player.setPremiumStatus(false);
// player.sendPacket(new ExBrPremiumState(player));
}
}
// Data Cache
private final Map<String, Long> premiumData = new HashMap<>();
// expireTasks
private final Map<String, ScheduledFuture<?>> expiretasks = new HashMap<>();
// Listeners
private final ListenersContainer listenerContainer = Containers.Players();
private final Consumer<OnPlayerLogin> playerLoginEvent = (event) ->
{
final L2PcInstance player = event.getActiveChar();
final String accountName = player.getAccountName();
final long now = System.currentTimeMillis();
final long premiumExpiration = getPremiumExpiration(accountName);
player.setPremiumStatus(premiumExpiration > now);
// player.sendPacket(new ExBrPremiumState(player));
if (player.hasPremiumStatus())
{
startExpireTask(player, premiumExpiration - now);
}
};
private final Consumer<OnPlayerLogout> playerLogoutEvent = (event) ->
{
L2PcInstance player = event.getActiveChar();
stopExpireTask(player);
};
protected PremiumManager()
{
loadPremiumData();
listenerContainer.addListener(new ConsumerEventListener(listenerContainer, EventType.ON_PLAYER_LOGIN, playerLoginEvent, this));
listenerContainer.addListener(new ConsumerEventListener(listenerContainer, EventType.ON_PLAYER_LOGOUT, playerLogoutEvent, this));
}
/**
* @param player
* @param delay
*/
private void startExpireTask(L2PcInstance player, long delay)
{
ScheduledFuture<?> task = ThreadPoolManager.getInstance().scheduleEvent(new PremiumExpireTask(player), delay);
expiretasks.put(player.getAccountName(), task);
}
/**
* @param player
*/
private void stopExpireTask(L2PcInstance player)
{
ScheduledFuture<?> task = expiretasks.remove(player.getAccountName());
if (task != null)
{
task.cancel(false);
task = null;
}
}
private void loadPremiumData()
{
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement(LOAD_SQL);
ResultSet rset = statement.executeQuery())
{ {
final PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?");
statement.setString(1, accountName);
final ResultSet rset = statement.executeQuery();
while (rset.next()) while (rset.next())
{ {
if (Config.PREMIUM_SYSTEM_ENABLED) premiumData.put(rset.getString(1), rset.getLong(2));
{
endDate = rset.getLong("enddate");
if (endDate <= System.currentTimeMillis())
{
endDate = 0;
removePremiumStatus(accountName);
} }
} }
}
statement.close();
}
catch (Exception e)
{
}
return endDate;
}
public void updatePremiumData(int months, String accountName)
{
long remainingTime = getPremiumEndDate(accountName);
if (remainingTime > 0)
{
remainingTime -= System.currentTimeMillis();
}
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
final Calendar endDate = Calendar.getInstance();
endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime);
endDate.set(Calendar.SECOND, 0);
endDate.add(Calendar.MONTH, months);
final PreparedStatement statement = con.prepareStatement("UPDATE account_premium SET premium_service=?,enddate=? WHERE account_name=?");
statement.setInt(1, 1);
statement.setLong(2, endDate.getTimeInMillis());
statement.setString(3, accountName);
statement.execute();
statement.close();
}
catch (SQLException e) catch (SQLException e)
{ {
e.printStackTrace();
} }
for (L2PcInstance player : L2World.getInstance().getPlayers()) long expiredData = premiumData.values().stream().filter(d -> d < System.currentTimeMillis()).count();
LOGGER.info(getClass().getSimpleName() + ": Loaded " + premiumData.size() + " premium data (" + expiredData + " have expired)");
}
public long getPremiumExpiration(String accountName)
{ {
if (player.getAccountNamePlayer().equalsIgnoreCase(accountName)) return premiumData.getOrDefault(accountName, 0L);
}
public void addPremiumTime(String accountName, int timeValue, TimeUnit timeUnit)
{ {
player.setPremiumStatus(getPremiumEndDate(accountName) > 0); long addTime = timeUnit.toMillis(timeValue);
long now = System.currentTimeMillis();
// new premium task at least from now
long oldPremiumExpiration = Math.max(now, getPremiumExpiration(accountName));
long newPremiumExpiration = oldPremiumExpiration + addTime;
String sqlCmd = premiumData.containsKey(accountName) ? UPDATE_SQL : ADD_SQL;
// UPDATE DATABASE
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement(sqlCmd))
{
stmt.setLong(1, newPremiumExpiration);
stmt.setString(2, accountName);
stmt.execute();
}
catch (SQLException e)
{
e.printStackTrace();
}
// UPDATE CACHE
premiumData.put(accountName, newPremiumExpiration);
// UPDATE PlAYER PREMIUMSTATUS
L2PcInstance playerOnline = L2World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
if (playerOnline != null)
{
stopExpireTask(playerOnline);
startExpireTask(playerOnline, newPremiumExpiration - now);
if (!playerOnline.hasPremiumStatus())
{
playerOnline.setPremiumStatus(true);
// playerOnline.sendPacket(new ExBrPremiumState(playerOnline));
} }
} }
} }
public void removePremiumStatus(String accountName) public void removePremiumStatus(String accountName)
{ {
// TODO: Add check if account exists. XD L2PcInstance playerOnline = L2World.getInstance().getPlayers().stream().filter(p -> accountName.equals(p.getAccountName())).findFirst().orElse(null);
try (Connection con = DatabaseFactory.getInstance().getConnection()) if ((playerOnline != null) && playerOnline.hasPremiumStatus())
{ {
final PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?"); playerOnline.setPremiumStatus(false);
statement.setString(1, accountName); // playerOnline.sendPacket(new ExBrPremiumState(playerOnline));
statement.setInt(2, 0); stopExpireTask(playerOnline);
statement.setLong(3, 0); }
statement.setInt(4, 0);
statement.setLong(5, 0); // UPDATE CACHE
statement.execute(); premiumData.remove(accountName);
statement.close();
// UPDATE DATABASE
try (Connection con = DatabaseFactory.getInstance().getConnection();
PreparedStatement stmt = con.prepareStatement(UPDATE_SQL))
{
stmt.setLong(1, 0L);
stmt.setString(2, accountName);
stmt.execute();
} }
catch (SQLException e) catch (SQLException e)
{ {
} e.printStackTrace();
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if (player.getAccountNamePlayer().equalsIgnoreCase(accountName))
{
player.setPremiumStatus(false);
}
} }
} }