From 6388ea050435c91b3239d328c2918f662eba853f Mon Sep 17 00:00:00 2001 From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com> Date: Fri, 22 Mar 2019 10:54:44 +0000 Subject: [PATCH] AdminLevel setlevel improvements. Contributed by NightBR. --- .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 31 +++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ .../admincommandhandlers/AdminLevel.java | 34 +++++++++++++------ 12 files changed, 284 insertions(+), 121 deletions(-) diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_6.0_Fafurion/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 73fdb4763f..314eec15e3 100644 --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,26 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); - if ((lvl >= 1) && (lvl <= ExperienceData.getInstance().getMaxLevel())) + if ((lvl >= 1) && (lvl <= maxLevel)) { final long pXp = targetPlayer.getExp(); final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); - if (pXp > tXp) { targetPlayer.removeExpAndSp(pXp - tXp, 0); @@ -86,16 +92,19 @@ public class AdminLevel implements IAdminCommandHandler { targetPlayer.addExpAndSp(tXp - pXp, 0); } + targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); + targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); + targetPlayer.broadcastUserInfo(); } else { - BuilderUtil.sendSysMessage(activeChar, "You must specify level between 1 and " + ExperienceData.getInstance().getMaxLevel() + "."); + BuilderUtil.sendSysMessage(activeChar, "You must specify level between 1 and " + maxLevel + "."); return false; } } catch (NumberFormatException e) { - BuilderUtil.sendSysMessage(activeChar, "You must specify level between 1 and " + ExperienceData.getInstance().getMaxLevel() + "."); + BuilderUtil.sendSysMessage(activeChar, "You must specify level between 1 and " + maxLevel + "."); return false; } } diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo(); diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java index 9afa9fb3d8..fff76953b1 100644 --- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java +++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminLevel.java @@ -18,6 +18,7 @@ package handlers.admincommandhandlers; import java.util.StringTokenizer; +import com.l2jmobius.Config; import com.l2jmobius.gameserver.data.xml.impl.ExperienceData; import com.l2jmobius.gameserver.handler.IAdminCommandHandler; import com.l2jmobius.gameserver.model.L2Object; @@ -63,21 +64,34 @@ public class AdminLevel implements IAdminCommandHandler } else if (actualCommand.equalsIgnoreCase("admin_set_level")) { - final int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if ((targetChar == null) || !targetChar.isPlayer()) + { + activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! + return false; + } + + final L2PcInstance targetPlayer = targetChar.getActingPlayer(); + int maxLevel = ExperienceData.getInstance().getMaxLevel(); + if (targetPlayer.isSubClassActive() && (Config.MAX_SUBCLASS_LEVEL < maxLevel)) + { + maxLevel = Config.MAX_SUBCLASS_LEVEL; + } + try { - if ((targetChar == null) || !targetChar.isPlayer()) - { - activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target! - return false; - } - final L2PcInstance targetPlayer = (L2PcInstance) targetChar; - final byte lvl = Byte.parseByte(val); if ((lvl >= 1) && (lvl <= maxLevel)) { - targetPlayer.setExp(ExperienceData.getInstance().getExpForLevel(lvl)); - targetPlayer.getStat().setLevel(lvl); + final long pXp = targetPlayer.getExp(); + final long tXp = ExperienceData.getInstance().getExpForLevel(lvl); + if (pXp > tXp) + { + targetPlayer.removeExpAndSp(pXp - tXp, 0); + } + else if (pXp < tXp) + { + targetPlayer.addExpAndSp(tXp - pXp, 0); + } targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp()); targetPlayer.setCurrentCp(targetPlayer.getMaxCp()); targetPlayer.broadcastUserInfo();