Premium system for the custom community board.
Contributed by gigilo1968.
This commit is contained in:
@@ -62,7 +62,42 @@ public class PremiumManager
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void updatePremiumData(int months, String accountName)
|
||||
public void addPremiumDays(int days, 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.HOUR, 24 * days);
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if (player.getAccountNamePlayer().equalsIgnoreCase(accountName))
|
||||
{
|
||||
player.setPremiumStatus(getPremiumEndDate(accountName) > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addPremiumMonths(int months, String accountName)
|
||||
{
|
||||
long remainingTime = getPremiumEndDate(accountName);
|
||||
if (remainingTime > 0)
|
||||
|
@@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.network.serverpackets;
|
||||
|
||||
import com.l2jmobius.commons.network.PacketWriter;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.client.OutgoingPackets;
|
||||
|
||||
/**
|
||||
@@ -24,13 +25,11 @@ import com.l2jmobius.gameserver.network.client.OutgoingPackets;
|
||||
*/
|
||||
public class ExBrPremiumState implements IClientOutgoingPacket
|
||||
{
|
||||
private final int _objId;
|
||||
private final int _state;
|
||||
private final L2PcInstance _activeChar;
|
||||
|
||||
public ExBrPremiumState(int id, int state)
|
||||
public ExBrPremiumState(L2PcInstance activeChar)
|
||||
{
|
||||
_objId = id;
|
||||
_state = state;
|
||||
_activeChar = activeChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,8 +37,8 @@ public class ExBrPremiumState implements IClientOutgoingPacket
|
||||
{
|
||||
OutgoingPackets.EX_BR_PREMIUM_STATE.writeId(packet);
|
||||
|
||||
packet.writeD(_objId);
|
||||
packet.writeC(_state);
|
||||
packet.writeD(_activeChar.getObjectId());
|
||||
packet.writeC(_activeChar.hasPremiumStatus() ? 0x01 : 0x00);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user