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.
# Default: 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_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 command="admin_quest_reload" 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>
</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="Premium" action="bypass -h admin_premium_menu" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
</tr>
</table>
<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.AdminPledge;
import handlers.admincommandhandlers.AdminPolymorph;
import handlers.admincommandhandlers.AdminPremium;
import handlers.admincommandhandlers.AdminPunishment;
import handlers.admincommandhandlers.AdminQuest;
import handlers.admincommandhandlers.AdminReload;
@@ -249,6 +250,7 @@ import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.Premium;
import handlers.voicedcommandhandlers.StatsVCmd;
import handlers.voicedcommandhandlers.Wedding;
@@ -374,6 +376,7 @@ public class MasterHandler
AdminPForge.class,
AdminPledge.class,
AdminPolymorph.class,
AdminPremium.class,
AdminPunishment.class,
AdminQuest.class,
AdminReload.class,
@@ -524,6 +527,7 @@ public class MasterHandler
(Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null),
(Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null),
(Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null),
(Config.PREMIUM_SYSTEM_ENABLED ? Premium.class : null),
},
{
// 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;