Store custom player statuses in player variables.
This commit is contained in:
@@ -678,7 +678,7 @@ public class Config
|
|||||||
public static int DIFFERENT_Z_NEW_MOVIE;
|
public static int DIFFERENT_Z_NEW_MOVIE;
|
||||||
public static int HERO_CUSTOM_ITEM_ID;
|
public static int HERO_CUSTOM_ITEM_ID;
|
||||||
public static int NOOBLE_CUSTOM_ITEM_ID;
|
public static int NOOBLE_CUSTOM_ITEM_ID;
|
||||||
public static int HERO_CUSTOM_DAY;
|
public static long HERO_CUSTOM_DAY;
|
||||||
public static boolean ALLOW_FARM1_COMMAND;
|
public static boolean ALLOW_FARM1_COMMAND;
|
||||||
public static boolean ALLOW_FARM2_COMMAND;
|
public static boolean ALLOW_FARM2_COMMAND;
|
||||||
public static boolean ALLOW_PVP1_COMMAND;
|
public static boolean ALLOW_PVP1_COMMAND;
|
||||||
@@ -1885,7 +1885,7 @@ public class Config
|
|||||||
NOOBLE_CUSTOM_ITEM_ID = customServerConfig.getInt("NoobleCustomItemId", 6673);
|
NOOBLE_CUSTOM_ITEM_ID = customServerConfig.getInt("NoobleCustomItemId", 6673);
|
||||||
HERO_CUSTOM_ITEMS = customServerConfig.getBoolean("EnableHeroCustomItem", true);
|
HERO_CUSTOM_ITEMS = customServerConfig.getBoolean("EnableHeroCustomItem", true);
|
||||||
HERO_CUSTOM_ITEM_ID = customServerConfig.getInt("HeroCustomItemId", 3481);
|
HERO_CUSTOM_ITEM_ID = customServerConfig.getInt("HeroCustomItemId", 3481);
|
||||||
HERO_CUSTOM_DAY = customServerConfig.getInt("HeroCustomDay", 0);
|
HERO_CUSTOM_DAY = customServerConfig.getLong("HeroCustomDay", 0);
|
||||||
ALLOW_CREATE_LVL = customServerConfig.getBoolean("CustomStartingLvl", false);
|
ALLOW_CREATE_LVL = customServerConfig.getBoolean("CustomStartingLvl", false);
|
||||||
CHAR_CREATE_LVL = customServerConfig.getInt("CharLvl", 80);
|
CHAR_CREATE_LVL = customServerConfig.getInt("CharLvl", 80);
|
||||||
SPAWN_CHAR = customServerConfig.getBoolean("CustomSpawn", false);
|
SPAWN_CHAR = customServerConfig.getBoolean("CustomSpawn", false);
|
||||||
|
@@ -16,28 +16,24 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
||||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||||
import org.l2jmobius.gameserver.model.WorldObject;
|
import org.l2jmobius.gameserver.model.WorldObject;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
import org.l2jmobius.gameserver.model.entity.Announcements;
|
|
||||||
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
|
||||||
import org.l2jmobius.gameserver.util.BuilderUtil;
|
import org.l2jmobius.gameserver.util.BuilderUtil;
|
||||||
|
|
||||||
public class AdminDonator implements IAdminCommandHandler
|
public class AdminDonator implements IAdminCommandHandler
|
||||||
{
|
{
|
||||||
|
protected static final Logger LOGGER = Logger.getLogger(AdminDonator.class.getName());
|
||||||
|
|
||||||
private static final String[] ADMIN_COMMANDS =
|
private static final String[] ADMIN_COMMANDS =
|
||||||
{
|
{
|
||||||
"admin_setdonator"
|
"admin_setdonator"
|
||||||
};
|
};
|
||||||
|
|
||||||
protected static final Logger LOGGER = Logger.getLogger(AdminDonator.class.getName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
||||||
{
|
{
|
||||||
@@ -57,8 +53,10 @@ public class AdminDonator implements IAdminCommandHandler
|
|||||||
{
|
{
|
||||||
targetPlayer.setDonator(true);
|
targetPlayer.setDonator(true);
|
||||||
targetPlayer.updateNameTitleColor();
|
targetPlayer.updateNameTitleColor();
|
||||||
updateDatabase(targetPlayer, true);
|
targetPlayer.getVariables().set("CustomDonator", true);
|
||||||
sendMessages(true, targetPlayer, activeChar, false, true);
|
targetPlayer.sendMessage(activeChar.getName() + " has granted you donator status!");
|
||||||
|
activeChar.sendMessage("You have granted donator status to " + targetPlayer.getName());
|
||||||
|
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has set " + targetPlayer.getName() + " as donator !");
|
||||||
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
|
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
|
||||||
targetPlayer.broadcastUserInfo();
|
targetPlayer.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
@@ -66,95 +64,23 @@ public class AdminDonator implements IAdminCommandHandler
|
|||||||
{
|
{
|
||||||
targetPlayer.setDonator(false);
|
targetPlayer.setDonator(false);
|
||||||
targetPlayer.updateNameTitleColor();
|
targetPlayer.updateNameTitleColor();
|
||||||
updateDatabase(targetPlayer, false);
|
targetPlayer.getVariables().set("CustomDonator", false);
|
||||||
sendMessages(false, targetPlayer, activeChar, false, true);
|
targetPlayer.sendMessage(activeChar.getName() + " has revoked donator status from you!");
|
||||||
|
activeChar.sendMessage("You have revoked donator status from " + targetPlayer.getName());
|
||||||
|
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has removed donator status from player" + targetPlayer.getName());
|
||||||
targetPlayer.broadcastUserInfo();
|
targetPlayer.broadcastUserInfo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non Player Target as Donator.");
|
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non player target as donator.");
|
||||||
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non Player Target as Donator.");
|
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non player target as donator.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessages(boolean forNewDonator, PlayerInstance player, PlayerInstance gm, boolean announce, boolean notifyGmList)
|
|
||||||
{
|
|
||||||
if (forNewDonator)
|
|
||||||
{
|
|
||||||
player.sendMessage(gm.getName() + " has granted Donator Status for you!");
|
|
||||||
gm.sendMessage("You've granted Donator Status for " + player.getName());
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
Announcements.getInstance().announceToAll(player.getName() + " has received Donator Status!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notifyGmList)
|
|
||||||
{
|
|
||||||
AdminData.broadcastMessageToGMs("Warn: " + gm.getName() + " has set " + player.getName() + " as Donator !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage(gm.getName() + " has revoked Donator Status from you!");
|
|
||||||
gm.sendMessage("You've revoked Donator Status from " + player.getName());
|
|
||||||
if (announce)
|
|
||||||
{
|
|
||||||
Announcements.getInstance().announceToAll(player.getName() + " has lost Donator Status!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notifyGmList)
|
|
||||||
{
|
|
||||||
AdminData.broadcastMessageToGMs("Warn: " + gm.getName() + " has removed Donator Status of player" + player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param player
|
|
||||||
* @param newDonator
|
|
||||||
*/
|
|
||||||
private void updateDatabase(PlayerInstance player, boolean newDonator)
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection())
|
|
||||||
{
|
|
||||||
final PreparedStatement stmt = con.prepareStatement(newDonator ? INSERT_DATA : DEL_DATA);
|
|
||||||
|
|
||||||
// if it is a new donator insert proper data
|
|
||||||
if (newDonator)
|
|
||||||
{
|
|
||||||
stmt.setInt(1, player.getObjectId());
|
|
||||||
stmt.setString(2, player.getName());
|
|
||||||
stmt.setInt(3, player.isHero() ? 1 : 0);
|
|
||||||
stmt.setInt(4, player.isNoble() ? 1 : 0);
|
|
||||||
stmt.setInt(5, 1);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
else // deletes from database
|
|
||||||
{
|
|
||||||
stmt.setInt(1, player.getObjectId());
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.warning("Error: could not update database: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator) VALUES (?,?,?,?,?)";
|
|
||||||
String DEL_DATA = "UPDATE characters_custom_data SET donator = 0 WHERE obj_Id=?";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getAdminCommandList()
|
public String[] getAdminCommandList()
|
||||||
{
|
{
|
||||||
|
@@ -16,11 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
package org.l2jmobius.gameserver.handler.admincommandhandlers;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
import org.l2jmobius.gameserver.datatables.xml.AdminData;
|
||||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||||
import org.l2jmobius.gameserver.model.WorldObject;
|
import org.l2jmobius.gameserver.model.WorldObject;
|
||||||
@@ -30,13 +27,13 @@ import org.l2jmobius.gameserver.util.BuilderUtil;
|
|||||||
|
|
||||||
public class AdminNoble implements IAdminCommandHandler
|
public class AdminNoble implements IAdminCommandHandler
|
||||||
{
|
{
|
||||||
|
protected static final Logger LOGGER = Logger.getLogger(AdminNoble.class.getName());
|
||||||
|
|
||||||
private static final String[] ADMIN_COMMANDS =
|
private static final String[] ADMIN_COMMANDS =
|
||||||
{
|
{
|
||||||
"admin_setnoble"
|
"admin_setnoble"
|
||||||
};
|
};
|
||||||
|
|
||||||
protected static final Logger LOGGER = Logger.getLogger(AdminNoble.class.getName());
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
||||||
{
|
{
|
||||||
@@ -56,22 +53,26 @@ public class AdminNoble implements IAdminCommandHandler
|
|||||||
{
|
{
|
||||||
targetPlayer.setNoble(true);
|
targetPlayer.setNoble(true);
|
||||||
targetPlayer.sendMessage("You are now a noblesse.");
|
targetPlayer.sendMessage("You are now a noblesse.");
|
||||||
updateDatabase(targetPlayer, true);
|
targetPlayer.getVariables().set("CustomNoble", true);
|
||||||
sendMessages(true, targetPlayer, activeChar, true);
|
targetPlayer.sendMessage(activeChar.getName() + " has granted noble status from you!");
|
||||||
|
activeChar.sendMessage("You've granted noble status from " + targetPlayer.getName());
|
||||||
|
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has set " + targetPlayer.getName() + " as noble !");
|
||||||
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
|
targetPlayer.broadcastPacket(new SocialAction(targetPlayer.getObjectId(), 16));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetPlayer.setNoble(false);
|
targetPlayer.setNoble(false);
|
||||||
targetPlayer.sendMessage("You are no longer a noblesse.");
|
targetPlayer.sendMessage("You are no longer a noblesse.");
|
||||||
updateDatabase(targetPlayer, false);
|
targetPlayer.getVariables().set("CustomNoble", false);
|
||||||
sendMessages(false, targetPlayer, activeChar, true);
|
targetPlayer.sendMessage(activeChar.getName() + " has revoked noble status for you!");
|
||||||
|
activeChar.sendMessage("You've revoked noble status for " + targetPlayer.getName());
|
||||||
|
AdminData.broadcastMessageToGMs("Warn: " + activeChar.getName() + " has removed noble status of player" + targetPlayer.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non Player Target as noble.");
|
BuilderUtil.sendSysMessage(activeChar, "Impossible to set a non player target as noble.");
|
||||||
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non Player Target as noble.");
|
LOGGER.info("GM: " + activeChar.getName() + " is trying to set a non player target as noble.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,64 +80,6 @@ public class AdminNoble implements IAdminCommandHandler
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessages(boolean forNewNoble, PlayerInstance player, PlayerInstance gm, boolean notifyGmList)
|
|
||||||
{
|
|
||||||
if (forNewNoble)
|
|
||||||
{
|
|
||||||
player.sendMessage(gm.getName() + " has granted Noble Status from you!");
|
|
||||||
gm.sendMessage("You've granted Noble Status from " + player.getName());
|
|
||||||
if (notifyGmList)
|
|
||||||
{
|
|
||||||
AdminData.broadcastMessageToGMs("Warn: " + gm.getName() + " has set " + player.getName() + " as Noble !");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage(gm.getName() + " has revoked Noble Status for you!");
|
|
||||||
gm.sendMessage("You've revoked Noble Status for " + player.getName());
|
|
||||||
if (notifyGmList)
|
|
||||||
{
|
|
||||||
AdminData.broadcastMessageToGMs("Warn: " + gm.getName() + " has removed Noble Status of player" + player.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDatabase(PlayerInstance player, boolean newNoble)
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection())
|
|
||||||
{
|
|
||||||
final PreparedStatement stmt = con.prepareStatement(newNoble ? INSERT_DATA : DEL_DATA);
|
|
||||||
if (newNoble)
|
|
||||||
{
|
|
||||||
stmt.setInt(1, player.getObjectId());
|
|
||||||
stmt.setString(2, player.getName());
|
|
||||||
stmt.setInt(3, player.isHero() ? 1 : 0);
|
|
||||||
stmt.setInt(4, 1);
|
|
||||||
stmt.setInt(5, player.isDonator() ? 1 : 0);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
else // deletes from database
|
|
||||||
{
|
|
||||||
stmt.setInt(1, player.getObjectId());
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.warning("Error: could not update database: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator) VALUES (?,?,?,?,?)";
|
|
||||||
String DEL_DATA = "UPDATE characters_custom_data SET noble = 0 WHERE obj_Id=?";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getAdminCommandList()
|
public String[] getAdminCommandList()
|
||||||
{
|
{
|
||||||
|
@@ -16,12 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.l2jmobius.gameserver.handler.itemhandlers;
|
package org.l2jmobius.gameserver.handler.itemhandlers;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
|
||||||
import org.l2jmobius.gameserver.handler.IItemHandler;
|
import org.l2jmobius.gameserver.handler.IItemHandler;
|
||||||
import org.l2jmobius.gameserver.model.actor.Playable;
|
import org.l2jmobius.gameserver.model.actor.Playable;
|
||||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||||
@@ -32,7 +29,10 @@ public class HeroCustomItem implements IItemHandler
|
|||||||
{
|
{
|
||||||
protected static final Logger LOGGER = Logger.getLogger(HeroCustomItem.class.getName());
|
protected static final Logger LOGGER = Logger.getLogger(HeroCustomItem.class.getName());
|
||||||
|
|
||||||
private static final String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";
|
private static final int ITEM_IDS[] =
|
||||||
|
{
|
||||||
|
Config.HERO_CUSTOM_ITEM_ID
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void useItem(Playable playable, ItemInstance item)
|
public void useItem(Playable playable, ItemInstance item)
|
||||||
@@ -47,22 +47,25 @@ public class HeroCustomItem implements IItemHandler
|
|||||||
final PlayerInstance player = (PlayerInstance) playable;
|
final PlayerInstance player = (PlayerInstance) playable;
|
||||||
if (player.isInOlympiadMode())
|
if (player.isInOlympiadMode())
|
||||||
{
|
{
|
||||||
player.sendMessage("This Item Cannot Be Used On Olympiad Games.");
|
player.sendMessage("This item cannot be used in olympiad mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isHero())
|
if (player.isHero())
|
||||||
{
|
{
|
||||||
player.sendMessage("You Are Already A Hero!.");
|
player.sendMessage("You already are a hero!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
|
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
|
||||||
player.setHero(true);
|
player.setHero(true);
|
||||||
updateDatabase(player, Config.HERO_CUSTOM_DAY * 24 * 60 * 60 * 1000);
|
player.sendMessage("You are now a hero, you are granted with hero status, skills and aura.");
|
||||||
player.sendMessage("You Are Now a Hero,You Are Granted With Hero Status , Skills ,Aura.");
|
|
||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||||
player.getInventory().addItem("Wings", 6842, 1, player, null);
|
player.getInventory().addItem("CustomHeroWings", 6842, 1, player, null);
|
||||||
|
|
||||||
|
final long heroTime = Config.HERO_CUSTOM_DAY * 24 * 60 * 60 * 1000;
|
||||||
|
player.getVariables().set("CustomHero", true);
|
||||||
|
player.getVariables().set("CustomHeroEnd", heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,34 +75,4 @@ public class HeroCustomItem implements IItemHandler
|
|||||||
{
|
{
|
||||||
return ITEM_IDS;
|
return ITEM_IDS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDatabase(PlayerInstance player, long heroTime)
|
|
||||||
{
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection())
|
|
||||||
{
|
|
||||||
final PreparedStatement stmt = con.prepareStatement(INSERT_DATA);
|
|
||||||
stmt.setInt(1, player.getObjectId());
|
|
||||||
stmt.setString(2, player.getName());
|
|
||||||
stmt.setInt(3, 1);
|
|
||||||
stmt.setInt(4, player.isNoble() ? 1 : 0);
|
|
||||||
stmt.setInt(5, player.isDonator() ? 1 : 0);
|
|
||||||
stmt.setLong(6, heroTime == 0 ? 0 : System.currentTimeMillis() + heroTime);
|
|
||||||
stmt.execute();
|
|
||||||
stmt.close();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.warning("Error: could not update database: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final int ITEM_IDS[] =
|
|
||||||
{
|
|
||||||
Config.HERO_CUSTOM_ITEM_ID
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
@@ -43,21 +43,21 @@ public class NobleCustomItem implements IItemHandler
|
|||||||
final PlayerInstance player = (PlayerInstance) playable;
|
final PlayerInstance player = (PlayerInstance) playable;
|
||||||
if (player.isInOlympiadMode())
|
if (player.isInOlympiadMode())
|
||||||
{
|
{
|
||||||
player.sendMessage("This Item Cannot Be Used On Olympiad Games.");
|
player.sendMessage("This item cannot be used in Olympiad mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.isNoble())
|
if (player.isNoble())
|
||||||
{
|
{
|
||||||
player.sendMessage("You Are Already A Noblesse!.");
|
player.sendMessage("You are already a noblesse!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
|
player.broadcastPacket(new SocialAction(player.getObjectId(), 16));
|
||||||
player.setNoble(true);
|
player.setNoble(true);
|
||||||
player.sendMessage("You Are Now a Noble,You Are Granted With Noblesse Status , And Noblesse Skills.");
|
player.sendMessage("You are now a noble, you have been granted noblesse status and skills.");
|
||||||
player.broadcastUserInfo();
|
player.broadcastUserInfo();
|
||||||
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
|
||||||
player.getInventory().addItem("Tiara", 7694, 1, player, null);
|
player.getInventory().addItem("NobleCustomItem", 7694, 1, player, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -122,6 +122,7 @@ import org.l2jmobius.gameserver.model.clan.Clan;
|
|||||||
import org.l2jmobius.gameserver.model.clan.ClanMember;
|
import org.l2jmobius.gameserver.model.clan.ClanMember;
|
||||||
import org.l2jmobius.gameserver.model.entity.Announcements;
|
import org.l2jmobius.gameserver.model.entity.Announcements;
|
||||||
import org.l2jmobius.gameserver.model.entity.Duel;
|
import org.l2jmobius.gameserver.model.entity.Duel;
|
||||||
|
import org.l2jmobius.gameserver.model.entity.Hero;
|
||||||
import org.l2jmobius.gameserver.model.entity.Rebirth;
|
import org.l2jmobius.gameserver.model.entity.Rebirth;
|
||||||
import org.l2jmobius.gameserver.model.entity.event.CTF;
|
import org.l2jmobius.gameserver.model.entity.event.CTF;
|
||||||
import org.l2jmobius.gameserver.model.entity.event.DM;
|
import org.l2jmobius.gameserver.model.entity.event.DM;
|
||||||
@@ -240,7 +241,6 @@ public class PlayerInstance extends Playable
|
|||||||
/** SQL queries */
|
/** SQL queries */
|
||||||
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,pc_point=?,name_color=?,title_color=?,aio=?,aio_end=? WHERE obj_id=?";
|
private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,pc_point=?,name_color=?,title_color=?,aio=?,aio_end=? WHERE obj_id=?";
|
||||||
private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer,newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point,name_color,title_color,first_log,aio,aio_end FROM characters WHERE obj_id=?";
|
private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon,punish_level,punish_timer,newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point,name_color,title_color,first_log,aio,aio_end FROM characters WHERE obj_id=?";
|
||||||
private static final String STATUS_DATA_GET = "SELECT hero, noble, donator, hero_end_date FROM characters_custom_data WHERE obj_Id = ?";
|
|
||||||
private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
|
private static final String RESTORE_SKILLS_FOR_CHAR_ALT_SUBCLASS = "SELECT skill_id,skill_level FROM character_skills WHERE char_obj_id=? ORDER BY (skill_level+0)";
|
||||||
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
|
private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
|
||||||
private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
|
private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
|
||||||
@@ -14955,55 +14955,25 @@ public class PlayerInstance extends Playable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* restore all Custom Data hero/noble/donator.
|
|
||||||
*/
|
|
||||||
public void restoreCustomStatus()
|
public void restoreCustomStatus()
|
||||||
{
|
{
|
||||||
int hero = 0;
|
final long heroEnd = getVariables().getLong("CustomHeroEnd", 0);
|
||||||
int noble = 0;
|
if (getVariables().getBoolean("CustomHero", false) && ((heroEnd == 0) || (heroEnd > System.currentTimeMillis())))
|
||||||
int donator = 0;
|
|
||||||
long heroEnd = 0;
|
|
||||||
|
|
||||||
try (Connection con = DatabaseFactory.getConnection())
|
|
||||||
{
|
|
||||||
final PreparedStatement statement = con.prepareStatement(STATUS_DATA_GET);
|
|
||||||
statement.setInt(1, getObjectId());
|
|
||||||
|
|
||||||
final ResultSet rset = statement.executeQuery();
|
|
||||||
|
|
||||||
while (rset.next())
|
|
||||||
{
|
|
||||||
hero = rset.getInt("hero");
|
|
||||||
noble = rset.getInt("noble");
|
|
||||||
donator = rset.getInt("donator");
|
|
||||||
heroEnd = rset.getLong("hero_end_date");
|
|
||||||
}
|
|
||||||
rset.close();
|
|
||||||
statement.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.warning("Error: could not restore char custom data info: " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((hero > 0) && ((heroEnd == 0) || (heroEnd > System.currentTimeMillis())))
|
|
||||||
{
|
{
|
||||||
setHero(true);
|
setHero(true);
|
||||||
}
|
}
|
||||||
else
|
else if ((Hero.getInstance().getHeroes() != null) && !Hero.getInstance().getHeroes().containsKey(getObjectId()))
|
||||||
{
|
{
|
||||||
// delete wings of destiny
|
// Delete wings of destiny.
|
||||||
destroyItem("HeroEnd", 6842, 1, null, false);
|
destroyItem("CustomHeroEnd", 6842, 1, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noble > 0)
|
if (getVariables().getBoolean("CustomNoble", false))
|
||||||
{
|
{
|
||||||
setNoble(true);
|
setNoble(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (donator > 0)
|
if (getVariables().getBoolean("CustomDonator", false))
|
||||||
{
|
{
|
||||||
setDonator(true);
|
setDonator(true);
|
||||||
}
|
}
|
||||||
|
@@ -268,8 +268,7 @@ public class EnterWorld extends GameClientPacket
|
|||||||
|
|
||||||
// Restores custom status
|
// Restores custom status
|
||||||
player.restoreCustomStatus();
|
player.restoreCustomStatus();
|
||||||
|
colorSystem(player);
|
||||||
ColorSystem(player);
|
|
||||||
|
|
||||||
// Expand Skill
|
// Expand Skill
|
||||||
player.sendPacket(new ExStorageMaxCount(player));
|
player.sendPacket(new ExStorageMaxCount(player));
|
||||||
@@ -651,7 +650,7 @@ public class EnterWorld extends GameClientPacket
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ColorSystem(PlayerInstance player)
|
private void colorSystem(PlayerInstance player)
|
||||||
{
|
{
|
||||||
// Color System checks - Start
|
// Color System checks - Start
|
||||||
// Check if the custom PvP and PK color systems are enabled and if so check the character's counters
|
// Check if the custom PvP and PK color systems are enabled and if so check the character's counters
|
||||||
|
Reference in New Issue
Block a user