Premium system.

This commit is contained in:
mobius 2015-01-13 20:26:37 +00:00
parent 7ac7b394be
commit c13fe97ac2
16 changed files with 563 additions and 12 deletions

View File

@ -656,3 +656,33 @@ GoodNameColor = 00FF00
# Evil name color. # Evil name color.
# Default: 0000FF # Default: 0000FF
EvilNameColor = 0000FF EvilNameColor = 0000FF
# ---------------------------------------------------------------------------
# Premium System (VIP)
# ---------------------------------------------------------------------------
# -Admins can manage subscriptions from main admin menu.
# -Players can use .premium to view account related info.
# -Caution: Premium rates multiply existing server rates.
# Enable premium system.
# Default: False
EnablePremiumSystem = False
# Xp rate for premium players.
PremiumRateXp = 2
# Sp rate for premium players.
PremiumRateSp = 2
# Drop chance for premium players.
PremiumRateDropChance = 2
# Drop ammount for premium players.
PremiumRateDropAmmount = 1
# Spoil chance for premium players.
PremiumRateSpoilChance = 2
# Spoil ammount for premium players.
PremiumRateSpoilAmmount = 1

View File

@ -419,6 +419,14 @@
<admin command="admin_untransform" accessLevel="100" /> <admin command="admin_untransform" accessLevel="100" />
<admin command="admin_transform_menu" accessLevel="100" /> <admin command="admin_transform_menu" accessLevel="100" />
<!-- PREMIUM SYSTEM -->
<admin command="admin_premium_menu" accessLevel="100" />
<admin command="admin_premium_add1" accessLevel="100" confirmDlg="true" />
<admin command="admin_premium_add2" accessLevel="100" confirmDlg="true" />
<admin command="admin_premium_add3" accessLevel="100" confirmDlg="true" />
<admin command="admin_premium_info" accessLevel="100" />
<admin command="admin_premium_remove" accessLevel="100" confirmDlg="true" />
<!-- ADMIN QUEST --> <!-- ADMIN QUEST -->
<admin command="admin_quest_reload" accessLevel="100" /> <admin command="admin_quest_reload" accessLevel="100" />
<admin command="admin_script_load" accessLevel="100" /> <admin command="admin_script_load" accessLevel="100" />

View File

@ -28,6 +28,7 @@
<td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="goSpawn" action="bypass -h admin_list_spawns $qbox 1" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr><tr> </tr><tr>
<td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td> <td><button value="Scan" action="bypass -h admin_scan $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
<td><button value="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr> </tr>
</table> </table>
<br> <br>

View File

@ -0,0 +1,15 @@
<html><title>Premium Service Menu</title><body>
<center>
<br>
<font color="LEVEL">Premium Service Menu</font><br>
<br>
Enter Account Name:<br>
<edit var="acc_name" width=200>
<br><button value="Add 1 month Premium" action="bypass -h admin_premium_add1 $acc_name" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
<button value="Add 2 months Premium" action="bypass -h admin_premium_add2 $acc_name" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
<button value="Add 3 months Premium" action="bypass -h admin_premium_add3 $acc_name" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
<br>
<button value="View Premium Info" action="bypass -h admin_premium_info $acc_name" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
<button value="Remove Premium" action="bypass -h admin_premium_remove $acc_name" width=200 height=25 back="L2UI_ct1.button_df" fore="L2UI_ct1.button_df">
</center>
</body></html>

View File

@ -85,6 +85,7 @@ import handlers.admincommandhandlers.AdminPcCondOverride;
import handlers.admincommandhandlers.AdminPetition; import handlers.admincommandhandlers.AdminPetition;
import handlers.admincommandhandlers.AdminPledge; import handlers.admincommandhandlers.AdminPledge;
import handlers.admincommandhandlers.AdminPolymorph; import handlers.admincommandhandlers.AdminPolymorph;
import handlers.admincommandhandlers.AdminPremium;
import handlers.admincommandhandlers.AdminPunishment; import handlers.admincommandhandlers.AdminPunishment;
import handlers.admincommandhandlers.AdminQuest; import handlers.admincommandhandlers.AdminQuest;
import handlers.admincommandhandlers.AdminReload; import handlers.admincommandhandlers.AdminReload;
@ -249,6 +250,7 @@ import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin; import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug; import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang; import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.Premium;
import handlers.voicedcommandhandlers.StatsVCmd; import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.Wedding; import handlers.voicedcommandhandlers.Wedding;
@ -374,6 +376,7 @@ public class MasterHandler
AdminPForge.class, AdminPForge.class,
AdminPledge.class, AdminPledge.class,
AdminPolymorph.class, AdminPolymorph.class,
AdminPremium.class,
AdminPunishment.class, AdminPunishment.class,
AdminQuest.class, AdminQuest.class,
AdminReload.class, AdminReload.class,
@ -524,6 +527,7 @@ public class MasterHandler
(Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null), (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
(Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null), (Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
(Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null), (Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
(Config.PREMIUM_SYSTEM_ENABLED ? Premium.class : null),
}, },
{ {
// Target Handlers // Target Handlers

View File

@ -0,0 +1,153 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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 DataPack 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.admincommandhandlers;
import java.text.SimpleDateFormat;
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
import com.l2jserver.gameserver.instancemanager.PremiumManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Mobius
*/
public class AdminPremium implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_premium_menu",
"admin_premium_add1",
"admin_premium_add2",
"admin_premium_add3",
"admin_premium_info",
"admin_premium_remove"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_premium_menu"))
{
AdminHtml.showAdminHtml(activeChar, "premium_menu.htm");
}
else if (command.startsWith("admin_premium_add1"))
{
try
{
String val = command.substring(19);
addPremiumStatus(activeChar, 1, val);
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error.");
}
}
else if (command.startsWith("admin_premium_add2"))
{
try
{
String val = command.substring(19);
addPremiumStatus(activeChar, 2, val);
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error.");
}
}
else if (command.startsWith("admin_premium_add3"))
{
try
{
String val = command.substring(19);
addPremiumStatus(activeChar, 3, val);
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error.");
}
}
else if (command.startsWith("admin_premium_info"))
{
try
{
String val = command.substring(19);
viewPremiumInfo(activeChar, val);
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error.");
}
}
else if (command.startsWith("admin_premium_remove"))
{
try
{
String val = command.substring(21);
removePremium(activeChar, val);
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Error.");
}
}
return true;
}
private void addPremiumStatus(L2PcInstance admin, int months, String accountName)
{
// TODO: Add check if account exists XD
PremiumManager.getInstance().updatePremiumData(months, accountName);
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
final long endDate = PremiumManager.getInstance().getPremiumEndDate(accountName);
admin.sendMessage("Account " + accountName + " will now have premium status until " + String.valueOf(format.format(endDate)) + ".");
}
private void viewPremiumInfo(L2PcInstance admin, String accountName)
{
if (PremiumManager.getInstance().getPremiumEndDate(accountName) > 0)
{
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
final long endDate = PremiumManager.getInstance().getPremiumEndDate(accountName);
admin.sendMessage("Account " + accountName + " has premium status until " + String.valueOf(format.format(endDate)) + ".");
}
else
{
admin.sendMessage("Account " + accountName + " has no premium status.");
}
}
private void removePremium(L2PcInstance admin, String accountName)
{
if (PremiumManager.getInstance().getPremiumEndDate(accountName) > 0)
{
PremiumManager.getInstance().removePremiumStatus(accountName);
admin.sendMessage("Account " + accountName + " has no longer premium status.");
}
else
{
admin.sendMessage("Account " + accountName + " has no premium status.");
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@ -0,0 +1,107 @@
/*
* Copyright (C) 2004-2015 L2J DataPack
*
* This file is part of L2J DataPack.
*
* L2J DataPack 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 DataPack 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.voicedcommandhandlers;
import java.text.SimpleDateFormat;
import com.l2jserver.Config;
import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
import com.l2jserver.gameserver.instancemanager.PremiumManager;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
public class Premium implements IVoicedCommandHandler
{
private static final String[] VOICED_COMMANDS =
{
"premium"
};
@Override
public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
{
if (command.startsWith("premium") && Config.PREMIUM_SYSTEM_ENABLED)
{
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
long endDate = PremiumManager.getInstance().getPremiumEndDate(activeChar.getAccountName());
if (endDate == 0)
{
NpcHtmlMessage msg = new NpcHtmlMessage(5);
StringBuilder html = new StringBuilder("<html><body><title>Account Details</title><center>");
html.append("<table>");
html.append("<tr><td><center>Account Status: <font color=\"LEVEL\">Normal<br></font></td></tr>");
html.append("<tr><td>Rate XP: <font color=\"LEVEL\"> x" + Config.RATE_XP + "<br1></font></td></tr>");
html.append("<tr><td>Rate SP: <font color=\"LEVEL\"> x" + Config.RATE_SP + "<br1></font></td></tr>");
html.append("<tr><td>Drop Chance: <font color=\"LEVEL\"> x" + Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER + "<br1></font></td></tr><br>");
html.append("<tr><td>Drop Ammount: <font color=\"LEVEL\"> x" + Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER + "<br1></font></td></tr><br>");
html.append("<tr><td>Spoil Chance: <font color=\"LEVEL\"> x" + Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER + "<br1></font></td></tr><br>");
html.append("<tr><td>Spoil Ammount: <font color=\"LEVEL\"> x" + Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER + "<br><br></font></td></tr><br>");
html.append("<tr><td><center>Premium Info & Rules<br></td></tr>");
html.append("<tr><td>Rate XP: <font color=\"LEVEL\"> x" + (Config.RATE_XP * Config.PREMIUM_RATE_XP) + "<br1></font></td></tr>");
html.append("<tr><td>Rate SP: <font color=\"LEVEL\"> x" + (Config.RATE_SP * Config.PREMIUM_RATE_SP) + "<br1></font></td></tr>");
html.append("<tr><td>Drop Chance: <font color=\"LEVEL\"> x" + (Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_DROP_CHANCE) + "<br1></font></td></tr>");
html.append("<tr><td>Drop Ammount: <font color=\"LEVEL\"> x" + (Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_DROP_AMMOUNT) + "<br1></font></td></tr>");
html.append("<tr><td>Spoil Chance: <font color=\"LEVEL\"> x" + (Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_SPOIL_CHANCE) + "<br1></font></td></tr>");
html.append("<tr><td>Spoil Ammount: <font color=\"LEVEL\"> x" + (Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_SPOIL_AMMOUNT) + "<br1></font></td></tr>");
html.append("<tr><td> <font color=\"70FFCA\">1. Premium benefits CAN NOT BE TRANSFERED.<br1></font></td></tr>");
html.append("<tr><td> <font color=\"70FFCA\">2. Premium does not effect party members.<br1></font></td></tr>");
html.append("<tr><td> <font color=\"70FFCA\">3. Premium benefits effect ALL characters in same account.</font></td></tr>");
html.append("</table>");
html.append("</center></body></html>");
msg.setHtml(html.toString());
activeChar.sendPacket(msg);
}
else
{
NpcHtmlMessage msg = new NpcHtmlMessage(5);
StringBuilder html = new StringBuilder("<html><body><title>Premium Account Details</title><center>");
html.append("<table>");
html.append("<tr><td><center>Account Status: <font color=\"LEVEL\">Premium<br></font></td></tr>");
html.append("<tr><td>Rate XP: <font color=\"LEVEL\">x" + (Config.RATE_XP * Config.PREMIUM_RATE_XP) + " <br1></font></td></tr>");
html.append("<tr><td>Rate SP: <font color=\"LEVEL\">x" + (Config.RATE_SP * Config.PREMIUM_RATE_SP) + " <br1></font></td></tr>");
html.append("<tr><td>Drop Chance: <font color=\"LEVEL\">x" + (Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_DROP_CHANCE) + " <br1></font></td></tr>");
html.append("<tr><td>Drop Ammount: <font color=\"LEVEL\">x" + (Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_DROP_AMMOUNT) + " <br1></font></td></tr>");
html.append("<tr><td>Spoil Chance: <font color=\"LEVEL\">x" + (Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER * Config.PREMIUM_RATE_SPOIL_CHANCE) + " <br1></font></td></tr>");
html.append("<tr><td>Spoil Ammount: <font color=\"LEVEL\">x" + (Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER * Config.PREMIUM_RATE_SPOIL_AMMOUNT) + " <br1></font></td></tr>");
html.append("<tr><td>Expires: <font color=\"00A5FF\">" + String.valueOf(format.format(endDate)) + "</font></td></tr>");
html.append("<tr><td>Current Date: <font color=\"70FFCA\">" + String.valueOf(format.format(System.currentTimeMillis())) + "<br><br></font></td></tr>");
html.append("<tr><td><center>Premium Info & Rules<br></center></td></tr>");
html.append("<tr><td><font color=\"70FFCA\">1. Premium accounts CAN NOT BE TRANSFERED.<br1></font></td></tr>");
html.append("<tr><td><font color=\"70FFCA\">2. Premium does not effect party members.<br1></font></td></tr>");
html.append("<tr><td><font color=\"70FFCA\">3. Premium account effects ALL characters in same account.<br><br><br></font></td></tr>");
html.append("<tr><td><center>Thank you for supporting our server.</td></tr>");
html.append("</table>");
html.append("</center></body></html>");
msg.setHtml(html.toString());
activeChar.sendPacket(msg);
}
}
else
{
return false;
}
return true;
}
@Override
public String[] getVoicedCommandList()
{
return VOICED_COMMANDS;
}
}

View File

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

View File

@ -831,6 +831,14 @@ public final class Config
public static String FACTION_EVIL_TEAM_NAME; public static String FACTION_EVIL_TEAM_NAME;
public static int FACTION_GOOD_NAME_COLOR; public static int FACTION_GOOD_NAME_COLOR;
public static int FACTION_EVIL_NAME_COLOR; public static int FACTION_EVIL_NAME_COLOR;
public static boolean PREMIUM_SYSTEM_ENABLED;
public static float PREMIUM_RATE_XP;
public static float PREMIUM_RATE_SP;
public static Map<Integer, Float> PREMIUM_RATE_DROP_ITEMS_ID;
public static float PREMIUM_RATE_DROP_CHANCE;
public static float PREMIUM_RATE_DROP_AMMOUNT;
public static float PREMIUM_RATE_SPOIL_CHANCE;
public static float PREMIUM_RATE_SPOIL_AMMOUNT;
// -------------------------------------------------- // --------------------------------------------------
// NPC Settings // NPC Settings
@ -2641,6 +2649,14 @@ public final class Config
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("GoodNameColor", "00FF00")); FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("GoodNameColor", "00FF00"));
FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("EvilNameColor", "0000FF")); FACTION_EVIL_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("EvilNameColor", "0000FF"));
PREMIUM_SYSTEM_ENABLED = CustomSettings.getBoolean("EnablePremiumSystem", false);
PREMIUM_RATE_XP = CustomSettings.getFloat("PremiumRateXp", 2);
PREMIUM_RATE_SP = CustomSettings.getFloat("PremiumRateSp", 2);
PREMIUM_RATE_DROP_CHANCE = CustomSettings.getFloat("PremiumRateDropChance", 2);
PREMIUM_RATE_DROP_AMMOUNT = CustomSettings.getFloat("PremiumRateDropAmmount", 1);
PREMIUM_RATE_SPOIL_CHANCE = CustomSettings.getFloat("PremiumRateSpoilChance", 2);
PREMIUM_RATE_SPOIL_AMMOUNT = CustomSettings.getFloat("PremiumRateSpoilAmmount", 1);
// Load PvP L2Properties file (if exists) // Load PvP L2Properties file (if exists)
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE); final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);

View File

@ -124,6 +124,7 @@ import com.l2jserver.gameserver.instancemanager.MapRegionManager;
import com.l2jserver.gameserver.instancemanager.MentorManager; import com.l2jserver.gameserver.instancemanager.MentorManager;
import com.l2jserver.gameserver.instancemanager.MercTicketManager; import com.l2jserver.gameserver.instancemanager.MercTicketManager;
import com.l2jserver.gameserver.instancemanager.PetitionManager; import com.l2jserver.gameserver.instancemanager.PetitionManager;
import com.l2jserver.gameserver.instancemanager.PremiumManager;
import com.l2jserver.gameserver.instancemanager.PunishmentManager; import com.l2jserver.gameserver.instancemanager.PunishmentManager;
import com.l2jserver.gameserver.instancemanager.QuestManager; import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.instancemanager.RaidBossPointsManager; import com.l2jserver.gameserver.instancemanager.RaidBossPointsManager;
@ -256,6 +257,11 @@ public class GameServer
CharSummonTable.getInstance().init(); CharSummonTable.getInstance().init();
BeautyShopData.getInstance(); BeautyShopData.getInstance();
MentorManager.getInstance(); MentorManager.getInstance();
if (Config.PREMIUM_SYSTEM_ENABLED)
{
_log.info("PremiumManager: Premium system is enabled.");
PremiumManager.getInstance();
}
printSection("Clans"); printSection("Clans");
ClanTable.getInstance(); ClanTable.getInstance();

View File

@ -0,0 +1,138 @@
/*
* Copyright (C) 2004-2015 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 com.l2jserver.gameserver.instancemanager;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Calendar;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Mobius, RobíkBobík
*/
public class PremiumManager
{
private long endDate = 0;
public long getPremiumEndDate(String accountName)
{
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
PreparedStatement statement = con.prepareStatement("SELECT premium_service,enddate FROM account_premium WHERE account_name=?");
statement.setString(1, accountName);
ResultSet rset = statement.executeQuery();
while (rset.next())
{
if (Config.PREMIUM_SYSTEM_ENABLED)
{
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 = L2DatabaseFactory.getInstance().getConnection())
{
Calendar endDate = Calendar.getInstance();
endDate.setTimeInMillis(System.currentTimeMillis() + remainingTime);
endDate.set(Calendar.SECOND, 0);
endDate.add(Calendar.MONTH, months);
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)
{
}
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if (player.getAccountNamePlayer().equalsIgnoreCase(accountName))
{
player.setPremiumStatus(getPremiumEndDate(accountName) > 0 ? true : false);
}
}
}
public void removePremiumStatus(String accountName)
{
// TODO: Add check if account exists. XD
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
PreparedStatement statement = con.prepareStatement("INSERT INTO account_premium (account_name,premium_service,enddate) values(?,?,?) ON DUPLICATE KEY UPDATE premium_service = ?, enddate = ?");
statement.setString(1, accountName);
statement.setInt(2, 0);
statement.setLong(3, 0);
statement.setInt(4, 0);
statement.setLong(5, 0);
statement.execute();
statement.close();
}
catch (SQLException e)
{
}
for (L2PcInstance player : L2World.getInstance().getPlayers())
{
if (player.getAccountNamePlayer().equalsIgnoreCase(accountName))
{
player.setPremiumStatus(false);
}
}
}
public static final PremiumManager getInstance()
{
return SingletonHolder._instance;
}
private static class SingletonHolder
{
protected static final PremiumManager _instance = new PremiumManager();
}
}

View File

@ -111,6 +111,7 @@ import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
import com.l2jserver.gameserver.instancemanager.InstanceManager; import com.l2jserver.gameserver.instancemanager.InstanceManager;
import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager; import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
import com.l2jserver.gameserver.instancemanager.MentorManager; import com.l2jserver.gameserver.instancemanager.MentorManager;
import com.l2jserver.gameserver.instancemanager.PremiumManager;
import com.l2jserver.gameserver.instancemanager.PunishmentManager; import com.l2jserver.gameserver.instancemanager.PunishmentManager;
import com.l2jserver.gameserver.instancemanager.QuestManager; import com.l2jserver.gameserver.instancemanager.QuestManager;
import com.l2jserver.gameserver.instancemanager.SiegeManager; import com.l2jserver.gameserver.instancemanager.SiegeManager;
@ -362,6 +363,9 @@ public final class L2PcInstance extends L2Playable
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=? WHERE charId=?"; private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,fame=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,title_color=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,newbie=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,bookmarkslot=?,vitality_points=?,language=?,faction=? WHERE charId=?";
private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?"; private static final String RESTORE_CHARACTER = "SELECT * FROM characters WHERE charId=?";
// Character Premium System String Definitions:
private static final String RESTORE_PREMIUMSERVICE = "SELECT premium_service,enddate FROM account_premium WHERE account_name=?";
// Character Teleport Bookmark: // Character Teleport Bookmark:
private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)"; private static final String INSERT_TP_BOOKMARK = "INSERT INTO character_tpbookmark (charId,Id,x,y,z,icon,tag,name) values (?,?,?,?,?,?,?,?)";
private static final String UPDATE_TP_BOOKMARK = "UPDATE character_tpbookmark SET icon=?,tag=?,name=? where charId=? AND Id=?"; private static final String UPDATE_TP_BOOKMARK = "UPDATE character_tpbookmark SET icon=?,tag=?,name=? where charId=? AND Id=?";
@ -599,6 +603,9 @@ public final class L2PcInstance extends L2Playable
private boolean _noble = false; private boolean _noble = false;
private boolean _hero = false; private boolean _hero = false;
/** Premium System */
private boolean _premiumStatus = false;
/** Faction System */ /** Faction System */
private boolean _isGood = false; private boolean _isGood = false;
private boolean _isEvil = false; private boolean _isEvil = false;
@ -6912,6 +6919,7 @@ public final class L2PcInstance extends L2Playable
player = new L2PcInstance(objectId, template, rset.getString("account_name"), app); player = new L2PcInstance(objectId, template, rset.getString("account_name"), app);
player.setName(rset.getString("char_name")); player.setName(rset.getString("char_name"));
restorePremiumSystemData(player, rset.getString("account_name"));
player._lastAccess = rset.getLong("lastAccess"); player._lastAccess = rset.getLong("lastAccess");
player.getStat().setExp(rset.getLong("exp")); player.getStat().setExp(rset.getLong("exp"));
@ -14083,6 +14091,58 @@ public final class L2PcInstance extends L2Playable
_recoTwoHoursGiven = val; _recoTwoHoursGiven = val;
} }
public void setPremiumStatus(boolean premiumStatus)
{
_premiumStatus = premiumStatus;
}
public boolean hasPremiumStatus()
{
return _premiumStatus;
}
private static void restorePremiumSystemData(L2PcInstance player, String account)
{
boolean success = false;
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
PreparedStatement statement = con.prepareStatement(RESTORE_PREMIUMSERVICE);
statement.setString(1, account);
ResultSet rset = statement.executeQuery();
while (rset.next())
{
success = true;
if (Config.PREMIUM_SYSTEM_ENABLED)
{
if (rset.getLong("enddate") <= System.currentTimeMillis())
{
PremiumManager.getInstance().removePremiumStatus(account);
player.setPremiumStatus(false);
}
else
{
player.setPremiumStatus(rset.getBoolean("premium_service"));
}
}
else
{
player.setPremiumStatus(false);
}
}
statement.close();
}
catch (Exception e)
{
_log.warning("Premium System: Could not restore premium system data for " + account + "." + e);
e.printStackTrace();
}
if (success == false)
{
PremiumManager.getInstance().removePremiumStatus(player.getAccountName());
player.setPremiumStatus(false);
}
}
public void setLastPetitionGmName(String gmName) public void setLastPetitionGmName(String gmName)
{ {
_lastPetitionGmName = gmName; _lastPetitionGmName = gmName;

View File

@ -131,6 +131,12 @@ public class PcStat extends PlayableStat
addToExp *= bonusExp; addToExp *= bonusExp;
addToSp *= bonusSp; addToSp *= bonusSp;
if (activeChar.hasPremiumStatus())
{
addToExp *= Config.PREMIUM_RATE_XP;
addToSp *= Config.PREMIUM_RATE_SP;
}
float ratioTakenByPlayer = 0; float ratioTakenByPlayer = 0;
// if this player has a pet and it is in his range he takes from the owner's Exp, give the pet Exp now // if this player has a pet and it is in his range he takes from the owner's Exp, give the pet Exp now

View File

@ -41,9 +41,9 @@ public class CorpseDropItem extends GeneralDropItem
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier() * @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
*/ */
@Override @Override
protected double getGlobalAmountMultiplier() protected double getGlobalAmountMultiplier(boolean isPremium)
{ {
return Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER; return isPremium ? Config.PREMIUM_RATE_SPOIL_AMMOUNT * Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER : Config.RATE_CORPSE_DROP_AMOUNT_MULTIPLIER;
} }
/* /*
@ -51,8 +51,8 @@ public class CorpseDropItem extends GeneralDropItem
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier() * @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier()
*/ */
@Override @Override
protected double getGlobalChanceMultiplier() protected double getGlobalChanceMultiplier(boolean isPremium)
{ {
return Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER; return isPremium ? Config.PREMIUM_RATE_SPOIL_CHANCE * Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER : Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER;
} }
} }

View File

@ -41,9 +41,9 @@ public class DeathDropItem extends GeneralDropItem
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier() * @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
*/ */
@Override @Override
protected double getGlobalAmountMultiplier() protected double getGlobalAmountMultiplier(boolean isPremium)
{ {
return Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER; return isPremium ? Config.PREMIUM_RATE_DROP_AMMOUNT * Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER : Config.RATE_DEATH_DROP_AMOUNT_MULTIPLIER;
} }
/* /*
@ -51,8 +51,8 @@ public class DeathDropItem extends GeneralDropItem
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier() * @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalChanceMultiplier()
*/ */
@Override @Override
protected double getGlobalChanceMultiplier() protected double getGlobalChanceMultiplier(boolean isPremium)
{ {
return Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER; return isPremium ? Config.PREMIUM_RATE_DROP_CHANCE * Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER : Config.RATE_DEATH_DROP_CHANCE_MULTIPLIER;
} }
} }

View File

@ -54,12 +54,12 @@ public class GeneralDropItem implements IDropItem
_chance = chance; _chance = chance;
} }
protected double getGlobalChanceMultiplier() protected double getGlobalChanceMultiplier(boolean isPremium)
{ {
return 1.; return 1.;
} }
protected double getGlobalAmountMultiplier() protected double getGlobalAmountMultiplier(boolean isPremium)
{ {
return 1.; return 1.;
} }
@ -87,7 +87,7 @@ public class GeneralDropItem implements IDropItem
else else
{ {
// drop type specific amount multiplier // drop type specific amount multiplier
multiplier *= getGlobalAmountMultiplier(); multiplier *= getGlobalAmountMultiplier(killer.getActingPlayer().hasPremiumStatus());
} }
} }
@ -183,7 +183,7 @@ public class GeneralDropItem implements IDropItem
} }
else else
{ {
multiplier *= getGlobalChanceMultiplier(); multiplier *= getGlobalChanceMultiplier(killer.getActingPlayer().hasPremiumStatus());
} }
} }