Premium system.
This commit is contained in:
@@ -831,6 +831,14 @@ public final class Config
|
||||
public static String FACTION_EVIL_TEAM_NAME;
|
||||
public static int FACTION_GOOD_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
|
||||
@@ -2641,6 +2649,14 @@ public final class Config
|
||||
FACTION_GOOD_NAME_COLOR = Integer.decode("0x" + CustomSettings.getString("GoodNameColor", "00FF00"));
|
||||
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)
|
||||
final PropertiesParser PVPSettings = new PropertiesParser(PVP_CONFIG_FILE);
|
||||
|
||||
|
@@ -124,6 +124,7 @@ import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.MentorManager;
|
||||
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PremiumManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossPointsManager;
|
||||
@@ -256,6 +257,11 @@ public class GameServer
|
||||
CharSummonTable.getInstance().init();
|
||||
BeautyShopData.getInstance();
|
||||
MentorManager.getInstance();
|
||||
if (Config.PREMIUM_SYSTEM_ENABLED)
|
||||
{
|
||||
_log.info("PremiumManager: Premium system is enabled.");
|
||||
PremiumManager.getInstance();
|
||||
}
|
||||
|
||||
printSection("Clans");
|
||||
ClanTable.getInstance();
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
@@ -111,6 +111,7 @@ import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ItemsOnGroundManager;
|
||||
import com.l2jserver.gameserver.instancemanager.MentorManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PremiumManager;
|
||||
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
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 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:
|
||||
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=?";
|
||||
@@ -599,6 +603,9 @@ public final class L2PcInstance extends L2Playable
|
||||
private boolean _noble = false;
|
||||
private boolean _hero = false;
|
||||
|
||||
/** Premium System */
|
||||
private boolean _premiumStatus = false;
|
||||
|
||||
/** Faction System */
|
||||
private boolean _isGood = 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.setName(rset.getString("char_name"));
|
||||
restorePremiumSystemData(player, rset.getString("account_name"));
|
||||
player._lastAccess = rset.getLong("lastAccess");
|
||||
|
||||
player.getStat().setExp(rset.getLong("exp"));
|
||||
@@ -14083,6 +14091,58 @@ public final class L2PcInstance extends L2Playable
|
||||
_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)
|
||||
{
|
||||
_lastPetitionGmName = gmName;
|
||||
|
@@ -131,6 +131,12 @@ public class PcStat extends PlayableStat
|
||||
addToExp *= bonusExp;
|
||||
addToSp *= bonusSp;
|
||||
|
||||
if (activeChar.hasPremiumStatus())
|
||||
{
|
||||
addToExp *= Config.PREMIUM_RATE_XP;
|
||||
addToSp *= Config.PREMIUM_RATE_SP;
|
||||
}
|
||||
|
||||
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
|
||||
|
@@ -41,9 +41,9 @@ public class CorpseDropItem extends GeneralDropItem
|
||||
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
|
||||
*/
|
||||
@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()
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
@@ -41,9 +41,9 @@ public class DeathDropItem extends GeneralDropItem
|
||||
* @see com.l2jserver.gameserver.model.drops.GeneralDropItem#getGlobalAmountMultiplier()
|
||||
*/
|
||||
@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()
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
@@ -54,12 +54,12 @@ public class GeneralDropItem implements IDropItem
|
||||
_chance = chance;
|
||||
}
|
||||
|
||||
protected double getGlobalChanceMultiplier()
|
||||
protected double getGlobalChanceMultiplier(boolean isPremium)
|
||||
{
|
||||
return 1.;
|
||||
}
|
||||
|
||||
protected double getGlobalAmountMultiplier()
|
||||
protected double getGlobalAmountMultiplier(boolean isPremium)
|
||||
{
|
||||
return 1.;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class GeneralDropItem implements IDropItem
|
||||
else
|
||||
{
|
||||
// drop type specific amount multiplier
|
||||
multiplier *= getGlobalAmountMultiplier();
|
||||
multiplier *= getGlobalAmountMultiplier(killer.getActingPlayer().hasPremiumStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class GeneralDropItem implements IDropItem
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplier *= getGlobalChanceMultiplier();
|
||||
multiplier *= getGlobalChanceMultiplier(killer.getActingPlayer().hasPremiumStatus());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user