Merged with released L2J-Unity files.
This commit is contained in:
36
trunk/dist/game/data/scripts/handlers/ConditionMasterHandler.java
vendored
Normal file
36
trunk/dist/game/data/scripts/handlers/ConditionMasterHandler.java
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.ConditionHandler;
|
||||
|
||||
import handlers.conditions.CategoryTypeCondition;
|
||||
import handlers.conditions.NpcLevelCondition;
|
||||
import handlers.conditions.PlayerLevelCondition;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ConditionMasterHandler
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
ConditionHandler.getInstance().registerHandler("CategoryType", CategoryTypeCondition::new);
|
||||
ConditionHandler.getInstance().registerHandler("NpcLevel", NpcLevelCondition::new);
|
||||
ConditionHandler.getInstance().registerHandler("PlayerLevel", PlayerLevelCondition::new);
|
||||
}
|
||||
}
|
||||
BIN
trunk/dist/game/data/scripts/handlers/EffectMasterHandler.class
vendored
Normal file
BIN
trunk/dist/game/data/scripts/handlers/EffectMasterHandler.class
vendored
Normal file
Binary file not shown.
@@ -1,242 +1,343 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.EffectHandler;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
|
||||
import handlers.effecthandlers.*;
|
||||
|
||||
/**
|
||||
* Effect Master handler.
|
||||
* @author BiggBoss, Zoey76
|
||||
*/
|
||||
final class EffectMasterHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(EffectMasterHandler.class.getName());
|
||||
|
||||
private static final Class<?>[] EFFECTS =
|
||||
{
|
||||
AddHate.class,
|
||||
AttackTrait.class,
|
||||
Backstab.class,
|
||||
Betray.class,
|
||||
Blink.class,
|
||||
BlockAction.class,
|
||||
BlockBuff.class,
|
||||
BlockChat.class,
|
||||
BlockDamage.class,
|
||||
BlockDebuff.class,
|
||||
BlockParty.class,
|
||||
BlockBuffSlot.class,
|
||||
BlockResurrection.class,
|
||||
BlockTarget.class,
|
||||
Bluff.class,
|
||||
Buff.class,
|
||||
CallParty.class,
|
||||
CallPc.class,
|
||||
CallSkill.class,
|
||||
ChameleonRest.class,
|
||||
ChangeFace.class,
|
||||
ChangeFishingMastery.class,
|
||||
ChangeHairColor.class,
|
||||
ChangeHairStyle.class,
|
||||
ClanGate.class,
|
||||
ClassChange.class,
|
||||
Confuse.class,
|
||||
ConsumeBody.class,
|
||||
ConvertItem.class,
|
||||
CpDamPercent.class,
|
||||
CpHeal.class,
|
||||
CpHealOverTime.class,
|
||||
CpHealPercent.class,
|
||||
CrystalGradeModify.class,
|
||||
CubicMastery.class,
|
||||
DamOverTime.class,
|
||||
DamOverTimePercent.class,
|
||||
DeathLink.class,
|
||||
Debuff.class,
|
||||
DefenceTrait.class,
|
||||
DeleteHate.class,
|
||||
DeleteHateOfMe.class,
|
||||
DetectHiddenObjects.class,
|
||||
Detection.class,
|
||||
Disarm.class,
|
||||
DispelAll.class,
|
||||
DispelByCategory.class,
|
||||
DispelBySlot.class,
|
||||
DispelBySlotProbability.class,
|
||||
Duel.class,
|
||||
EnableCloak.class,
|
||||
EnemyCharge.class,
|
||||
EnergyAttack.class,
|
||||
Escape.class,
|
||||
FakeDeath.class,
|
||||
FatalBlow.class,
|
||||
Fear.class,
|
||||
FeohStance.class,
|
||||
Fishing.class,
|
||||
Flag.class,
|
||||
FocusEnergy.class,
|
||||
FocusMaxEnergy.class,
|
||||
FocusSouls.class,
|
||||
GetAgro.class,
|
||||
GiveRecommendation.class,
|
||||
GiveSp.class,
|
||||
GiveXp.class,
|
||||
Grow.class,
|
||||
HairAccessorySet.class,
|
||||
Harvesting.class,
|
||||
HeadquarterCreate.class,
|
||||
Heal.class,
|
||||
HealOverTime.class,
|
||||
HealPercent.class,
|
||||
Hide.class,
|
||||
NoTarget.class,
|
||||
HpByLevel.class,
|
||||
HpCpHeal.class,
|
||||
HpDrain.class,
|
||||
IgnoreDeath.class,
|
||||
ImmobileBuff.class,
|
||||
ImmobilePetBuff.class,
|
||||
JumpToFriend.class,
|
||||
KnockBack.class,
|
||||
KnockDown.class,
|
||||
Lethal.class,
|
||||
Lucky.class,
|
||||
MagicalAttack.class,
|
||||
MagicalAttackByAbnormal.class,
|
||||
MagicalAttackMp.class,
|
||||
MagicalSoulAttack.class,
|
||||
ManaDamOverTime.class,
|
||||
ManaHeal.class,
|
||||
ManaHealByLevel.class,
|
||||
ManaHealOverTime.class,
|
||||
ManaHealPercent.class,
|
||||
MarkRetriever.class,
|
||||
MaxCp.class,
|
||||
MaxHp.class,
|
||||
MpConsumePerLevel.class,
|
||||
Mute.class,
|
||||
NoblesseBless.class,
|
||||
OpenChest.class,
|
||||
Unsummon.class,
|
||||
OpenCommonRecipeBook.class,
|
||||
OpenDoor.class,
|
||||
OpenDwarfRecipeBook.class,
|
||||
Paralyze.class,
|
||||
Passive.class,
|
||||
PhysicalAttack.class,
|
||||
PhysicalAttackHpLink.class,
|
||||
PhysicalAttackMute.class,
|
||||
PhysicalMute.class,
|
||||
PhysicalSoulAttack.class,
|
||||
Pumping.class,
|
||||
ProtectionBlessing.class,
|
||||
RandomizeHate.class,
|
||||
RebalanceHP.class,
|
||||
RecoverVitalityInPeaceZone.class,
|
||||
Recovery.class,
|
||||
Reeling.class,
|
||||
RefuelAirship.class,
|
||||
Relax.class,
|
||||
RemoteControl.class,
|
||||
RemoveArmor.class,
|
||||
RemoveTarget.class,
|
||||
ResistSkill.class,
|
||||
Restoration.class,
|
||||
RestorationRandom.class,
|
||||
Resurrection.class,
|
||||
ResurrectionSpecial.class,
|
||||
RewardItemOnExit.class,
|
||||
Root.class,
|
||||
RunAway.class,
|
||||
ServitorShare.class,
|
||||
SetSkill.class,
|
||||
ShiftTarget.class,
|
||||
ShilensBreath.class,
|
||||
SilentMove.class,
|
||||
SingleTarget.class,
|
||||
SkillTurning.class,
|
||||
Sleep.class,
|
||||
SoulBlow.class,
|
||||
SoulEating.class,
|
||||
Sow.class,
|
||||
Spoil.class,
|
||||
StaticDamage.class,
|
||||
StealAbnormal.class,
|
||||
Stun.class,
|
||||
Summon.class,
|
||||
SummonAgathion.class,
|
||||
SummonCubic.class,
|
||||
SummonDebuff.class,
|
||||
SummonNpc.class,
|
||||
SummonPet.class,
|
||||
SummonTrap.class,
|
||||
Sweeper.class,
|
||||
TakeCastle.class,
|
||||
TakeCastleStart.class,
|
||||
TakeFort.class,
|
||||
TakeFortStart.class,
|
||||
TalismanSlot.class,
|
||||
TargetCancel.class,
|
||||
TargetMe.class,
|
||||
TargetMeProbability.class,
|
||||
Teleport.class,
|
||||
TeleportToTarget.class,
|
||||
ThrowHorizontal.class,
|
||||
ThrowUp.class,
|
||||
TransferDamage.class,
|
||||
TransferHate.class,
|
||||
Transformation.class,
|
||||
TrapDetect.class,
|
||||
TrapRemove.class,
|
||||
TriggerForce.class,
|
||||
TriggerSkillByAttack.class,
|
||||
TriggerSkillByAvoid.class,
|
||||
TriggerSkillByDamage.class,
|
||||
TriggerSkillBySkill.class,
|
||||
UnsummonAgathion.class,
|
||||
VitalityPointUp.class,
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for (Class<?> c : EFFECTS)
|
||||
{
|
||||
if (c == null)
|
||||
{
|
||||
continue; // Disabled handler
|
||||
}
|
||||
EffectHandler.getInstance().registerHandler((Class<? extends AbstractEffect>) c);
|
||||
}
|
||||
|
||||
// And lets try get size
|
||||
try
|
||||
{
|
||||
_log.log(Level.INFO, EffectMasterHandler.class.getSimpleName() + ": Loaded " + EffectHandler.getInstance().size() + " effect handlers.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed invoking size method for handler: " + EffectMasterHandler.class.getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.EffectHandler;
|
||||
|
||||
import handlers.effecthandlers.*;
|
||||
|
||||
/**
|
||||
* Effect Master handler.
|
||||
* @author NosBit
|
||||
*/
|
||||
public final class EffectMasterHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(EffectMasterHandler.class.getName());
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
EffectHandler.getInstance().registerHandler("AbnormalShield", AbnormalShield::new);
|
||||
EffectHandler.getInstance().registerHandler("AbnormalTimeChange", AbnormalTimeChange::new);
|
||||
EffectHandler.getInstance().registerHandler("AbsorbDamage", AbsorbDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("Accuracy", Accuracy::new);
|
||||
EffectHandler.getInstance().registerHandler("AddHate", AddHate::new);
|
||||
EffectHandler.getInstance().registerHandler("AddTeleportBookmarkSlot", AddTeleportBookmarkSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("AreaDamage", AreaDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("AttackAttribute", AttackAttribute::new);
|
||||
EffectHandler.getInstance().registerHandler("AttackBehind", AttackBehind::new);
|
||||
EffectHandler.getInstance().registerHandler("AttackTrait", AttackTrait::new);
|
||||
EffectHandler.getInstance().registerHandler("Backstab", Backstab::new);
|
||||
EffectHandler.getInstance().registerHandler("Betray", Betray::new);
|
||||
EffectHandler.getInstance().registerHandler("Blink", Blink::new);
|
||||
EffectHandler.getInstance().registerHandler("BlinkSwap", BlinkSwap::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockAbnormalSlot", BlockAbnormalSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockAction", BlockAction::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockActions", BlockActions::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockChat", BlockChat::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockControl", BlockControl::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockEscape", BlockEscape::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockMove", BlockMove::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockParty", BlockParty::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockResurrection", BlockResurrection::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockSkill", BlockSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("BlockTarget", BlockTarget::new);
|
||||
EffectHandler.getInstance().registerHandler("Bluff", Bluff::new);
|
||||
EffectHandler.getInstance().registerHandler("Breath", Breath::new);
|
||||
EffectHandler.getInstance().registerHandler("BuffBlock", BuffBlock::new);
|
||||
EffectHandler.getInstance().registerHandler("CallParty", CallParty::new);
|
||||
EffectHandler.getInstance().registerHandler("CallPc", CallPc::new);
|
||||
EffectHandler.getInstance().registerHandler("CallSkill", CallSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("CallSkillOnActionTime", CallSkillOnActionTime::new);
|
||||
EffectHandler.getInstance().registerHandler("CallTargetParty", CallTargetParty::new);
|
||||
EffectHandler.getInstance().registerHandler("CheapShot", CheapShot::new);
|
||||
EffectHandler.getInstance().registerHandler("ChameleonRest", ChameleonRest::new);
|
||||
EffectHandler.getInstance().registerHandler("ChangeBody", ChangeBody::new);
|
||||
EffectHandler.getInstance().registerHandler("ChangeFace", ChangeFace::new);
|
||||
EffectHandler.getInstance().registerHandler("ChangeFishingMastery", ChangeFishingMastery::new);
|
||||
EffectHandler.getInstance().registerHandler("ChangeHairColor", ChangeHairColor::new);
|
||||
EffectHandler.getInstance().registerHandler("ChangeHairStyle", ChangeHairStyle::new);
|
||||
EffectHandler.getInstance().registerHandler("ClassChange", ClassChange::new);
|
||||
EffectHandler.getInstance().registerHandler("Confuse", Confuse::new);
|
||||
EffectHandler.getInstance().registerHandler("ConsumeBody", ConsumeBody::new);
|
||||
EffectHandler.getInstance().registerHandler("ConvertItem", ConvertItem::new);
|
||||
EffectHandler.getInstance().registerHandler("CounterPhysicalSkill", CounterPhysicalSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("Cp", Cp::new);
|
||||
EffectHandler.getInstance().registerHandler("CpHeal", CpHeal::new);
|
||||
EffectHandler.getInstance().registerHandler("CpHealOverTime", CpHealOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("CpHealPercent", CpHealPercent::new);
|
||||
EffectHandler.getInstance().registerHandler("CpRegen", CpRegen::new);
|
||||
EffectHandler.getInstance().registerHandler("CreateItemRandom", CreateItemRandom::new);
|
||||
EffectHandler.getInstance().registerHandler("CriticalDamage", CriticalDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("CriticalDamagePosition", CriticalDamagePosition::new);
|
||||
EffectHandler.getInstance().registerHandler("CriticalRate", CriticalRate::new);
|
||||
EffectHandler.getInstance().registerHandler("CriticalRatePositionBonus", CriticalRatePositionBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("CrystalGradeModify", CrystalGradeModify::new);
|
||||
EffectHandler.getInstance().registerHandler("CubicMastery", CubicMastery::new);
|
||||
EffectHandler.getInstance().registerHandler("DamageBlock", DamageBlock::new);
|
||||
EffectHandler.getInstance().registerHandler("DamageShield", DamageShield::new);
|
||||
EffectHandler.getInstance().registerHandler("DamageShieldResist", DamageShieldResist::new);
|
||||
EffectHandler.getInstance().registerHandler("DamOverTime", DamOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("DamOverTimePercent", DamOverTimePercent::new);
|
||||
EffectHandler.getInstance().registerHandler("DeathLink", DeathLink::new);
|
||||
EffectHandler.getInstance().registerHandler("DebuffBlock", DebuffBlock::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceAttribute", DefenceAttribute::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceCriticalDamage", DefenceCriticalDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceCriticalRate", DefenceCriticalRate::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceMagicCriticalDamage", DefenceMagicCriticalDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceMagicCriticalRate", DefenceMagicCriticalRate::new);
|
||||
EffectHandler.getInstance().registerHandler("DefenceTrait", DefenceTrait::new);
|
||||
EffectHandler.getInstance().registerHandler("DeleteHate", DeleteHate::new);
|
||||
EffectHandler.getInstance().registerHandler("DeleteHateOfMe", DeleteHateOfMe::new);
|
||||
EffectHandler.getInstance().registerHandler("DeleteTopAgro", DeleteTopAgro::new);
|
||||
EffectHandler.getInstance().registerHandler("DetectHiddenObjects", DetectHiddenObjects::new);
|
||||
EffectHandler.getInstance().registerHandler("Detection", Detection::new);
|
||||
EffectHandler.getInstance().registerHandler("DisableTargeting", DisableTargeting::new);
|
||||
EffectHandler.getInstance().registerHandler("Disarm", Disarm::new);
|
||||
EffectHandler.getInstance().registerHandler("Disarmor", Disarmor::new);
|
||||
EffectHandler.getInstance().registerHandler("DispelAll", DispelAll::new);
|
||||
EffectHandler.getInstance().registerHandler("DispelByCategory", DispelByCategory::new);
|
||||
EffectHandler.getInstance().registerHandler("DispelBySlot", DispelBySlot::new);
|
||||
EffectHandler.getInstance().registerHandler("DispelBySlotMyself", DispelBySlotMyself::new);
|
||||
EffectHandler.getInstance().registerHandler("DispelBySlotProbability", DispelBySlotProbability::new);
|
||||
EffectHandler.getInstance().registerHandler("DoubleCast", DoubleCast::new);
|
||||
EffectHandler.getInstance().registerHandler("EnableCloak", EnableCloak::new);
|
||||
EffectHandler.getInstance().registerHandler("EnemyCharge", EnemyCharge::new);
|
||||
EffectHandler.getInstance().registerHandler("EnergyAttack", EnergyAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("EnlargeAbnormalSlot", EnlargeAbnormalSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("EnlargeSlot", EnlargeSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("Escape", Escape::new);
|
||||
EffectHandler.getInstance().registerHandler("ExpModify", ExpModify::new);
|
||||
EffectHandler.getInstance().registerHandler("Faceoff", Faceoff::new);
|
||||
EffectHandler.getInstance().registerHandler("FakeDeath", FakeDeath::new);
|
||||
EffectHandler.getInstance().registerHandler("FatalBlow", FatalBlow::new);
|
||||
EffectHandler.getInstance().registerHandler("FatalBlowRate", FatalBlowRate::new);
|
||||
EffectHandler.getInstance().registerHandler("Fear", Fear::new);
|
||||
EffectHandler.getInstance().registerHandler("Feed", Feed::new);
|
||||
EffectHandler.getInstance().registerHandler("Flag", Flag::new);
|
||||
EffectHandler.getInstance().registerHandler("FlyMove", FlyMove::new);
|
||||
EffectHandler.getInstance().registerHandler("FocusEnergy", FocusEnergy::new);
|
||||
EffectHandler.getInstance().registerHandler("FocusMomentum", FocusMomentum::new);
|
||||
EffectHandler.getInstance().registerHandler("FocusMaxMomentum", FocusMaxMomentum::new);
|
||||
EffectHandler.getInstance().registerHandler("FocusSouls", FocusSouls::new);
|
||||
EffectHandler.getInstance().registerHandler("GetAgro", GetAgro::new);
|
||||
EffectHandler.getInstance().registerHandler("GetDamageLimit", GetDamageLimit::new);
|
||||
EffectHandler.getInstance().registerHandler("GetMomentum", GetMomentum::new);
|
||||
EffectHandler.getInstance().registerHandler("GiveRecommendation", GiveRecommendation::new);
|
||||
EffectHandler.getInstance().registerHandler("GiveSp", GiveSp::new);
|
||||
EffectHandler.getInstance().registerHandler("Grow", Grow::new);
|
||||
EffectHandler.getInstance().registerHandler("HairAccessorySet", HairAccessorySet::new);
|
||||
EffectHandler.getInstance().registerHandler("Harvesting", Harvesting::new);
|
||||
EffectHandler.getInstance().registerHandler("HateAttack", HateAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("HeadquarterCreate", HeadquarterCreate::new);
|
||||
EffectHandler.getInstance().registerHandler("Heal", Heal::new);
|
||||
EffectHandler.getInstance().registerHandler("HealEffect", HealEffect::new);
|
||||
EffectHandler.getInstance().registerHandler("HealOverTime", HealOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("HealPercent", HealPercent::new);
|
||||
EffectHandler.getInstance().registerHandler("Hide", Hide::new);
|
||||
EffectHandler.getInstance().registerHandler("HitNumber", HitNumber::new);
|
||||
EffectHandler.getInstance().registerHandler("Hp", Hp::new);
|
||||
EffectHandler.getInstance().registerHandler("HpByLevel", HpByLevel::new);
|
||||
EffectHandler.getInstance().registerHandler("HpCpHeal", HpCpHeal::new);
|
||||
EffectHandler.getInstance().registerHandler("HpCpHealCritical", HpCpHealCritical::new);
|
||||
EffectHandler.getInstance().registerHandler("HpDrain", HpDrain::new);
|
||||
EffectHandler.getInstance().registerHandler("HpRegen", HpRegen::new);
|
||||
EffectHandler.getInstance().registerHandler("HpToOwner", HpToOwner::new);
|
||||
EffectHandler.getInstance().registerHandler("IgnoreDeath", IgnoreDeath::new);
|
||||
EffectHandler.getInstance().registerHandler("ImmobilePetBuff", ImmobilePetBuff::new);
|
||||
EffectHandler.getInstance().registerHandler("InstantKillResist", InstantKillResist::new);
|
||||
EffectHandler.getInstance().registerHandler("KarmaCount", KarmaCount::new);
|
||||
EffectHandler.getInstance().registerHandler("KnockBack", KnockBack::new);
|
||||
EffectHandler.getInstance().registerHandler("Lethal", Lethal::new);
|
||||
EffectHandler.getInstance().registerHandler("LimitCp", LimitCp::new);
|
||||
EffectHandler.getInstance().registerHandler("LimitHp", LimitHp::new);
|
||||
EffectHandler.getInstance().registerHandler("LimitMp", LimitMp::new);
|
||||
EffectHandler.getInstance().registerHandler("Lucky", Lucky::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicAccuracy", MagicAccuracy::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAbnormalDispelAttack", MagicalAbnormalDispelAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAbnormalResist", MagicalAbnormalResist::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttack", MagicalAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttackByAbnormal", MagicalAttackByAbnormal::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttackByAbnormalSlot", MagicalAttackByAbnormalSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttackMp", MagicalAttackMp::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttackRange", MagicalAttackRange::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalAttackSpeed", MagicalAttackSpeed::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalDamOverTime", MagicalDamOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalDefence", MagicalDefence::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalEvasion", MagicalEvasion::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicalSoulAttack", MagicalSoulAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicCriticalDamage", MagicCriticalDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicCriticalRate", MagicCriticalRate::new);
|
||||
EffectHandler.getInstance().registerHandler("MagicMpCost", MagicMpCost::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaCharge", ManaCharge::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaDamOverTime", ManaDamOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaHeal", ManaHeal::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaHealByLevel", ManaHealByLevel::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaHealOverTime", ManaHealOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("ManaHealPercent", ManaHealPercent::new);
|
||||
EffectHandler.getInstance().registerHandler("MAtk", MAtk::new);
|
||||
EffectHandler.getInstance().registerHandler("MaxCp", MaxCp::new);
|
||||
EffectHandler.getInstance().registerHandler("MaxHp", MaxHp::new);
|
||||
EffectHandler.getInstance().registerHandler("MaxMp", MaxMp::new);
|
||||
EffectHandler.getInstance().registerHandler("ModifyVital", ModifyVital::new);
|
||||
EffectHandler.getInstance().registerHandler("Mp", Mp::new);
|
||||
EffectHandler.getInstance().registerHandler("MpConsumePerLevel", MpConsumePerLevel::new);
|
||||
EffectHandler.getInstance().registerHandler("MpRegen", MpRegen::new);
|
||||
EffectHandler.getInstance().registerHandler("MpShield", MpShield::new);
|
||||
EffectHandler.getInstance().registerHandler("MpVampiricAttack", MpVampiricAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("Mute", Mute::new);
|
||||
EffectHandler.getInstance().registerHandler("NoblesseBless", NoblesseBless::new);
|
||||
EffectHandler.getInstance().registerHandler("OpenChest", OpenChest::new);
|
||||
EffectHandler.getInstance().registerHandler("OpenCommonRecipeBook", OpenCommonRecipeBook::new);
|
||||
EffectHandler.getInstance().registerHandler("OpenDoor", OpenDoor::new);
|
||||
EffectHandler.getInstance().registerHandler("OpenDwarfRecipeBook", OpenDwarfRecipeBook::new);
|
||||
EffectHandler.getInstance().registerHandler("Passive", Passive::new);
|
||||
EffectHandler.getInstance().registerHandler("PAtk", PAtk::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAbnormalResist", PhysicalAbnormalResist::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttack", PhysicalAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackHpLink", PhysicalAttackHpLink::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackMute", PhysicalAttackMute::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackRange", PhysicalAttackRange::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackSaveHp", PhysicalAttackSaveHp::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackSpeed", PhysicalAttackSpeed::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalAttackWeaponBonus", PhysicalAttackWeaponBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalDefence", PhysicalDefence::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalEvasion", PhysicalEvasion::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalMute", PhysicalMute::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalShieldAngleAll", PhysicalShieldAngleAll::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalSkillPower", PhysicalSkillPower::new);
|
||||
EffectHandler.getInstance().registerHandler("PhysicalSoulAttack", PhysicalSoulAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("PkCount", PkCount::new);
|
||||
EffectHandler.getInstance().registerHandler("Plunder", Plunder::new);
|
||||
EffectHandler.getInstance().registerHandler("ProtectionBlessing", ProtectionBlessing::new);
|
||||
EffectHandler.getInstance().registerHandler("ProtectDeathPenalty", ProtectDeathPenalty::new);
|
||||
EffectHandler.getInstance().registerHandler("PullBack", PullBack::new);
|
||||
EffectHandler.getInstance().registerHandler("PveMagicalSkillDamageBonus", PveMagicalSkillDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PveMagicalSkillDefenceBonus", PveMagicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvePhysicalAttackDamageBonus", PvePhysicalAttackDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvePhysicalAttackDefenceBonus", PvePhysicalAttackDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvePhysicalSkillDamageBonus", PvePhysicalSkillDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvePhysicalSkillDefenceBonus", PvePhysicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PveRaidMagicalSkillDefenceBonus", PveRaidMagicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PveRaidPhysicalAttackDefenceBonus", PveRaidPhysicalAttackDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PveRaidPhysicalSkillDefenceBonus", PveRaidPhysicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpMagicalSkillDamageBonus", PvpMagicalSkillDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpMagicalSkillDefenceBonus", PvpMagicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpPhysicalAttackDamageBonus", PvpPhysicalAttackDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpPhysicalAttackDefenceBonus", PvpPhysicalAttackDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpPhysicalSkillDamageBonus", PvpPhysicalSkillDamageBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("PvpPhysicalSkillDefenceBonus", PvpPhysicalSkillDefenceBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("RandomizeHate", RandomizeHate::new);
|
||||
EffectHandler.getInstance().registerHandler("RealDamage", RealDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("RebalanceHP", RebalanceHP::new);
|
||||
EffectHandler.getInstance().registerHandler("Recovery", Recovery::new);
|
||||
EffectHandler.getInstance().registerHandler("ReduceCancel", ReduceCancel::new);
|
||||
EffectHandler.getInstance().registerHandler("ReduceDropPenalty", ReduceDropPenalty::new);
|
||||
EffectHandler.getInstance().registerHandler("ReflectMagic", ReflectMagic::new);
|
||||
EffectHandler.getInstance().registerHandler("ReflectSkill", ReflectSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("RefuelAirship", RefuelAirship::new);
|
||||
EffectHandler.getInstance().registerHandler("Relax", Relax::new);
|
||||
EffectHandler.getInstance().registerHandler("ResistAbnormalByCategory", ResistAbnormalByCategory::new);
|
||||
EffectHandler.getInstance().registerHandler("ResistDDMagic", ResistDDMagic::new);
|
||||
EffectHandler.getInstance().registerHandler("ResistDispelByCategory", ResistDispelByCategory::new);
|
||||
EffectHandler.getInstance().registerHandler("ResistSkill", ResistSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("Restoration", Restoration::new);
|
||||
EffectHandler.getInstance().registerHandler("RestorationRandom", RestorationRandom::new);
|
||||
EffectHandler.getInstance().registerHandler("Resurrection", Resurrection::new);
|
||||
EffectHandler.getInstance().registerHandler("ResurrectionSpecial", ResurrectionSpecial::new);
|
||||
EffectHandler.getInstance().registerHandler("Reuse", Reuse::new);
|
||||
EffectHandler.getInstance().registerHandler("Root", Root::new);
|
||||
EffectHandler.getInstance().registerHandler("SafeFallHeight", SafeFallHeight::new);
|
||||
EffectHandler.getInstance().registerHandler("SendSystemMessageToClan", SendSystemMessageToClan::new);
|
||||
EffectHandler.getInstance().registerHandler("ServitorShare", ServitorShare::new);
|
||||
EffectHandler.getInstance().registerHandler("SetHp", SetHp::new);
|
||||
EffectHandler.getInstance().registerHandler("SetSkill", SetSkill::new);
|
||||
EffectHandler.getInstance().registerHandler("ShieldDefence", ShieldDefence::new);
|
||||
EffectHandler.getInstance().registerHandler("ShieldDefenceRate", ShieldDefenceRate::new);
|
||||
EffectHandler.getInstance().registerHandler("SilentMove", SilentMove::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillCritical", SkillCritical::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillCriticalDamage", SkillCriticalDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillCriticalProbability", SkillCriticalProbability::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillEvasion", SkillEvasion::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillTurning", SkillTurning::new);
|
||||
EffectHandler.getInstance().registerHandler("SkillTurningOverTime", SkillTurningOverTime::new);
|
||||
EffectHandler.getInstance().registerHandler("SoulBlow", SoulBlow::new);
|
||||
EffectHandler.getInstance().registerHandler("SoulEating", SoulEating::new);
|
||||
EffectHandler.getInstance().registerHandler("Sow", Sow::new);
|
||||
EffectHandler.getInstance().registerHandler("Speed", Speed::new);
|
||||
EffectHandler.getInstance().registerHandler("SphericBarrier", SphericBarrier::new);
|
||||
EffectHandler.getInstance().registerHandler("SpModify", SpModify::new);
|
||||
EffectHandler.getInstance().registerHandler("Spoil", Spoil::new);
|
||||
EffectHandler.getInstance().registerHandler("StatBonusSkillCritical", StatBonusSkillCritical::new);
|
||||
EffectHandler.getInstance().registerHandler("StatBonusSpeed", StatBonusSpeed::new);
|
||||
EffectHandler.getInstance().registerHandler("StatByMoveType", StatByMoveType::new);
|
||||
EffectHandler.getInstance().registerHandler("StatUp", StatUp::new);
|
||||
EffectHandler.getInstance().registerHandler("StealAbnormal", StealAbnormal::new);
|
||||
EffectHandler.getInstance().registerHandler("Summon", Summon::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonAgathion", SummonAgathion::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonCubic", SummonCubic::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonHallucination", SummonHallucination::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonMulti", SummonMulti::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonNpc", SummonNpc::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonPet", SummonPet::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonPoints", SummonPoints::new);
|
||||
EffectHandler.getInstance().registerHandler("SummonTrap", SummonTrap::new);
|
||||
EffectHandler.getInstance().registerHandler("Sweeper", Sweeper::new);
|
||||
EffectHandler.getInstance().registerHandler("Synergy", Synergy::new);
|
||||
EffectHandler.getInstance().registerHandler("TakeCastle", TakeCastle::new);
|
||||
EffectHandler.getInstance().registerHandler("TakeCastleStart", TakeCastleStart::new);
|
||||
EffectHandler.getInstance().registerHandler("TakeFort", TakeFort::new);
|
||||
EffectHandler.getInstance().registerHandler("TakeFortStart", TakeFortStart::new);
|
||||
EffectHandler.getInstance().registerHandler("TalismanSlot", TalismanSlot::new);
|
||||
EffectHandler.getInstance().registerHandler("TargetCancel", TargetCancel::new);
|
||||
EffectHandler.getInstance().registerHandler("TargetMe", TargetMe::new);
|
||||
EffectHandler.getInstance().registerHandler("TargetMeProbability", TargetMeProbability::new);
|
||||
EffectHandler.getInstance().registerHandler("Teleport", Teleport::new);
|
||||
EffectHandler.getInstance().registerHandler("TeleportToNpc", TeleportToNpc::new);
|
||||
EffectHandler.getInstance().registerHandler("TeleportToSummon", TeleportToSummon::new);
|
||||
EffectHandler.getInstance().registerHandler("TeleportToTarget", TeleportToTarget::new);
|
||||
EffectHandler.getInstance().registerHandler("ThrowUp", ThrowUp::new);
|
||||
EffectHandler.getInstance().registerHandler("TransferDamageToPlayer", TransferDamageToPlayer::new);
|
||||
EffectHandler.getInstance().registerHandler("TransferDamageToSummon", TransferDamageToSummon::new);
|
||||
EffectHandler.getInstance().registerHandler("TransferHate", TransferHate::new);
|
||||
EffectHandler.getInstance().registerHandler("Transformation", Transformation::new);
|
||||
EffectHandler.getInstance().registerHandler("TrapDetect", TrapDetect::new);
|
||||
EffectHandler.getInstance().registerHandler("TrapRemove", TrapRemove::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByAttack", TriggerSkillByAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByAvoid", TriggerSkillByAvoid::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByDamage", TriggerSkillByDamage::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByDeathBlow", TriggerSkillByDeathBlow::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByKill", TriggerSkillByKill::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillByMagicType", TriggerSkillByMagicType::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillBySkill", TriggerSkillBySkill::new);
|
||||
EffectHandler.getInstance().registerHandler("TriggerSkillBySkillAttack", TriggerSkillBySkillAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("TwoHandedBluntBonus", TwoHandedBluntBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("TwoHandedSwordBonus", TwoHandedSwordBonus::new);
|
||||
EffectHandler.getInstance().registerHandler("Unsummon", Unsummon::new);
|
||||
EffectHandler.getInstance().registerHandler("UnsummonAgathion", UnsummonAgathion::new);
|
||||
EffectHandler.getInstance().registerHandler("UnsummonServitors", UnsummonServitors::new);
|
||||
EffectHandler.getInstance().registerHandler("Untargetable", Untargetable::new);
|
||||
EffectHandler.getInstance().registerHandler("VampiricAttack", VampiricAttack::new);
|
||||
EffectHandler.getInstance().registerHandler("VampiricDefence", VampiricDefence::new);
|
||||
EffectHandler.getInstance().registerHandler("VitalityPointsRate", VitalityPointsRate::new);
|
||||
EffectHandler.getInstance().registerHandler("VitalityPointUp", VitalityPointUp::new);
|
||||
EffectHandler.getInstance().registerHandler("WeightLimit", WeightLimit::new);
|
||||
EffectHandler.getInstance().registerHandler("WeightPenalty", WeightPenalty::new);
|
||||
LOGGER.info(EffectMasterHandler.class.getSimpleName() + ": Loaded " + EffectHandler.getInstance().size() + " effect handlers.");
|
||||
}
|
||||
}
|
||||
|
||||
1303
trunk/dist/game/data/scripts/handlers/MasterHandler.java
vendored
1303
trunk/dist/game/data/scripts/handlers/MasterHandler.java
vendored
File diff suppressed because it is too large
Load Diff
51
trunk/dist/game/data/scripts/handlers/OneDayRewardMasterHandler.java
vendored
Normal file
51
trunk/dist/game/data/scripts/handlers/OneDayRewardMasterHandler.java
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.OneDayRewardHandler;
|
||||
|
||||
import handlers.onedayrewardshandlers.BossOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.CeremonyOfChaosOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.FishingOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.LevelOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.OlympiadOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.QuestOneDayRewardHandler;
|
||||
import handlers.onedayrewardshandlers.SiegeOneDayRewardHandler;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class OneDayRewardMasterHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(OneDayRewardMasterHandler.class.getName());
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
OneDayRewardHandler.getInstance().registerHandler("level", LevelOneDayRewardHandler::new);
|
||||
// OneDayRewardHandler.getInstance().registerHandler("loginAllWeek", LoginAllWeekOneDayRewardHandler::new);
|
||||
// OneDayRewardHandler.getInstance().registerHandler("loginAllMonth", LoginAllWeekOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("quest", QuestOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("olympiad", OlympiadOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("siege", SiegeOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("boss", BossOneDayRewardHandler::new);
|
||||
OneDayRewardHandler.getInstance().registerHandler("fishing", FishingOneDayRewardHandler::new);
|
||||
LOGGER.info(OneDayRewardMasterHandler.class.getSimpleName() + ": Loaded " + OneDayRewardHandler.getInstance().size() + " handlers.");
|
||||
}
|
||||
}
|
||||
135
trunk/dist/game/data/scripts/handlers/SkillConditionMasterHandler.java
vendored
Normal file
135
trunk/dist/game/data/scripts/handlers/SkillConditionMasterHandler.java
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.SkillConditionHandler;
|
||||
|
||||
import handlers.skillconditionhandlers.*;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class SkillConditionMasterHandler
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
SkillConditionHandler.getInstance().registerHandler("EquipWeapon", EquipWeaponSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("EquipArmor", EquipArmorSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("EquipShield", EquipShieldSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("PossessHolything", PossessHolythingSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSkillAcquire", OpSkillAcquireSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("TargetRace", TargetRaceSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("TargetMyParty", TargetMyPartySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanSummon", CanSummonSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("BuildCamp", BuildCampSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("NotInUnderwater", NotInUnderwaterSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNotOlympiad", OpNotOlympiadSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpUnlock", OpUnlockSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpEnergyMax", OpEnergyMaxSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("RemainHpPer", RemainHpPerSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpResurrection", OpResurrectionSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("ConsumeBody", ConsumeBodySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSweeper", OpSweeperSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanSummonCubic", CanSummonCubicSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCanEscape", OpCanEscapeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNotTerritory", OpNotTerritorySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanSummonSiegeGolem", CanSummonSiegeGolemSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("RemainMpPer", RemainMpPerSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("Op2hWeapon", Op2hWeaponSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpEncumbered", OpEncumberedSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpFishingCast", OpFishingCastSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpFishingPumping", OpFishingPumpingSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpFishingReeling", OpFishingReelingSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("RemainCpPer", RemainCpPerSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanUseInBattlefield", CanUseInBattlefieldSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCallPc", OpCallPcSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("EnergySaved", EnergySavedSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpExistNpc", OpExistNpcSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckCastRange", OpCheckCastRangeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSoulMax", OpSoulMaxSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpBlink", OpBlinkSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("SoulSaved", SoulSavedSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckAbnormal", OpCheckAbnormalSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckClass", OpCheckClassSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanTransform", CanTransformSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpChangeWeapon", OpChangeWeaponSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanUntransform", CanUntransformSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("BuildAdvanceBase", BuildAdvanceBaseSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanTransformInDominion", CanTransformInDominionSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetNpc", OpTargetNpcSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpHaveSummon", OpHaveSummonSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNotInstantzone", OpNotInstantzoneSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCanNotUseAirship", OpCanNotUseAirshipSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("TargetItemCrystalType", TargetItemCrystalTypeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpUseFirecracker", OpUseFirecrackerSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanSummonPet", CanSummonPetSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CannotUseInTransform", CannotUseInTransformSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CheckSex", CheckSexSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CheckLevel", CheckLevelSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanChangeVitalItemCount", CanChangeVitalItemCountSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpHome", OpHomeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCompanion", OpCompanionSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpAlignment", OpAlignmentSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTerritory", OpTerritorySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckResidence", OpCheckResidenceSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanEnchantAttribute", CanEnchantAttributeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSkill", OpSkillSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckClassList", OpCheckClassListSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanRestoreVitalPoint", CanRestoreVitalPointSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanUseVitalityConsumeItem", CanUseVitalityConsumeItemSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanBookmarkAddSlot", CanBookmarkAddSlotSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanAddMaxEntranceInzone", CanAddMaxEntranceInzoneSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanRefuelAirship", CanRefuelAirshipSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckPcbangPoint", OpCheckPcbangPointSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpEnchantRange", OpEnchantRangeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNeedAgathion", OpNeedAgathionSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckAccountType", OpCheckAccountTypeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpHaveSummonedNpc", OpHaveSummonedNpcSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("TargetMyMentee", TargetMyMenteeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpPeacezone", OpPeacezoneSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpPkcount", OpPkcountSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNotCursed", OpNotCursedSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("TargetMyPledge", TargetMyPledgeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetPc", OpTargetPcSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpMainjob", OpMainjobSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckSkill", OpCheckSkillSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpRestartPoint", OpRestartPointSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpNeedSummonOrPet", OpNeedSummonOrPetSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpUsePraseed", OpUsePraseedSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanUseInDragonLair", CanUseInDragonLairSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetWeaponAttackType", OpTargetWeaponAttackTypeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetArmorType", OpTargetArmorTypeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetAllItemType", OpTargetAllItemTypeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanMountForEvent", CanMountForEventSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpEquipItem", OpEquipItemSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpInstantzone", OpInstantzoneSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSubjob", OpSubjobSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpAgathionEnergy", OpAgathionEnergySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpPledge", OpPledgeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSocialClass", OpSocialClassSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpSiegeHammer", OpSiegeHammerSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpWyvern", OpWyvernSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanUseSwoopCannon", CanUseSwoopCannonSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckCrtEffect", OpCheckCrtEffectSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpInSiegeTime", OpInSiegeTimeSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCannotUseTargetWithPrivateStore", OpCannotUseTargetWithPrivateStoreSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckOnGoingEventCampaign", OpCheckOnGoingEventCampaignSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("CanSummonMulti", CanSummonMultiSkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpTargetMyPledgeAcademy", OpTargetMyPledgeAcademySkillCondition::new);
|
||||
SkillConditionHandler.getInstance().registerHandler("OpCheckFlag", OpCheckFlagSkillCondition::new);
|
||||
}
|
||||
}
|
||||
@@ -1,100 +1,102 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
|
||||
public class L2DoorInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (door.getClanHall() != null) && (activeChar.getClanId() == door.getClanHall().getOwnerId()))
|
||||
{
|
||||
if (!door.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else if (!door.getClanHall().isSiegableHall() || !((SiegableHall) door.getClanHall()).isInSiege())
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder(door));
|
||||
if (!door.getOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (((L2DoorInstance) target).getFort() != null) && (activeChar.getClan() == ((L2DoorInstance) target).getFort().getOwnerClan()) && ((L2DoorInstance) target).isOpenableBySkill() && !((L2DoorInstance) target).getFort().getSiege().isInProgress())
|
||||
{
|
||||
if (!((L2Character) target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
|
||||
if (!((L2DoorInstance) target).getOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
|
||||
public class L2DoorInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallByDoorId(door.getId());
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (clanHall != null) && (activeChar.getClanId() == clanHall.getOwnerId()))
|
||||
{
|
||||
if (!door.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder(door));
|
||||
if (!door.isOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (((L2DoorInstance) target).getFort() != null) && (activeChar.getClan() == ((L2DoorInstance) target).getFort().getOwnerClan()) && ((L2DoorInstance) target).isOpenableBySkill() && !((L2DoorInstance) target).getFort().getSiege().isInProgress())
|
||||
{
|
||||
if (!((L2Character) target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
|
||||
if (!((L2DoorInstance) target).isOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,59 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// this causes the validate position handler to do the pickup if the location is reached.
|
||||
// mercenary tickets can only be picked up by the castle owner.
|
||||
final int castleId = MercTicketManager.getInstance().getTicketCastleId(target.getId());
|
||||
|
||||
if ((castleId > 0) && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
|
||||
{
|
||||
if (activeChar.isInParty())
|
||||
{
|
||||
activeChar.sendMessage("You cannot pickup mercenaries while in a party.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Only the castle lord can pickup mercenaries.");
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
}
|
||||
else if (!activeChar.isFlying())
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final Castle castle = CastleManager.getInstance().getCastle(target);
|
||||
if ((castle != null) && (SiegeGuardManager.getInstance().getSiegeGuardByItem(castle.getResidenceId(), target.getId()) != null))
|
||||
{
|
||||
if ((activeChar.getClan() == null) || (castle.getOwnerId() != activeChar.getClanId()) || !activeChar.hasClanPrivilege(ClanPrivilege.CS_MERCENARIES))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_AUTHORITY_TO_CANCEL_MERCENARY_POSITIONING);
|
||||
activeChar.setTarget(target);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!activeChar.isFlying())
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
@@ -1,145 +1,150 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToPawn;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
public class L2NpcAction implements IActionHandler
|
||||
{
|
||||
/**
|
||||
* Manage actions when a player click on the L2Npc.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on first click on the L2Npc (Select it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the L2Npc as target of the L2PcInstance player (if necessary)</li>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li>
|
||||
* <li>If L2Npc is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2Npc HP bar</li>
|
||||
* <li>Send a Server->Client packet ValidateLocation to correct the L2Npc position and heading on the client</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on second click on the L2Npc (Attack it/Intercat with it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li>
|
||||
* <li>If L2Npc is autoAttackable, notify the L2PcInstance AI with AI_INTENTION_ATTACK (after a height verification)</li>
|
||||
* <li>If L2Npc is NOT autoAttackable, notify the L2PcInstance AI with AI_INTENTION_INTERACT (after a distance verification) and show message</li><BR>
|
||||
* <BR>
|
||||
* <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid that client wait an other packet</B></FONT><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action, AttackRequest</li><BR>
|
||||
* <BR>
|
||||
* @param activeChar The L2PcInstance that start an action on the L2Npc
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc) target).canTarget(activeChar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setLastFolkNPC((L2Npc) target);
|
||||
// Check if the L2PcInstance already target the L2Npc
|
||||
if (target != activeChar.getTarget())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
// Check if the activeChar is attackable (without a forced attack)
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
((L2Npc) target).getAI(); // wake up ai
|
||||
}
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if the activeChar is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !((L2Npc) target).isAlikeDead())
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, target));
|
||||
}
|
||||
}
|
||||
else if (!target.isAutoAttackable(activeChar))
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2Npc
|
||||
if (!((L2Npc) target).canInteract(activeChar))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
// Turn NPC to the player.
|
||||
activeChar.sendPacket(new MoveToPawn(activeChar, npc, 100));
|
||||
if (npc.hasRandomAnimation())
|
||||
{
|
||||
npc.onRandomAnimation(Rnd.get(8));
|
||||
}
|
||||
// Open a chat window on client with the text of the L2Npc
|
||||
if (npc.isEventMob())
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (npc.hasListener(EventType.ON_NPC_QUEST_START))
|
||||
{
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
}
|
||||
if (npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MoveToPawn;
|
||||
|
||||
public class L2NpcAction implements IActionHandler
|
||||
{
|
||||
/**
|
||||
* Manage actions when a player click on the L2Npc.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on first click on the L2Npc (Select it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the L2Npc as target of the L2PcInstance player (if necessary)</li>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li>
|
||||
* <li>If L2Npc is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2Npc HP bar</li>
|
||||
* <li>Send a Server->Client packet ValidateLocation to correct the L2Npc position and heading on the client</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on second click on the L2Npc (Attack it/Intercat with it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li>
|
||||
* <li>If L2Npc is autoAttackable, notify the L2PcInstance AI with AI_INTENTION_ATTACK (after a height verification)</li>
|
||||
* <li>If L2Npc is NOT autoAttackable, notify the L2PcInstance AI with AI_INTENTION_INTERACT (after a distance verification) and show message</li><BR>
|
||||
* <BR>
|
||||
* <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid that client wait an other packet</B></FONT><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action, AttackRequest</li><BR>
|
||||
* <BR>
|
||||
* @param activeChar The L2PcInstance that start an action on the L2Npc
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc) target).canTarget(activeChar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setLastFolkNPC((L2Npc) target);
|
||||
// Check if the L2PcInstance already target the L2Npc
|
||||
if (target != activeChar.getTarget())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
// Check if the activeChar is attackable (without a forced attack)
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
((L2Npc) target).getAI(); // wake up ai
|
||||
}
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if the activeChar is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !((L2Character) target).isAlikeDead())
|
||||
{
|
||||
// Check the height difference
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400) // this max heigth difference might need some tweaking
|
||||
{
|
||||
// Set the L2PcInstance Intention to AI_INTENTION_ATTACK
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
// activeChar.startAttack(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
else if (!target.isAutoAttackable(activeChar))
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2Npc
|
||||
if (!((L2Npc) target).canInteract(activeChar))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
// Turn NPC to the player.
|
||||
activeChar.sendPacket(new MoveToPawn(activeChar, npc, 100));
|
||||
if (npc.hasRandomAnimation())
|
||||
{
|
||||
npc.onRandomAnimation(Rnd.get(8));
|
||||
}
|
||||
// Open a chat window on client with the text of the L2Npc
|
||||
if (npc.getVariables().getBoolean("eventmob", false))
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (npc.hasListener(EventType.ON_NPC_QUEST_START))
|
||||
{
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
}
|
||||
if (npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
@@ -1,135 +1,122 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public class L2PcInstanceAction implements IActionHandler
|
||||
{
|
||||
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
|
||||
|
||||
/**
|
||||
* Manage actions when a player click on this L2PcInstance.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on first click on the L2PcInstance (Select it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the target of the player</li>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on second click on the L2PcInstance (Follow it/Attack it/Intercat with it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li>
|
||||
* <li>If target L2PcInstance has a Private Store, notify the player AI with AI_INTENTION_INTERACT</li>
|
||||
* <li>If target L2PcInstance is autoAttackable, notify the player AI with AI_INTENTION_ATTACK</li> <BR>
|
||||
* <BR>
|
||||
* <li>If target L2PcInstance is NOT autoAttackable, notify the player AI with AI_INTENTION_FOLLOW</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action, AttackRequest</li><BR>
|
||||
* <BR>
|
||||
* @param activeChar The player that start an action on target L2PcInstance
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// See description in TvTEvent.java
|
||||
if (!TvTEvent.onAction(activeChar, target.getObjectId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance is confused
|
||||
if (activeChar.isOutOfControl())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
final L2PcInstance player = target.getActingPlayer();
|
||||
// Check if this L2PcInstance has a Private Store
|
||||
if (player.getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, player);
|
||||
}
|
||||
// Check if this L2PcInstance is autoAttackable
|
||||
else if (player.isAutoAttackable(activeChar))
|
||||
{
|
||||
if ((player.isCursedWeaponEquipped() && (activeChar.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|
||||
|| (activeChar.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, player))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, player));
|
||||
}
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, player))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, GeoData.getInstance().moveCheck(activeChar, player));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
|
||||
public class L2PcInstanceAction implements IActionHandler
|
||||
{
|
||||
/**
|
||||
* Manage actions when a player click on this L2PcInstance.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on first click on the L2PcInstance (Select it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the target of the player</li>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on second click on the L2PcInstance (Follow it/Attack it/Intercat with it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the player (display the select window)</li>
|
||||
* <li>If target L2PcInstance has a Private Store, notify the player AI with AI_INTENTION_INTERACT</li>
|
||||
* <li>If target L2PcInstance is autoAttackable, notify the player AI with AI_INTENTION_ATTACK</li> <BR>
|
||||
* <BR>
|
||||
* <li>If target L2PcInstance is NOT autoAttackable, notify the player AI with AI_INTENTION_FOLLOW</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action, AttackRequest</li><BR>
|
||||
* <BR>
|
||||
* @param activeChar The player that start an action on target L2PcInstance
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance is confused
|
||||
if (activeChar.isControlBlocked())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if this L2PcInstance has a Private Store
|
||||
if (((L2PcInstance) target).getPrivateStoreType() != PrivateStoreType.NONE)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if this L2PcInstance is autoAttackable
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
// activeChar with lvl < 21 can't attack a cursed weapon holder
|
||||
// And a cursed weapon holder can't attack activeChars with lvl < 21
|
||||
if ((((L2PcInstance) target).isCursedWeaponEquipped() && (activeChar.getLevel() < 21)) || (activeChar.isCursedWeaponEquipped() && (((L2Character) target).getLevel() < 21)))
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +1,87 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final L2StaticObjectInstance staticObject = (L2StaticObjectInstance) target;
|
||||
if (staticObject.getType() < 0)
|
||||
{
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: " + staticObject.getId());
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != staticObject)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(staticObject);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(staticObject, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, staticObject);
|
||||
}
|
||||
else if (staticObject.getType() == 2)
|
||||
{
|
||||
final String filename = (staticObject.getId() == 24230101) ? "html/signboards/tomb_of_crystalgolem.htm" : "html/signboards/pvp_signboard.htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(staticObject.getObjectId());
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml("<html><body>Signboard is missing:<br>" + filename + "</body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (staticObject.getType() == 0)
|
||||
{
|
||||
activeChar.sendPacket(staticObject.getMap());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionhandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
final L2StaticObjectInstance staticObject = (L2StaticObjectInstance) target;
|
||||
if (staticObject.getType() < 0)
|
||||
{
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: " + staticObject.getId());
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != staticObject)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(staticObject);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(staticObject, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, staticObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (staticObject.getType() == 2)
|
||||
{
|
||||
final String filename = (staticObject.getId() == 24230101) ? "data/html/signboards/tomb_of_crystalgolem.htm" : "data/html/signboards/pvp_signboard.htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(staticObject.getObjectId());
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
html.setHtml("<html><body>Signboard is missing:<br>" + filename + "</body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (staticObject.getType() == 0)
|
||||
{
|
||||
activeChar.sendPacket(staticObject.getMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,78 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StaticObject;
|
||||
|
||||
public class L2DoorInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/doorinfo.htm");
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%hp%", String.valueOf((int) door.getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(door.getMaxHp()));
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%doorid%", String.valueOf(door.getId()));
|
||||
|
||||
html.replace("%minx%", String.valueOf(door.getX(0)));
|
||||
html.replace("%miny%", String.valueOf(door.getY(0)));
|
||||
html.replace("%minz%", String.valueOf(door.getZMin()));
|
||||
|
||||
html.replace("%maxx%", String.valueOf(door.getX(2)));
|
||||
html.replace("%maxy%", String.valueOf(door.getY(2)));
|
||||
html.replace("%maxz%", String.valueOf(door.getZMax()));
|
||||
html.replace("%unlock%", door.isOpenableBySkill() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.entity.Fort;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StaticObject;
|
||||
import com.l2jmobius.gameserver.util.HtmlUtil;
|
||||
|
||||
/**
|
||||
* This class manage shift + click on {@link L2DoorInstance}.
|
||||
* @author St3eT
|
||||
*/
|
||||
public class L2DoorInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
final L2DoorInstance door = (L2DoorInstance) target;
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallByDoorId(door.getId());
|
||||
final Fort fort = door.getFort();
|
||||
final Castle castle = door.getCastle();
|
||||
activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/doorinfo.htm");
|
||||
// Hp / MP
|
||||
html.replace("%hpGauge%", HtmlUtil.getHpGauge(250, (long) door.getCurrentHp(), door.getMaxHp(), false));
|
||||
html.replace("%mpGauge%", HtmlUtil.getMpGauge(250, (long) door.getCurrentMp(), door.getMaxMp(), false));
|
||||
// Basic info
|
||||
html.replace("%doorName%", door.getName());
|
||||
html.replace("%objId%", String.valueOf(door.getObjectId()));
|
||||
html.replace("%doorId%", String.valueOf(door.getId()));
|
||||
// Position info
|
||||
html.replace("%position%", door.getX() + ", " + door.getY() + ", " + door.getZ());
|
||||
html.replace("%node1%", door.getX(0) + ", " + door.getY(0) + ", " + door.getZMin());
|
||||
html.replace("%node2%", door.getX(1) + ", " + door.getY(1) + ", " + door.getZMin());
|
||||
html.replace("%node3%", door.getX(2) + ", " + door.getY(2) + ", " + door.getZMax());
|
||||
html.replace("%node4%", door.getX(3) + ", " + door.getY(3) + ", " + door.getZMax());
|
||||
// Residence info
|
||||
html.replace("%fortress%", fort != null ? fort.getName() : "None");
|
||||
html.replace("%clanHall%", clanHall != null ? clanHall.getName() : "None");
|
||||
html.replace("%castle%", castle != null ? castle.getName() + " Castle" : "None");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,44 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class L2ItemInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.sendPacket(new NpcHtmlMessage(StringUtil.concat("<html><body><center><font color=\"LEVEL\">Item Info</font></center><br><table border=0>", "<tr><td>Object ID: </td><td>", String.valueOf(target.getObjectId()), "</td></tr><tr><td>Item ID: </td><td>", String.valueOf(target.getId()), "</td></tr><tr><td>Owner ID: </td><td>", String.valueOf(((L2ItemInstance) target).getOwnerId()), "</td></tr><tr><td>Location: </td><td>", String.valueOf(((L2ItemInstance) target).getLocation()), "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", target.getClass().getSimpleName(), "</td></tr></table></body></html>")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2ItemInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1, "<html><body><center><font color=\"LEVEL\">Item Info</font></center><br><table border=0><tr><td>Object ID: </td><td>" + target.getObjectId() + "</td></tr><tr><td>Item ID: </td><td>" + target.getId() + "</td></tr><tr><td>Owner ID: </td><td>" + ((L2ItemInstance) target).getOwnerId() + "</td></tr><tr><td>Location: </td><td>" + target.getLocation() + "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>" + target.getClass().getSimpleName() + "</td></tr></table></body></html>");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,198 +1,210 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.Elementals;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
import handlers.bypasshandlers.NpcViewMod;
|
||||
|
||||
public class L2NpcActionShift implements IActionShiftHandler
|
||||
{
|
||||
/**
|
||||
* Manage and Display the GM console to modify the L2NpcInstance (GM only).<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions (If the L2PcInstance is a GM only)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the L2NpcInstance as target of the L2PcInstance player (if necessary)</li>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li>
|
||||
* <li>If L2NpcInstance is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to update L2NpcInstance HP bar</li>
|
||||
* <li>Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance</li><BR>
|
||||
* <BR>
|
||||
* <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid that client wait an other packet</B></FONT><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action</li><BR>
|
||||
* <BR>
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance is a GM
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/npcinfo.htm");
|
||||
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%race%", ((L2Npc) target).getTemplate().getRace().toString());
|
||||
html.replace("%id%", String.valueOf(((L2Npc) target).getTemplate().getId()));
|
||||
html.replace("%lvl%", String.valueOf(((L2Npc) target).getTemplate().getLevel()));
|
||||
html.replace("%name%", String.valueOf(((L2Npc) target).getTemplate().getName()));
|
||||
html.replace("%tmplid%", String.valueOf(((L2Npc) target).getTemplate().getId()));
|
||||
html.replace("%aggro%", String.valueOf((target instanceof L2Attackable) ? ((L2Attackable) target).getAggroRange() : 0));
|
||||
html.replace("%hp%", String.valueOf((int) ((L2Character) target).getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(((L2Character) target).getMaxHp()));
|
||||
html.replace("%mp%", String.valueOf((int) ((L2Character) target).getCurrentMp()));
|
||||
html.replace("%mpmax%", String.valueOf(((L2Character) target).getMaxMp()));
|
||||
|
||||
html.replace("%patk%", String.valueOf((int) ((L2Character) target).getPAtk(null)));
|
||||
html.replace("%matk%", String.valueOf((int) ((L2Character) target).getMAtk(null, null)));
|
||||
html.replace("%pdef%", String.valueOf((int) ((L2Character) target).getPDef(null)));
|
||||
html.replace("%mdef%", String.valueOf((int) ((L2Character) target).getMDef(null, null)));
|
||||
html.replace("%accu%", String.valueOf(((L2Character) target).getAccuracy()));
|
||||
html.replace("%evas%", String.valueOf(((L2Character) target).getEvasionRate(null)));
|
||||
html.replace("%crit%", String.valueOf(((L2Character) target).getCriticalHit(null, null)));
|
||||
html.replace("%rspd%", String.valueOf((int) ((L2Character) target).getRunSpeed()));
|
||||
html.replace("%aspd%", String.valueOf(((L2Character) target).getPAtkSpd()));
|
||||
html.replace("%cspd%", String.valueOf(((L2Character) target).getMAtkSpd()));
|
||||
html.replace("%atkType%", String.valueOf(((L2Character) target).getTemplate().getBaseAttackType()));
|
||||
html.replace("%atkRng%", String.valueOf(((L2Character) target).getTemplate().getBaseAttackRange()));
|
||||
html.replace("%loc%", String.valueOf(target.getX() + " " + target.getY() + " " + target.getZ()));
|
||||
html.replace("%heading%", String.valueOf(((L2Character) target).getHeading()));
|
||||
html.replace("%collision_radius%", String.valueOf(((L2Character) target).getTemplate().getfCollisionRadius()));
|
||||
html.replace("%collision_height%", String.valueOf(((L2Character) target).getTemplate().getfCollisionHeight()));
|
||||
html.replace("%dist%", String.valueOf((int) activeChar.calculateDistance(target, true, false)));
|
||||
|
||||
final byte attackAttribute = ((L2Character) target).getAttackElement();
|
||||
html.replace("%ele_atk%", Elementals.getElementName(attackAttribute));
|
||||
html.replace("%ele_atk_value%", String.valueOf(((L2Character) target).getAttackElementValue(attackAttribute)));
|
||||
html.replace("%ele_dfire%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.FIRE)));
|
||||
html.replace("%ele_dwater%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.WATER)));
|
||||
html.replace("%ele_dwind%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.WIND)));
|
||||
html.replace("%ele_dearth%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.EARTH)));
|
||||
html.replace("%ele_dholy%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.HOLY)));
|
||||
html.replace("%ele_ddark%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.DARK)));
|
||||
|
||||
if (((L2Npc) target).getSpawn() != null)
|
||||
{
|
||||
html.replace("%territory%", ((L2Npc) target).getSpawn().getSpawnTerritory() == null ? "None" : ((L2Npc) target).getSpawn().getSpawnTerritory().getName());
|
||||
if (((L2Npc) target).getSpawn().isTerritoryBased())
|
||||
{
|
||||
html.replace("%spawntype%", "Random");
|
||||
final Location spawnLoc = ((L2Npc) target).getSpawn().getLocation(target);
|
||||
html.replace("%spawn%", spawnLoc.getX() + " " + spawnLoc.getY() + " " + spawnLoc.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%spawntype%", "Fixed");
|
||||
html.replace("%spawn%", ((L2Npc) target).getSpawn().getX() + " " + ((L2Npc) target).getSpawn().getY() + " " + ((L2Npc) target).getSpawn().getZ());
|
||||
}
|
||||
html.replace("%loc2d%", String.valueOf((int) activeChar.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), false, false)));
|
||||
html.replace("%loc3d%", String.valueOf((int) activeChar.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), true, false)));
|
||||
if (((L2Npc) target).getSpawn().getRespawnMinDelay() == 0)
|
||||
{
|
||||
html.replace("%resp%", "None");
|
||||
}
|
||||
else if (((L2Npc) target).getSpawn().hasRespawnRandom())
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(((L2Npc) target).getSpawn().getRespawnMinDelay() / 1000) + "-" + String.valueOf((((L2Npc) target).getSpawn().getRespawnMaxDelay() / 1000) + " sec"));
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(((L2Npc) target).getSpawn().getRespawnMinDelay() / 1000) + " sec");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%territory%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawntype%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawn%", "<font color=FF0000>null</font>");
|
||||
html.replace("%loc2d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%loc3d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%resp%", "<font color=FF0000>--</font>");
|
||||
}
|
||||
|
||||
if (((L2Npc) target).hasAI())
|
||||
{
|
||||
final Set<Integer> clans = ((L2Npc) target).getTemplate().getClans();
|
||||
final Set<Integer> ignoreClanNpcIds = ((L2Npc) target).getTemplate().getIgnoreClanNpcIds();
|
||||
final String clansString = clans != null ? Util.implode(clans.toArray(), ", ") : "";
|
||||
final String ignoreClanNpcIdsString = ignoreClanNpcIds != null ? Util.implode(ignoreClanNpcIds.toArray(), ", ") : "";
|
||||
|
||||
html.replace("%ai_intention%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Intention:</font></td><td align=right width=170>" + String.valueOf(((L2Npc) target).getAI().getIntention().name()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>AI</font></td><td align=right width=170>" + ((L2Npc) target).getAI().getClass().getSimpleName() + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_type%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>AIType</font></td><td align=right width=170>" + String.valueOf(((L2Npc) target).getAiType()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_clan%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>Clan & Range:</font></td><td align=right width=170>" + clansString + " " + String.valueOf(((L2Npc) target).getTemplate().getClanHelpRange()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_enemy_clan%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Ignore & Range:</font></td><td align=right width=170>" + ignoreClanNpcIdsString + " " + String.valueOf(((L2Npc) target).getTemplate().getAggroRange()) + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%ai_intention%", "");
|
||||
html.replace("%ai%", "");
|
||||
html.replace("%ai_type%", "");
|
||||
html.replace("%ai_clan%", "");
|
||||
html.replace("%ai_enemy_clan%", "");
|
||||
}
|
||||
|
||||
final String routeName = WalkingManager.getInstance().getRouteName((L2Npc) target);
|
||||
if (!routeName.isEmpty())
|
||||
{
|
||||
html.replace("%route%", "<tr><td><table width=270 border=0><tr><td width=100><font color=LEVEL>Route:</font></td><td align=right width=170>" + routeName + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%route%", "");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (Config.ALT_GAME_VIEWNPC)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setTarget(target);
|
||||
NpcViewMod.sendNpcView(activeChar, (L2Npc) target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.spawns.NpcSpawnTemplate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
import handlers.bypasshandlers.NpcViewMod;
|
||||
|
||||
public class L2NpcActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance is a GM
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallByNpcId(npc.getId());
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npcinfo.htm");
|
||||
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%race%", npc.getTemplate().getRace().toString());
|
||||
html.replace("%id%", String.valueOf(npc.getTemplate().getId()));
|
||||
html.replace("%lvl%", String.valueOf(npc.getTemplate().getLevel()));
|
||||
html.replace("%name%", String.valueOf(npc.getTemplate().getName()));
|
||||
html.replace("%tmplid%", String.valueOf(npc.getTemplate().getId()));
|
||||
html.replace("%aggro%", String.valueOf((target instanceof L2Attackable) ? ((L2Attackable) target).getAggroRange() : 0));
|
||||
html.replace("%hp%", String.valueOf((int) npc.getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(npc.getMaxHp()));
|
||||
html.replace("%mp%", String.valueOf((int) npc.getCurrentMp()));
|
||||
html.replace("%mpmax%", String.valueOf(npc.getMaxMp()));
|
||||
|
||||
html.replace("%patk%", String.valueOf(npc.getPAtk()));
|
||||
html.replace("%matk%", String.valueOf(npc.getMAtk()));
|
||||
html.replace("%pdef%", String.valueOf(npc.getPDef()));
|
||||
html.replace("%mdef%", String.valueOf(npc.getMDef()));
|
||||
html.replace("%accu%", String.valueOf(npc.getAccuracy()));
|
||||
html.replace("%evas%", String.valueOf(npc.getEvasionRate()));
|
||||
html.replace("%crit%", String.valueOf(npc.getCriticalHit()));
|
||||
html.replace("%rspd%", String.valueOf(npc.getRunSpeed()));
|
||||
html.replace("%aspd%", String.valueOf(npc.getPAtkSpd()));
|
||||
html.replace("%cspd%", String.valueOf(npc.getMAtkSpd()));
|
||||
html.replace("%atkType%", String.valueOf(npc.getTemplate().getBaseAttackType()));
|
||||
html.replace("%atkRng%", String.valueOf(npc.getTemplate().getBaseAttackRange()));
|
||||
html.replace("%str%", String.valueOf(npc.getSTR()));
|
||||
html.replace("%dex%", String.valueOf(npc.getDEX()));
|
||||
html.replace("%con%", String.valueOf(npc.getCON()));
|
||||
html.replace("%int%", String.valueOf(npc.getINT()));
|
||||
html.replace("%wit%", String.valueOf(npc.getWIT()));
|
||||
html.replace("%men%", String.valueOf(npc.getMEN()));
|
||||
html.replace("%loc%", String.valueOf(target.getX() + " " + target.getY() + " " + target.getZ()));
|
||||
html.replace("%heading%", String.valueOf(npc.getHeading()));
|
||||
html.replace("%collision_radius%", String.valueOf(npc.getTemplate().getfCollisionRadius()));
|
||||
html.replace("%collision_height%", String.valueOf(npc.getTemplate().getfCollisionHeight()));
|
||||
html.replace("%dist%", String.valueOf((int) activeChar.calculateDistance(target, true, false)));
|
||||
html.replace("%clanHall%", clanHall != null ? clanHall.getName() : "none");
|
||||
html.replace("%mpRewardValue%", npc.getTemplate().getMpRewardValue());
|
||||
html.replace("%mpRewardTicks%", npc.getTemplate().getMpRewardTicks());
|
||||
html.replace("%mpRewardType%", npc.getTemplate().getMpRewardType().name());
|
||||
html.replace("%mpRewardAffectType%", npc.getTemplate().getMpRewardAffectType().name());
|
||||
|
||||
final AttributeType attackAttribute = npc.getAttackElement();
|
||||
html.replace("%ele_atk%", attackAttribute.name());
|
||||
html.replace("%ele_atk_value%", String.valueOf(npc.getAttackElementValue(attackAttribute)));
|
||||
html.replace("%ele_dfire%", String.valueOf(npc.getDefenseElementValue(AttributeType.FIRE)));
|
||||
html.replace("%ele_dwater%", String.valueOf(npc.getDefenseElementValue(AttributeType.WATER)));
|
||||
html.replace("%ele_dwind%", String.valueOf(npc.getDefenseElementValue(AttributeType.WIND)));
|
||||
html.replace("%ele_dearth%", String.valueOf(npc.getDefenseElementValue(AttributeType.EARTH)));
|
||||
html.replace("%ele_dholy%", String.valueOf(npc.getDefenseElementValue(AttributeType.HOLY)));
|
||||
html.replace("%ele_ddark%", String.valueOf(npc.getDefenseElementValue(AttributeType.DARK)));
|
||||
|
||||
final L2Spawn spawn = npc.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
final NpcSpawnTemplate template = spawn.getNpcSpawnTemplate();
|
||||
if (template != null)
|
||||
{
|
||||
final String fileName = template.getSpawnTemplate().getFile().getAbsolutePath().substring(Config.DATAPACK_ROOT.getAbsolutePath().length() + 1).replace('\\', '/');
|
||||
html.replace("%spawnfile%", fileName);
|
||||
html.replace("%spawnname%", String.valueOf(template.getSpawnTemplate().getName()));
|
||||
html.replace("%spawngroup%", String.valueOf(template.getGroup().getName()));
|
||||
if (template.getSpawnTemplate().getAI() != null)
|
||||
{
|
||||
final Quest script = QuestManager.getInstance().getQuest(template.getSpawnTemplate().getAI());
|
||||
if (script != null)
|
||||
{
|
||||
html.replace("%spawnai%", "<a action=\"bypass -h admin_quest_info " + script.getName() + "\"><font color=\"LEVEL\">" + script.getName() + "</font></a>");
|
||||
}
|
||||
}
|
||||
html.replace("%spawnai%", "<font color=FF0000>" + template.getSpawnTemplate().getAI() + "</font>");
|
||||
}
|
||||
|
||||
html.replace("%spawn%", npc.getSpawn().getX() + " " + npc.getSpawn().getY() + " " + npc.getSpawn().getZ());
|
||||
html.replace("%loc2d%", String.valueOf((int) npc.calculateDistance(npc.getSpawn().getLocation(), false, false)));
|
||||
html.replace("%loc3d%", String.valueOf((int) npc.calculateDistance(npc.getSpawn().getLocation(), true, false)));
|
||||
if (npc.getSpawn().getRespawnMinDelay() == 0)
|
||||
{
|
||||
html.replace("%resp%", "None");
|
||||
}
|
||||
else if (npc.getSpawn().hasRespawnRandom())
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(npc.getSpawn().getRespawnMinDelay() / 1000) + "-" + String.valueOf((npc.getSpawn().getRespawnMaxDelay() / 1000) + " sec"));
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(npc.getSpawn().getRespawnMinDelay() / 1000) + " sec");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%spawn%", "<font color=FF0000>null</font>");
|
||||
html.replace("%loc2d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%loc3d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%resp%", "<font color=FF0000>--</font>");
|
||||
}
|
||||
|
||||
html.replace("%spawnfile%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawnname%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawngroup%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawnai%", "<font color=FF0000>--</font>");
|
||||
|
||||
if (npc.hasAI())
|
||||
{
|
||||
final Set<String> clans = NpcData.getInstance().getClansByIds(npc.getTemplate().getClans());
|
||||
final Set<Integer> ignoreClanNpcIds = npc.getTemplate().getIgnoreClanNpcIds();
|
||||
final String clansString = !clans.isEmpty() ? CommonUtil.implode(clans, ", ") : "";
|
||||
final String ignoreClanNpcIdsString = ignoreClanNpcIds != null ? CommonUtil.implode(ignoreClanNpcIds, ", ") : "";
|
||||
|
||||
html.replace("%ai_intention%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Intention:</font></td><td align=right width=170>" + String.valueOf(npc.getAI().getIntention().name()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>AI</font></td><td align=right width=170>" + npc.getAI().getClass().getSimpleName() + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_type%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>AIType</font></td><td align=right width=170>" + String.valueOf(npc.getAiType()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_clan%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>Clan & Range:</font></td><td align=right width=170>" + clansString + " " + String.valueOf(npc.getTemplate().getClanHelpRange()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_enemy_clan%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Ignore & Range:</font></td><td align=right width=170>" + ignoreClanNpcIdsString + " " + String.valueOf(npc.getTemplate().getAggroRange()) + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%ai_intention%", "");
|
||||
html.replace("%ai%", "");
|
||||
html.replace("%ai_type%", "");
|
||||
html.replace("%ai_clan%", "");
|
||||
html.replace("%ai_enemy_clan%", "");
|
||||
}
|
||||
|
||||
final String routeName = WalkingManager.getInstance().getRouteName(npc);
|
||||
if (!routeName.isEmpty())
|
||||
{
|
||||
html.replace("%route%", "<tr><td><table width=270 border=0><tr><td width=100><font color=LEVEL>Route:</font></td><td align=right width=170>" + routeName + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%route%", "");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (Config.ALT_GAME_VIEWNPC)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setTarget(target);
|
||||
NpcViewMod.sendNpcView(activeChar, (L2Npc) target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,47 +1,48 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StaticObject;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class L2StaticObjectInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new StaticObject((L2StaticObjectInstance) target));
|
||||
activeChar.sendPacket(new NpcHtmlMessage(StringUtil.concat("<html><body><center><font color=\"LEVEL\">Static Object Info</font></center><br><table border=0><tr><td>Coords X,Y,Z: </td><td>", String.valueOf(target.getX()), ", ", String.valueOf(target.getY()), ", ", String.valueOf(target.getZ()), "</td></tr><tr><td>Object ID: </td><td>", String.valueOf(target.getObjectId()), "</td></tr><tr><td>Static Object ID: </td><td>", String.valueOf(target.getId()), "</td></tr><tr><td>Mesh Index: </td><td>", String.valueOf(((L2StaticObjectInstance) target).getMeshIndex()), "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", target.getClass().getSimpleName(), "</td></tr></table></body></html>")));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.actionshifthandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.enums.InstanceType;
|
||||
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StaticObject;
|
||||
|
||||
public class L2StaticObjectInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new StaticObject((L2StaticObjectInstance) target));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1, "<html><body><center><font color=\"LEVEL\">Static Object Info</font></center><br><table border=0><tr><td>Coords X,Y,Z: </td><td>" + target.getX() + ", " + target.getY() + ", " + target.getZ() + "</td></tr><tr><td>Object ID: </td><td>" + target.getObjectId() + "</td></tr><tr><td>Static Object ID: </td><td>" + target.getId() + "</td></tr><tr><td>Mesh Index: </td><td>" + ((L2StaticObjectInstance) target).getMeshIndex() + "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>" + target.getClass().getSimpleName() + "</td></tr></table></body></html>");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,461 +1,474 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - admin|admin1/admin2/admin3/admin4/admin5 = slots for the 5 starting admin menus - gmliston/gmlistoff = includes/excludes active character from /gmlist results - silence = toggles private messages acceptance mode - diet = toggles weight penalty mode -
|
||||
* tradeoff = toggles trade acceptance mode - reload = reloads specified component from multisell|skill|npc|htm|item - set/set_menu/set_mod = alters specified server setting - saveolymp = saves olympiad state manually - manualhero = cycles olympiad and calculate new heroes.
|
||||
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2007/07/28 10:06:06 $
|
||||
*/
|
||||
public class AdminAdmin implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminAdmin.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_admin",
|
||||
"admin_admin1",
|
||||
"admin_admin2",
|
||||
"admin_admin3",
|
||||
"admin_admin4",
|
||||
"admin_admin5",
|
||||
"admin_admin6",
|
||||
"admin_admin7",
|
||||
"admin_gmliston",
|
||||
"admin_gmlistoff",
|
||||
"admin_silence",
|
||||
"admin_diet",
|
||||
"admin_tradeoff",
|
||||
"admin_set",
|
||||
"admin_set_mod",
|
||||
"admin_saveolymp",
|
||||
"admin_sethero",
|
||||
"admin_givehero",
|
||||
"admin_endolympiad",
|
||||
"admin_setconfig",
|
||||
"admin_config_server",
|
||||
"admin_gmon",
|
||||
"admin_worldchat",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_admin"))
|
||||
{
|
||||
showMainPage(activeChar, command);
|
||||
}
|
||||
else if (command.equals("admin_config_server"))
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_gmliston"))
|
||||
{
|
||||
AdminData.getInstance().showGm(activeChar);
|
||||
activeChar.sendMessage("Registered into gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_gmlistoff"))
|
||||
{
|
||||
AdminData.getInstance().hideGm(activeChar);
|
||||
activeChar.sendMessage("Removed from gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_silence"))
|
||||
{
|
||||
if (activeChar.isSilenceMode()) // already in message refusal mode
|
||||
{
|
||||
activeChar.setSilenceMode(false);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_ACCEPTANCE_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_REFUSAL_MODE);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_saveolymp"))
|
||||
{
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
activeChar.sendMessage("olympiad system saved.");
|
||||
}
|
||||
else if (command.startsWith("admin_endolympiad"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Olympiad.getInstance().manualSelectHeroes();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("An error occured while ending olympiad: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Heroes formed.");
|
||||
}
|
||||
else if (command.startsWith("admin_sethero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
target.setHero(!target.isHero());
|
||||
target.broadcastUserInfo();
|
||||
}
|
||||
else if (command.startsWith("admin_givehero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
if (Hero.getInstance().isHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player has already claimed the hero status.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Hero.getInstance().isUnclaimedHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player cannot claim the hero status.");
|
||||
return false;
|
||||
}
|
||||
Hero.getInstance().claimHero(target);
|
||||
}
|
||||
else if (command.startsWith("admin_diet"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
if (st.nextToken().equalsIgnoreCase("on"))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
else if (st.nextToken().equalsIgnoreCase("off"))
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (activeChar.getDietMode())
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
activeChar.refreshOverloaded();
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_tradeoff"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String mode = command.substring(15);
|
||||
if (mode.equalsIgnoreCase("on"))
|
||||
{
|
||||
activeChar.setTradeRefusal(true);
|
||||
activeChar.sendMessage("Trade refusal enabled");
|
||||
}
|
||||
else if (mode.equalsIgnoreCase("off"))
|
||||
{
|
||||
activeChar.setTradeRefusal(false);
|
||||
activeChar.sendMessage("Trade refusal disabled");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (activeChar.getTradeRefusal())
|
||||
{
|
||||
activeChar.setTradeRefusal(false);
|
||||
activeChar.sendMessage("Trade refusal disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setTradeRefusal(true);
|
||||
activeChar.sendMessage("Trade refusal enabled");
|
||||
}
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_setconfig"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
try
|
||||
{
|
||||
final String pName = st.nextToken();
|
||||
final String pValue = st.nextToken();
|
||||
if (Float.valueOf(pValue) == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameter!");
|
||||
return false;
|
||||
}
|
||||
switch (pName)
|
||||
{
|
||||
case "RateXp":
|
||||
{
|
||||
Config.RATE_XP = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "RateSp":
|
||||
{
|
||||
Config.RATE_SP = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "RateDropSpoil":
|
||||
{
|
||||
Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementStone":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_STONE = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementCrystal":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_CRYSTAL = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementJewel":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_JEWEL = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementEnergy":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_ENERGY = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("Config parameter " + pName + " set to " + pValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setconfig <parameter> <value>");
|
||||
}
|
||||
finally
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_worldchat"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // admin_worldchat
|
||||
switch (st.hasMoreTokens() ? st.nextToken() : "")
|
||||
{
|
||||
case "shout":
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
sb.append(st.nextToken());
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
final CreatureSay cs = new CreatureSay(activeChar, ChatType.WORLD, sb.toString());
|
||||
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
|
||||
break;
|
||||
}
|
||||
case "see":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
break;
|
||||
}
|
||||
final L2PcInstance targetPlayer = target.getActingPlayer();
|
||||
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
|
||||
{
|
||||
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
|
||||
break;
|
||||
}
|
||||
activeChar.sendMessage(targetPlayer.getName() + ": has " + targetPlayer.getWorldChatPoints() + " world chat points");
|
||||
break;
|
||||
}
|
||||
case "set":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
break;
|
||||
}
|
||||
|
||||
final L2PcInstance targetPlayer = target.getActingPlayer();
|
||||
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
|
||||
{
|
||||
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
|
||||
final String valueToken = st.nextToken();
|
||||
if (!Util.isDigit(valueToken))
|
||||
{
|
||||
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
|
||||
activeChar.sendMessage(targetPlayer.getName() + ": points changed from " + targetPlayer.getWorldChatPoints() + " to " + valueToken);
|
||||
targetPlayer.setWorldChatPoints(Integer.parseInt(valueToken));
|
||||
targetPlayer.sendPacket(new ExWorldChatCnt(targetPlayer));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Possible commands:");
|
||||
activeChar.sendMessage(" - Send message: //worldchat shout <text>");
|
||||
activeChar.sendMessage(" - See your target's points: //worldchat see");
|
||||
activeChar.sendMessage(" - Change your target's points: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_gmon"))
|
||||
{
|
||||
// TODO why is this empty?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar, String command)
|
||||
{
|
||||
int mode = 0;
|
||||
String filename = null;
|
||||
try
|
||||
{
|
||||
mode = Integer.parseInt(command.substring(11));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
filename = "main";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
filename = "game";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
filename = "effects";
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
filename = "server";
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
filename = "mods";
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
filename = "char";
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
filename = "gm";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
filename = "main";
|
||||
break;
|
||||
}
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, filename + "_menu.htm");
|
||||
}
|
||||
|
||||
private void showConfigPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><title>L2J :: Config</title><body>");
|
||||
replyMSG.append("<center><table width=270><tr><td width=60><button value=\"Main\" action=\"bypass -h admin_admin\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=150>Config Server Panel</td><td width=60><button value=\"Back\" action=\"bypass -h admin_admin4\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></center><br>");
|
||||
replyMSG.append("<center><table width=260><tr><td width=140></td><td width=40></td><td width=40></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"00AA00\">Drop:</font></td><td></td><td></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate EXP</font> = " + Config.RATE_XP + "</td><td><edit var=\"param1\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateXp $param1\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate SP</font> = " + Config.RATE_SP + "</td><td><edit var=\"param2\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateSp $param2\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate Drop Spoil</font> = " + Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER + "</td><td><edit var=\"param4\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateDropSpoil $param4\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td width=140></td><td width=40></td><td width=40></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"00AA00\">Enchant:</font></td><td></td><td></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Stone</font> = " + Config.ENCHANT_CHANCE_ELEMENT_STONE + "</td><td><edit var=\"param8\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementStone $param8\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Crystal</font> = " + Config.ENCHANT_CHANCE_ELEMENT_CRYSTAL + "</td><td><edit var=\"param9\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementCrystal $param9\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Jewel</font> = " + Config.ENCHANT_CHANCE_ELEMENT_JEWEL + "</td><td><edit var=\"param10\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementJewel $param10\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Energy</font> = " + Config.ENCHANT_CHANCE_ELEMENT_ENERGY + "</td><td><edit var=\"param11\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementEnergy $param11\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
|
||||
replyMSG.append("</table></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Hero;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExWorldChatCnt;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - admin|admin1/admin2/admin3/admin4/admin5 = slots for the 5 starting admin menus - gmliston/gmlistoff = includes/excludes active character from /gmlist results - silence = toggles private messages acceptance mode - diet = toggles weight penalty mode -
|
||||
* tradeoff = toggles trade acceptance mode - reload = reloads specified component from multisell|skill|npc|htm|item - set/set_menu/set_mod = alters specified server setting - saveolymp = saves olympiad state manually - manualhero = cycles olympiad and calculate new heroes.
|
||||
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2007/07/28 10:06:06 $
|
||||
*/
|
||||
public class AdminAdmin implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminAdmin.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_admin",
|
||||
"admin_admin1",
|
||||
"admin_admin2",
|
||||
"admin_admin3",
|
||||
"admin_admin4",
|
||||
"admin_admin5",
|
||||
"admin_admin6",
|
||||
"admin_admin7",
|
||||
"admin_gmliston",
|
||||
"admin_gmlistoff",
|
||||
"admin_silence",
|
||||
"admin_diet",
|
||||
"admin_tradeoff",
|
||||
"admin_set",
|
||||
"admin_set_mod",
|
||||
"admin_saveolymp",
|
||||
"admin_sethero",
|
||||
"admin_settruehero",
|
||||
"admin_givehero",
|
||||
"admin_endolympiad",
|
||||
"admin_setconfig",
|
||||
"admin_config_server",
|
||||
"admin_gmon",
|
||||
"admin_worldchat",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_admin"))
|
||||
{
|
||||
showMainPage(activeChar, command);
|
||||
}
|
||||
else if (command.equals("admin_config_server"))
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_gmliston"))
|
||||
{
|
||||
AdminData.getInstance().showGm(activeChar);
|
||||
activeChar.sendMessage("Registered into gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_gmlistoff"))
|
||||
{
|
||||
AdminData.getInstance().hideGm(activeChar);
|
||||
activeChar.sendMessage("Removed from gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_silence"))
|
||||
{
|
||||
if (activeChar.isSilenceMode()) // already in message refusal mode
|
||||
{
|
||||
activeChar.setSilenceMode(false);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_ACCEPTANCE_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_REFUSAL_MODE);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_saveolymp"))
|
||||
{
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
activeChar.sendMessage("olympiad system saved.");
|
||||
}
|
||||
else if (command.startsWith("admin_endolympiad"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Olympiad.getInstance().manualSelectHeroes();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("An error occured while ending olympiad: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Heroes formed.");
|
||||
}
|
||||
else if (command.startsWith("admin_sethero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
target.setHero(!target.isHero());
|
||||
target.broadcastUserInfo();
|
||||
}
|
||||
else if (command.startsWith("admin_settruehero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
target.setTrueHero(!target.isTrueHero());
|
||||
target.broadcastUserInfo();
|
||||
}
|
||||
else if (command.startsWith("admin_givehero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
if (Hero.getInstance().isHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player has already claimed the hero status.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Hero.getInstance().isUnclaimedHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player cannot claim the hero status.");
|
||||
return false;
|
||||
}
|
||||
Hero.getInstance().claimHero(target);
|
||||
}
|
||||
else if (command.startsWith("admin_diet"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
if (st.nextToken().equalsIgnoreCase("on"))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
else if (st.nextToken().equalsIgnoreCase("off"))
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (activeChar.getDietMode())
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
activeChar.refreshOverloaded(true);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_tradeoff"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String mode = command.substring(15);
|
||||
if (mode.equalsIgnoreCase("on"))
|
||||
{
|
||||
activeChar.setTradeRefusal(true);
|
||||
activeChar.sendMessage("Trade refusal enabled");
|
||||
}
|
||||
else if (mode.equalsIgnoreCase("off"))
|
||||
{
|
||||
activeChar.setTradeRefusal(false);
|
||||
activeChar.sendMessage("Trade refusal disabled");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (activeChar.getTradeRefusal())
|
||||
{
|
||||
activeChar.setTradeRefusal(false);
|
||||
activeChar.sendMessage("Trade refusal disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setTradeRefusal(true);
|
||||
activeChar.sendMessage("Trade refusal enabled");
|
||||
}
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_setconfig"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
try
|
||||
{
|
||||
final String pName = st.nextToken();
|
||||
final String pValue = st.nextToken();
|
||||
if (Float.valueOf(pValue) == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameter!");
|
||||
return false;
|
||||
}
|
||||
switch (pName)
|
||||
{
|
||||
case "RateXp":
|
||||
{
|
||||
Config.RATE_XP = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "RateSp":
|
||||
{
|
||||
Config.RATE_SP = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "RateDropSpoil":
|
||||
{
|
||||
Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementStone":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_STONE = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementCrystal":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_CRYSTAL = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementJewel":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_JEWEL = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
case "EnchantChanceElementEnergy":
|
||||
{
|
||||
Config.ENCHANT_CHANCE_ELEMENT_ENERGY = Float.valueOf(pValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("Config parameter " + pName + " set to " + pValue);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setconfig <parameter> <value>");
|
||||
}
|
||||
finally
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_worldchat"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // admin_worldchat
|
||||
switch (st.hasMoreTokens() ? st.nextToken() : "")
|
||||
{
|
||||
case "shout":
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
sb.append(st.nextToken());
|
||||
sb.append(" ");
|
||||
}
|
||||
|
||||
final CreatureSay cs = new CreatureSay(activeChar, ChatType.WORLD, sb.toString());
|
||||
L2World.getInstance().getPlayers().stream().filter(activeChar::isNotBlocked).forEach(cs::sendTo);
|
||||
break;
|
||||
}
|
||||
case "see":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
break;
|
||||
}
|
||||
final L2PcInstance targetPlayer = target.getActingPlayer();
|
||||
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
|
||||
{
|
||||
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
|
||||
break;
|
||||
}
|
||||
activeChar.sendMessage(targetPlayer.getName() + ": has " + targetPlayer.getWorldChatPoints() + " world chat points");
|
||||
break;
|
||||
}
|
||||
case "set":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || !target.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
break;
|
||||
}
|
||||
|
||||
final L2PcInstance targetPlayer = target.getActingPlayer();
|
||||
if (targetPlayer.getLevel() < Config.WORLD_CHAT_MIN_LEVEL)
|
||||
{
|
||||
activeChar.sendMessage("Your target's level is below the minimum: " + Config.WORLD_CHAT_MIN_LEVEL);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
|
||||
final String valueToken = st.nextToken();
|
||||
if (!Util.isDigit(valueToken))
|
||||
{
|
||||
activeChar.sendMessage("Incorrect syntax, use: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
|
||||
activeChar.sendMessage(targetPlayer.getName() + ": points changed from " + targetPlayer.getWorldChatPoints() + " to " + valueToken);
|
||||
targetPlayer.setWorldChatPoints(Integer.parseInt(valueToken));
|
||||
targetPlayer.sendPacket(new ExWorldChatCnt(targetPlayer));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Possible commands:");
|
||||
activeChar.sendMessage(" - Send message: //worldchat shout <text>");
|
||||
activeChar.sendMessage(" - See your target's points: //worldchat see");
|
||||
activeChar.sendMessage(" - Change your target's points: //worldchat set <points>");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_gmon"))
|
||||
{
|
||||
// TODO why is this empty?
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar, String command)
|
||||
{
|
||||
int mode = 0;
|
||||
String filename = null;
|
||||
try
|
||||
{
|
||||
mode = Integer.parseInt(command.substring(11));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
filename = "main";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
filename = "game";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
filename = "effects";
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
filename = "server";
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
filename = "mods";
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
filename = "char";
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
filename = "gm";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
filename = "main";
|
||||
break;
|
||||
}
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, filename + "_menu.htm");
|
||||
}
|
||||
|
||||
private void showConfigPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><title>L2J :: Config</title><body>");
|
||||
replyMSG.append("<center><table width=270><tr><td width=60><button value=\"Main\" action=\"bypass -h admin_admin\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=150>Config Server Panel</td><td width=60><button value=\"Back\" action=\"bypass -h admin_admin4\" width=60 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></center><br>");
|
||||
replyMSG.append("<center><table width=260><tr><td width=140></td><td width=40></td><td width=40></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"00AA00\">Drop:</font></td><td></td><td></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate EXP</font> = " + Config.RATE_XP + "</td><td><edit var=\"param1\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateXp $param1\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate SP</font> = " + Config.RATE_SP + "</td><td><edit var=\"param2\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateSp $param2\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Rate Drop Spoil</font> = " + Config.RATE_CORPSE_DROP_CHANCE_MULTIPLIER + "</td><td><edit var=\"param4\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig RateDropSpoil $param4\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td width=140></td><td width=40></td><td width=40></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"00AA00\">Enchant:</font></td><td></td><td></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Stone</font> = " + Config.ENCHANT_CHANCE_ELEMENT_STONE + "</td><td><edit var=\"param8\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementStone $param8\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Crystal</font> = " + Config.ENCHANT_CHANCE_ELEMENT_CRYSTAL + "</td><td><edit var=\"param9\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementCrystal $param9\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Jewel</font> = " + Config.ENCHANT_CHANCE_ELEMENT_JEWEL + "</td><td><edit var=\"param10\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementJewel $param10\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Element Energy</font> = " + Config.ENCHANT_CHANCE_ELEMENT_ENERGY + "</td><td><edit var=\"param11\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceElementEnergy $param11\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
|
||||
replyMSG.append("</table></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,378 +1,451 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class AdminBuffs implements IAdminCommandHandler
|
||||
{
|
||||
private static final int PAGE_LIMIT = 20;
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_getbuffs",
|
||||
"admin_getbuffs_ps",
|
||||
"admin_stopbuff",
|
||||
"admin_stopallbuffs",
|
||||
"admin_areacancel",
|
||||
"admin_removereuse",
|
||||
"admin_switch_gm_buffs"
|
||||
};
|
||||
// Misc
|
||||
private static final String FONT_RED1 = "<font color=\"FF0000\">";
|
||||
private static final String FONT_RED2 = "</font>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_getbuffs"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String playername = st.nextToken();
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(playername);
|
||||
if (player != null)
|
||||
{
|
||||
int page = 1;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
page = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
showBuffs(activeChar, player, page, command.endsWith("_ps"));
|
||||
return true;
|
||||
}
|
||||
activeChar.sendMessage("The player " + playername + " is not online.");
|
||||
return false;
|
||||
}
|
||||
else if ((activeChar.getTarget() != null) && activeChar.getTarget().isCharacter())
|
||||
{
|
||||
showBuffs(activeChar, (L2Character) activeChar.getTarget(), 1, command.endsWith("_ps"));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_stopbuff"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
final int objectId = Integer.parseInt(st.nextToken());
|
||||
final int skillId = Integer.parseInt(st.nextToken());
|
||||
|
||||
removeBuff(activeChar, objectId, skillId);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed removing effect: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //stopbuff <objectId> <skillId>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_stopallbuffs"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
final int objectId = Integer.parseInt(st.nextToken());
|
||||
removeAllBuffs(activeChar, objectId);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed removing all effects: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //stopallbuffs <objectId>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_areacancel"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
final String val = st.nextToken();
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(val);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (knownChar.isPlayer() && !knownChar.equals(activeChar))
|
||||
{
|
||||
knownChar.stopAllEffects();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("All effects canceled within radius " + radius);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //areacancel <radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_removereuse"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
L2Character creature = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
creature = L2World.getInstance().getPlayer(st.nextToken());
|
||||
if (creature == null)
|
||||
{
|
||||
activeChar.sendMessage("The player " + creature + " is not online.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target != null) && target.isCharacter())
|
||||
{
|
||||
creature = (L2Character) target;
|
||||
}
|
||||
|
||||
if (creature == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
creature.resetTimeStamps();
|
||||
creature.resetDisabledSkills();
|
||||
if (creature.isPlayer())
|
||||
{
|
||||
creature.sendPacket(new SkillCoolTime(creature.getActingPlayer()));
|
||||
}
|
||||
activeChar.sendMessage("Skill reuse was removed from " + creature.getName() + ".");
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_switch_gm_buffs"))
|
||||
{
|
||||
if (Config.GM_GIVE_SPECIAL_SKILLS != Config.GM_GIVE_SPECIAL_AURA_SKILLS)
|
||||
{
|
||||
final boolean toAuraSkills = activeChar.getKnownSkill(7041) != null;
|
||||
switchSkills(activeChar, toAuraSkills);
|
||||
activeChar.sendSkillList();
|
||||
activeChar.sendMessage("You have succefully changed to target " + (toAuraSkills ? "aura" : "one") + " special skills.");
|
||||
return true;
|
||||
}
|
||||
activeChar.sendMessage("There is nothing to switch.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gmchar the player to switch the Game Master skills.
|
||||
* @param toAuraSkills if {@code true} it will remove "GM Aura" skills and add "GM regular" skills, vice versa if {@code false}.
|
||||
*/
|
||||
private static void switchSkills(L2PcInstance gmchar, boolean toAuraSkills)
|
||||
{
|
||||
final Collection<Skill> skills = toAuraSkills ? SkillTreesData.getInstance().getGMSkillTree().values() : SkillTreesData.getInstance().getGMAuraSkillTree().values();
|
||||
for (Skill skill : skills)
|
||||
{
|
||||
gmchar.removeSkill(skill, false); // Don't Save GM skills to database
|
||||
}
|
||||
SkillTreesData.getInstance().addSkills(gmchar, toAuraSkills);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private static void showBuffs(L2PcInstance activeChar, L2Character target, int page, boolean passive)
|
||||
{
|
||||
final List<BuffInfo> effects = new ArrayList<>();
|
||||
if (!passive)
|
||||
{
|
||||
effects.addAll(target.getEffectList().getEffects());
|
||||
}
|
||||
else
|
||||
{
|
||||
effects.addAll(target.getEffectList().getPassives());
|
||||
}
|
||||
|
||||
if ((page > ((effects.size() / PAGE_LIMIT) + 1)) || (page < 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int max = effects.size() / PAGE_LIMIT;
|
||||
if (effects.size() > (PAGE_LIMIT * max))
|
||||
{
|
||||
max++;
|
||||
}
|
||||
|
||||
final StringBuilder html = StringUtil.startAppend(500 + (effects.size() * 200), "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center><font color=\"LEVEL\">Effects of ", target.getName(), "</font></td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><table width=\"100%\"><tr><td width=200>Skill</td><td width=30>Rem. Time</td><td width=70>Action</td></tr>");
|
||||
final int start = (page - 1) * PAGE_LIMIT;
|
||||
final int end = Math.min(((page - 1) * PAGE_LIMIT) + PAGE_LIMIT, effects.size());
|
||||
int count = 0;
|
||||
for (BuffInfo info : effects)
|
||||
{
|
||||
if ((count >= start) && (count < end))
|
||||
{
|
||||
final Skill skill = info.getSkill();
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
StringUtil.append(html, "<tr><td>", (!info.isInUse() ? FONT_RED1 : "") + skill.getName(), " Lv ", String.valueOf(skill.getLevel()), " (", effect.getClass().getSimpleName(), ")" + (!info.isInUse() ? FONT_RED2 : ""), "</td><td>", skill.isToggle() ? "T (" + info.getTickCount(effect) + ")" : skill.isPassive() ? "P" : info.getTime() + "s", "</td><td><button value=\"X\" action=\"bypass -h admin_stopbuff ", Integer.toString(target.getObjectId()), " ", String.valueOf(skill.getId()), "\" width=30 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
html.append("</table><table width=300 bgcolor=444444><tr>");
|
||||
for (int x = 0; x < max; x++)
|
||||
{
|
||||
final int pagenr = x + 1;
|
||||
if (page == pagenr)
|
||||
{
|
||||
html.append("<td>Page ");
|
||||
html.append(pagenr);
|
||||
html.append("</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.append("<td><a action=\"bypass -h admin_getbuffs" + (passive ? "_ps " : " "));
|
||||
html.append(target.getName());
|
||||
html.append(" ");
|
||||
html.append(x + 1);
|
||||
html.append("\"> Page ");
|
||||
html.append(pagenr);
|
||||
html.append(" </a></td>");
|
||||
}
|
||||
}
|
||||
|
||||
html.append("</tr></table>");
|
||||
|
||||
// Buttons
|
||||
StringUtil.append(html, "<br><center><button value=\"Refresh\" action=\"bypass -h admin_getbuffs", passive ? "_ps " : " ", target.getName(), "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
StringUtil.append(html, "<button value=\"Remove All\" action=\"bypass -h admin_stopallbuffs ", Integer.toString(target.getObjectId()), "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>");
|
||||
// Legend
|
||||
if (!passive)
|
||||
{
|
||||
StringUtil.append(html, FONT_RED1, "Inactive buffs: ", String.valueOf(target.getEffectList().getHiddenBuffsCount()), FONT_RED2, "<br>");
|
||||
}
|
||||
StringUtil.append(html, "Total", passive ? " passive" : "", " buff count: ", String.valueOf(effects.size()));
|
||||
if ((target.getEffectList().getAllBlockedBuffSlots() != null) && !target.getEffectList().getAllBlockedBuffSlots().isEmpty())
|
||||
{
|
||||
StringUtil.append(html, "<br>Blocked buff slots: ");
|
||||
String slots = "";
|
||||
for (AbnormalType slot : target.getEffectList().getAllBlockedBuffSlots())
|
||||
{
|
||||
slots += slot.toString() + ", ";
|
||||
}
|
||||
|
||||
if (!slots.isEmpty() && (slots.length() > 3))
|
||||
{
|
||||
StringUtil.append(html, slots.substring(0, slots.length() - 2));
|
||||
}
|
||||
}
|
||||
StringUtil.append(html, "</html>");
|
||||
// Send the packet
|
||||
activeChar.sendPacket(new NpcHtmlMessage(html.toString()));
|
||||
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "getbuffs", target.getName() + " (" + Integer.toString(target.getObjectId()) + ")", "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeBuff(L2PcInstance activeChar, int objId, int skillId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if ((target != null) && (skillId > 0))
|
||||
{
|
||||
if (target.isAffectedBySkill(skillId))
|
||||
{
|
||||
target.stopSkillEffects(true, skillId);
|
||||
activeChar.sendMessage("Removed skill ID: " + skillId + " effects from " + target.getName() + " (" + objId + ").");
|
||||
}
|
||||
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopbuff", target.getName() + " (" + objId + ")", Integer.toString(skillId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAllBuffs(L2PcInstance activeChar, int objId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target.stopAllEffects();
|
||||
activeChar.sendMessage("Removed all effects from " + target.getName() + " (" + objId + ")");
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopallbuffs", target.getName() + " (" + objId + ")", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jmobius.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jmobius.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
public class AdminBuffs implements IAdminCommandHandler
|
||||
{
|
||||
private final static int PAGE_LIMIT = 20;
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_buff",
|
||||
"admin_getbuffs",
|
||||
"admin_getbuffs_ps",
|
||||
"admin_stopbuff",
|
||||
"admin_stopallbuffs",
|
||||
"admin_areacancel",
|
||||
"admin_removereuse",
|
||||
"admin_switch_gm_buffs"
|
||||
};
|
||||
// Misc
|
||||
private static final String FONT_RED1 = "<font color=\"FF0000\">";
|
||||
private static final String FONT_RED2 = "</font>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_buff"))
|
||||
{
|
||||
if ((activeChar.getTarget() == null) || !activeChar.getTarget().isCharacter())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Skill Id and level are not specified.");
|
||||
activeChar.sendMessage("Usage: //buff <skillId> <skillLevel>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final int skillId = Integer.parseInt(st.nextToken());
|
||||
final int skillLevel = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : SkillData.getInstance().getMaxLevel(skillId);
|
||||
final L2Character target = (L2Character) activeChar.getTarget();
|
||||
final Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
|
||||
if (skill == null)
|
||||
{
|
||||
activeChar.sendMessage("Skill with id: " + skillId + ", lvl: " + skillLevel + " not found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Admin buffing " + skill.getName() + " (" + skillId + "," + skillLevel + ")");
|
||||
skill.applyEffects(activeChar, target);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed buffing: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //buff <skillId> <skillLevel>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_getbuffs"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String playername = st.nextToken();
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(playername);
|
||||
if (player != null)
|
||||
{
|
||||
int page = 1;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
page = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
showBuffs(activeChar, player, page, command.endsWith("_ps"));
|
||||
return true;
|
||||
}
|
||||
activeChar.sendMessage("The player " + playername + " is not online.");
|
||||
return false;
|
||||
}
|
||||
else if ((activeChar.getTarget() != null) && activeChar.getTarget().isCharacter())
|
||||
{
|
||||
showBuffs(activeChar, (L2Character) activeChar.getTarget(), 1, command.endsWith("_ps"));
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_stopbuff"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
final int objectId = Integer.parseInt(st.nextToken());
|
||||
final int skillId = Integer.parseInt(st.nextToken());
|
||||
|
||||
removeBuff(activeChar, objectId, skillId);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed removing effect: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //stopbuff <objectId> <skillId>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_stopallbuffs"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
final int objectId = Integer.parseInt(st.nextToken());
|
||||
removeAllBuffs(activeChar, objectId);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed removing all effects: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //stopallbuffs <objectId>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_areacancel"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
final String val = st.nextToken();
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(val);
|
||||
|
||||
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, L2Character::stopAllEffects);
|
||||
|
||||
activeChar.sendMessage("All effects canceled within radius " + radius);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //areacancel <radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_removereuse"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
L2PcInstance player = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String playername = st.nextToken();
|
||||
|
||||
try
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(playername);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendMessage("The player " + playername + " is not online.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
player = activeChar.getTarget().getActingPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.resetTimeStamps();
|
||||
player.resetDisabledSkills();
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
activeChar.sendMessage("Skill reuse was removed from " + player.getName() + ".");
|
||||
return true;
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_switch_gm_buffs"))
|
||||
{
|
||||
if (Config.GM_GIVE_SPECIAL_SKILLS != Config.GM_GIVE_SPECIAL_AURA_SKILLS)
|
||||
{
|
||||
final boolean toAuraSkills = activeChar.getKnownSkill(7041) != null;
|
||||
switchSkills(activeChar, toAuraSkills);
|
||||
activeChar.sendSkillList();
|
||||
activeChar.sendMessage("You have succefully changed to target " + (toAuraSkills ? "aura" : "one") + " special skills.");
|
||||
return true;
|
||||
}
|
||||
activeChar.sendMessage("There is nothing to switch.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gmchar the player to switch the Game Master skills.
|
||||
* @param toAuraSkills if {@code true} it will remove "GM Aura" skills and add "GM regular" skills, vice versa if {@code false}.
|
||||
*/
|
||||
public static void switchSkills(L2PcInstance gmchar, boolean toAuraSkills)
|
||||
{
|
||||
final Collection<Skill> skills = toAuraSkills ? SkillTreesData.getInstance().getGMSkillTree().values() : SkillTreesData.getInstance().getGMAuraSkillTree().values();
|
||||
for (Skill skill : skills)
|
||||
{
|
||||
gmchar.removeSkill(skill, false); // Don't Save GM skills to database
|
||||
}
|
||||
SkillTreesData.getInstance().addSkills(gmchar, toAuraSkills);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
public static void showBuffs(L2PcInstance activeChar, L2Character target, int page, boolean passive)
|
||||
{
|
||||
final List<BuffInfo> effects = new ArrayList<>();
|
||||
if (!passive)
|
||||
{
|
||||
effects.addAll(target.getEffectList().getEffects());
|
||||
}
|
||||
else
|
||||
{
|
||||
effects.addAll(target.getEffectList().getPassives());
|
||||
}
|
||||
|
||||
if ((page > ((effects.size() / PAGE_LIMIT) + 1)) || (page < 1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int max = effects.size() / PAGE_LIMIT;
|
||||
if (effects.size() > (PAGE_LIMIT * max))
|
||||
{
|
||||
max++;
|
||||
}
|
||||
|
||||
final StringBuilder html = new StringBuilder(500 + (effects.size() * 200));
|
||||
html.append("<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center><font color=\"LEVEL\">Effects of ");
|
||||
html.append(target.getName());
|
||||
html.append("</font></td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><table width=\"100%\"><tr><td width=200>Skill</td><td width=30>Rem. Time</td><td width=70>Action</td></tr>");
|
||||
|
||||
final int start = ((page - 1) * PAGE_LIMIT);
|
||||
final int end = Math.min(((page - 1) * PAGE_LIMIT) + PAGE_LIMIT, effects.size());
|
||||
int count = 0;
|
||||
for (BuffInfo info : effects)
|
||||
{
|
||||
if ((count >= start) && (count < end))
|
||||
{
|
||||
final Skill skill = info.getSkill();
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
html.append("<tr><td>");
|
||||
html.append(!info.isInUse() ? FONT_RED1 : "");
|
||||
html.append(skill.getName());
|
||||
html.append(" Lv ");
|
||||
html.append(skill.getLevel());
|
||||
html.append(" (");
|
||||
html.append(effect.getClass().getSimpleName());
|
||||
html.append(")");
|
||||
html.append(!info.isInUse() ? FONT_RED2 : "");
|
||||
html.append("</td><td>");
|
||||
html.append(skill.isToggle() ? "T (" + info.getTickCount(effect) + ")" : skill.isPassive() ? "P" : info.getTime() + "s");
|
||||
html.append("</td><td><button value=\"X\" action=\"bypass -h admin_stopbuff ");
|
||||
html.append(target.getObjectId());
|
||||
html.append(" ");
|
||||
html.append(skill.getId());
|
||||
html.append("\" width=30 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
html.append("</table><table width=300 bgcolor=444444><tr>");
|
||||
for (int x = 0; x < max; x++)
|
||||
{
|
||||
final int pagenr = x + 1;
|
||||
if (page == pagenr)
|
||||
{
|
||||
html.append("<td>Page ");
|
||||
html.append(pagenr);
|
||||
html.append("</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.append("<td><a action=\"bypass -h admin_getbuffs" + (passive ? "_ps " : " "));
|
||||
html.append(target.getName());
|
||||
html.append(" ");
|
||||
html.append(x + 1);
|
||||
html.append("\"> Page ");
|
||||
html.append(pagenr);
|
||||
html.append(" </a></td>");
|
||||
}
|
||||
}
|
||||
|
||||
html.append("</tr></table>");
|
||||
|
||||
// Buttons
|
||||
html.append("<br><center><button value=\"Refresh\" action=\"bypass -h admin_getbuffs");
|
||||
html.append(passive ? "_ps " : " ");
|
||||
html.append(target.getName());
|
||||
html.append("\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
html.append("<button value=\"Remove All\" action=\"bypass -h admin_stopallbuffs ");
|
||||
html.append(target.getObjectId());
|
||||
html.append("\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>");
|
||||
// Legend
|
||||
if (!passive)
|
||||
{
|
||||
html.append(FONT_RED1);
|
||||
html.append("Inactive buffs: ");
|
||||
html.append(target.getEffectList().getHiddenBuffsCount());
|
||||
html.append(FONT_RED2);
|
||||
html.append("<br>");
|
||||
}
|
||||
html.append("Total");
|
||||
html.append(passive ? " passive" : "");
|
||||
html.append(" buff count: ");
|
||||
html.append(effects.size());
|
||||
if ((target.getEffectList().getBlockedAbnormalTypes() != null) && !target.getEffectList().getBlockedAbnormalTypes().isEmpty())
|
||||
{
|
||||
html.append("<br>Blocked buff slots: ");
|
||||
String slots = "";
|
||||
for (AbnormalType slot : target.getEffectList().getBlockedAbnormalTypes())
|
||||
{
|
||||
slots += slot.toString() + ", ";
|
||||
}
|
||||
|
||||
if (!slots.isEmpty() && (slots.length() > 3))
|
||||
{
|
||||
html.append(slots.substring(0, slots.length() - 2));
|
||||
}
|
||||
}
|
||||
html.append("</html>");
|
||||
// Send the packet
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, html.toString()));
|
||||
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "getbuffs", target.getName() + " (" + Integer.toString(target.getObjectId()) + ")", "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeBuff(L2PcInstance activeChar, int objId, int skillId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if ((target != null) && (skillId > 0))
|
||||
{
|
||||
if (target.isAffectedBySkill(skillId))
|
||||
{
|
||||
target.stopSkillEffects(true, skillId);
|
||||
activeChar.sendMessage("Removed skill ID: " + skillId + " effects from " + target.getName() + " (" + objId + ").");
|
||||
}
|
||||
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopbuff", target.getName() + " (" + objId + ")", Integer.toString(skillId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAllBuffs(L2PcInstance activeChar, int objId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target.stopAllEffects();
|
||||
activeChar.sendMessage("Removed all effects from " + target.getName() + " (" + objId + ")");
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopallbuffs", target.getName() + " (" + objId + ")", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,384 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Calendar;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.ClanHallSiegeEngine;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SiegeInfo;
|
||||
|
||||
/**
|
||||
* @author BiggBoss
|
||||
*/
|
||||
public final class AdminCHSiege implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"admin_chsiege_siegablehall",
|
||||
"admin_chsiege_startSiege",
|
||||
"admin_chsiege_endsSiege",
|
||||
"admin_chsiege_setSiegeDate",
|
||||
"admin_chsiege_addAttacker",
|
||||
"admin_chsiege_removeAttacker",
|
||||
"admin_chsiege_clearAttackers",
|
||||
"admin_chsiege_listAttackers",
|
||||
"admin_chsiege_forwardSiege"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] split = command.split(" ");
|
||||
SiegableHall hall = null;
|
||||
if (Config.ALT_DEV_NO_QUESTS)
|
||||
{
|
||||
activeChar.sendMessage("AltDevNoQuests = true; Clan Hall Sieges are disabled!");
|
||||
return false;
|
||||
}
|
||||
if (split.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("You have to specify the hall id at least");
|
||||
return false;
|
||||
}
|
||||
if ((hall = getHall(split[1], activeChar)) == null)
|
||||
{
|
||||
activeChar.sendMessage("Couldnt find he desired siegable hall (" + split[1] + ")");
|
||||
return false;
|
||||
}
|
||||
if (hall.getSiege() == null)
|
||||
{
|
||||
activeChar.sendMessage("The given hall dont have any attached siege!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (split[0].equals(COMMANDS[1]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested clan hall is alredy in siege!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
hall.free();
|
||||
owner.setHideoutId(0);
|
||||
hall.addAttacker(owner);
|
||||
}
|
||||
hall.getSiege().startSiege();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[2]))
|
||||
{
|
||||
if (!hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested clan hall isnt in siege!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.getSiege().endSiege();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[3]))
|
||||
{
|
||||
if (!hall.isRegistering())
|
||||
{
|
||||
activeChar.sendMessage("Cannot change siege date while hall is in siege");
|
||||
}
|
||||
else if (split.length < 3)
|
||||
{
|
||||
activeChar.sendMessage("The date format is incorrect. Try again.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] rawDate = split[2].split(";");
|
||||
if (rawDate.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("You have to specify this format DD-MM-YYYY;HH:MM");
|
||||
}
|
||||
else
|
||||
{
|
||||
final String[] day = rawDate[0].split("-");
|
||||
final String[] hour = rawDate[1].split(":");
|
||||
if ((day.length < 3) || (hour.length < 2))
|
||||
{
|
||||
activeChar.sendMessage("Incomplete day, hour or both!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int d = parseInt(day[0]);
|
||||
final int month = parseInt(day[1]) - 1;
|
||||
final int year = parseInt(day[2]);
|
||||
final int h = parseInt(hour[0]);
|
||||
final int min = parseInt(hour[1]);
|
||||
if (((month == 2) && (d > 28)) || (d > 31) || (d <= 0) || (month <= 0) || (month > 12) || (year < Calendar.getInstance().get(Calendar.YEAR)))
|
||||
{
|
||||
activeChar.sendMessage("Wrong day/month/year gave!");
|
||||
}
|
||||
else if ((h <= 0) || (h > 24) || (min < 0) || (min >= 60))
|
||||
{
|
||||
activeChar.sendMessage("Wrong hour/minutes gave!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.YEAR, year);
|
||||
c.set(Calendar.MONTH, month);
|
||||
c.set(Calendar.DAY_OF_MONTH, d);
|
||||
c.set(Calendar.HOUR_OF_DAY, h);
|
||||
c.set(Calendar.MINUTE, min);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
|
||||
if (c.getTimeInMillis() > System.currentTimeMillis())
|
||||
{
|
||||
activeChar.sendMessage(hall.getName() + " siege: " + c.getTime().toString());
|
||||
hall.setNextSiegeDate(c.getTimeInMillis());
|
||||
hall.getSiege().updateSiege();
|
||||
hall.updateDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The given time is in the past!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[4]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The clan hall is in siege, cannot add attackers now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
L2Clan attacker = null;
|
||||
if (split.length < 3)
|
||||
{
|
||||
final L2Object rawTarget = activeChar.getTarget();
|
||||
L2PcInstance target = null;
|
||||
if (rawTarget == null)
|
||||
{
|
||||
activeChar.sendMessage("You must target a clan member of the attacker!");
|
||||
}
|
||||
else if (!(rawTarget instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You must target a player with clan!");
|
||||
}
|
||||
else if ((target = (L2PcInstance) rawTarget).getClan() == null)
|
||||
{
|
||||
activeChar.sendMessage("Your target does not have any clan!");
|
||||
}
|
||||
else if (hall.getSiege().checkIsAttacker(target.getClan()))
|
||||
{
|
||||
activeChar.sendMessage("Your target's clan is alredy participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker = target.getClan();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Clan rawClan = ClanTable.getInstance().getClanByName(split[2]);
|
||||
if (rawClan == null)
|
||||
{
|
||||
activeChar.sendMessage("The given clan does not exist!");
|
||||
}
|
||||
else if (hall.getSiege().checkIsAttacker(rawClan))
|
||||
{
|
||||
activeChar.sendMessage("The given clan is alredy participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker = rawClan;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null)
|
||||
{
|
||||
hall.addAttacker(attacker);
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[5]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The clan hall is in siege, cannot remove attackers now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (split.length < 3)
|
||||
{
|
||||
final L2Object rawTarget = activeChar.getTarget();
|
||||
L2PcInstance target = null;
|
||||
if (rawTarget == null)
|
||||
{
|
||||
activeChar.sendMessage("You must target a clan member of the attacker!");
|
||||
}
|
||||
else if (!(rawTarget instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You must target a player with clan!");
|
||||
}
|
||||
else if ((target = (L2PcInstance) rawTarget).getClan() == null)
|
||||
{
|
||||
activeChar.sendMessage("Your target does not have any clan!");
|
||||
}
|
||||
else if (!hall.getSiege().checkIsAttacker(target.getClan()))
|
||||
{
|
||||
activeChar.sendMessage("Your target's clan is not participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.removeAttacker(target.getClan());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Clan rawClan = ClanTable.getInstance().getClanByName(split[2]);
|
||||
if (rawClan == null)
|
||||
{
|
||||
activeChar.sendMessage("The given clan does not exist!");
|
||||
}
|
||||
else if (!hall.getSiege().checkIsAttacker(rawClan))
|
||||
{
|
||||
activeChar.sendMessage("The given clan is not participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.removeAttacker(rawClan);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[6]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested hall is in siege right now, cannot clear attacker list!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.getSiege().getAttackers().clear();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[7]))
|
||||
{
|
||||
activeChar.sendPacket(new SiegeInfo(hall));
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[8]))
|
||||
{
|
||||
final ClanHallSiegeEngine siegable = hall.getSiege();
|
||||
siegable.cancelSiegeTask();
|
||||
switch (hall.getSiegeStatus())
|
||||
{
|
||||
case REGISTERING:
|
||||
{
|
||||
siegable.prepareOwner();
|
||||
break;
|
||||
}
|
||||
case WAITING_BATTLE:
|
||||
{
|
||||
siegable.startSiege();
|
||||
break;
|
||||
}
|
||||
case RUNNING:
|
||||
{
|
||||
siegable.endSiege();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendSiegableHallPage(activeChar, split[1], hall);
|
||||
return false;
|
||||
}
|
||||
|
||||
private SiegableHall getHall(String id, L2PcInstance gm)
|
||||
{
|
||||
final int ch = parseInt(id);
|
||||
if (ch == 0)
|
||||
{
|
||||
gm.sendMessage("Wrong clan hall id, unparseable id!");
|
||||
return null;
|
||||
}
|
||||
|
||||
final SiegableHall hall = CHSiegeManager.getInstance().getSiegableHall(ch);
|
||||
|
||||
if (hall == null)
|
||||
{
|
||||
gm.sendMessage("Couldnt find the clan hall.");
|
||||
}
|
||||
|
||||
return hall;
|
||||
}
|
||||
|
||||
private int parseInt(String st)
|
||||
{
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(st);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
private void sendSiegableHallPage(L2PcInstance activeChar, String hallId, SiegableHall hall)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(null, "html/admin/siegablehall.htm");
|
||||
msg.replace("%clanhallId%", hallId);
|
||||
msg.replace("%clanhallName%", hall.getName());
|
||||
if (hall.getOwnerId() > 0)
|
||||
{
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
msg.replace("%clanhallOwner%", owner.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
@@ -1,261 +1,262 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.CastleSide;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Castle manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminCastle implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_castlemanage",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_castlemanage"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String param = st.nextToken();
|
||||
final Castle castle;
|
||||
if (Util.isDigit(param))
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastleById(Integer.parseInt(param));
|
||||
}
|
||||
else
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastle(param);
|
||||
}
|
||||
|
||||
if (castle == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters! Usage: //castlemanage <castleId[1-9] / castleName>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
final L2PcInstance target = checkTarget(activeChar) ? activeChar.getActingPlayer() : null;
|
||||
switch (action)
|
||||
{
|
||||
case "showRegWindow":
|
||||
{
|
||||
castle.getSiege().listRegisterClan(activeChar);
|
||||
break;
|
||||
}
|
||||
case "addAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerAttacker(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "addDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerDefender(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "startSiege":
|
||||
{
|
||||
if (!castle.getSiege().getAttackerClans().isEmpty())
|
||||
{
|
||||
castle.getSiege().startSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("There is currently not registered any clan for castle siege!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "stopSiege":
|
||||
{
|
||||
if (castle.getSiege().isInProgress())
|
||||
{
|
||||
castle.getSiege().endSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Castle siege is not currently in progress!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "setOwner":
|
||||
{
|
||||
if ((target == null) || !checkTarget(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else if (target.getClan().getCastleId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("This clan already have castle!");
|
||||
}
|
||||
else if (castle.getOwner() != null)
|
||||
{
|
||||
activeChar.sendMessage("This castle is already taken by another clan!");
|
||||
}
|
||||
else if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final CastleSide side = Enum.valueOf(CastleSide.class, st.nextToken().toUpperCase());
|
||||
if (side != null)
|
||||
{
|
||||
castle.setSide(side);
|
||||
castle.setOwner(target.getClan());
|
||||
}
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "takeCastle":
|
||||
{
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
|
||||
if (clan != null)
|
||||
{
|
||||
castle.removeOwner(clan);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error during removing castle!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "switchSide":
|
||||
{
|
||||
if (castle.getSide() == CastleSide.DARK)
|
||||
{
|
||||
castle.setSide(CastleSide.LIGHT);
|
||||
}
|
||||
else if (castle.getSide() == CastleSide.LIGHT)
|
||||
{
|
||||
castle.setSide(CastleSide.DARK);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You can't switch sides when is castle neutral!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/castlemanage.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showCastleMenu(L2PcInstance player, int castleId)
|
||||
{
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
|
||||
|
||||
if (castle != null)
|
||||
{
|
||||
final L2Clan ownerClan = castle.getOwner();
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "html/admin/castlemanage_selected.htm"));
|
||||
html.replace("%castleId%", castle.getResidenceId());
|
||||
html.replace("%castleName%", castle.getName());
|
||||
html.replace("%ownerName%", ownerClan != null ? ownerClan.getLeaderName() : "NPC");
|
||||
html.replace("%ownerClan%", ownerClan != null ? ownerClan.getName() : "NPC");
|
||||
html.replace("%castleSide%", Util.capitalizeFirst(castle.getSide().toString().toLowerCase()));
|
||||
player.sendPacket(html);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkTarget(L2PcInstance player)
|
||||
{
|
||||
return (player.getTarget() != null) && player.getTarget().isPlayer() && (((L2PcInstance) player.getTarget()).getClan() != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.CastleSide;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Castle manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminCastle implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_castlemanage",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_castlemanage"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String param = st.nextToken();
|
||||
final Castle castle;
|
||||
if (Util.isDigit(param))
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastleById(Integer.parseInt(param));
|
||||
}
|
||||
else
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastle(param);
|
||||
}
|
||||
|
||||
if (castle == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters! Usage: //castlemanage <castleId[1-9] / castleName>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
final L2PcInstance target = checkTarget(activeChar) ? activeChar.getActingPlayer() : null;
|
||||
switch (action)
|
||||
{
|
||||
case "showRegWindow":
|
||||
{
|
||||
castle.getSiege().listRegisterClan(activeChar);
|
||||
break;
|
||||
}
|
||||
case "addAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerAttacker(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "addDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerDefender(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "startSiege":
|
||||
{
|
||||
if (!castle.getSiege().getAttackerClans().isEmpty())
|
||||
{
|
||||
castle.getSiege().startSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("There is currently not registered any clan for castle siege!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "stopSiege":
|
||||
{
|
||||
if (castle.getSiege().isInProgress())
|
||||
{
|
||||
castle.getSiege().endSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Castle siege is not currently in progress!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "setOwner":
|
||||
{
|
||||
if ((target == null) || !checkTarget(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else if (target.getClan().getCastleId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("This clan already have castle!");
|
||||
}
|
||||
else if (castle.getOwner() != null)
|
||||
{
|
||||
activeChar.sendMessage("This castle is already taken by another clan!");
|
||||
}
|
||||
else if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final CastleSide side = Enum.valueOf(CastleSide.class, st.nextToken().toUpperCase());
|
||||
if (side != null)
|
||||
{
|
||||
castle.setSide(side);
|
||||
castle.setOwner(target.getClan());
|
||||
}
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "takeCastle":
|
||||
{
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
|
||||
if (clan != null)
|
||||
{
|
||||
castle.removeOwner(clan);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error during removing castle!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "switchSide":
|
||||
{
|
||||
if (castle.getSide() == CastleSide.DARK)
|
||||
{
|
||||
castle.setSide(CastleSide.LIGHT);
|
||||
}
|
||||
else if (castle.getSide() == CastleSide.LIGHT)
|
||||
{
|
||||
castle.setSide(CastleSide.DARK);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You can't switch sides when is castle neutral!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/castlemanage.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showCastleMenu(L2PcInstance player, int castleId)
|
||||
{
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
|
||||
|
||||
if (castle != null)
|
||||
{
|
||||
final L2Clan ownerClan = castle.getOwner();
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/admin/castlemanage_selected.htm"));
|
||||
html.replace("%castleId%", castle.getResidenceId());
|
||||
html.replace("%castleName%", castle.getName());
|
||||
html.replace("%ownerName%", ownerClan != null ? ownerClan.getLeaderName() : "NPC");
|
||||
html.replace("%ownerClan%", ownerClan != null ? ownerClan.getName() : "NPC");
|
||||
html.replace("%castleSide%", CommonUtil.capitalizeFirst(castle.getSide().toString().toLowerCase()));
|
||||
player.sendPacket(html);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkTarget(L2PcInstance player)
|
||||
{
|
||||
return ((player.getTarget() != null) && player.getTarget().isPlayer() && (((L2PcInstance) player.getTarget()).getClan() != null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,139 +1,140 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2AccessLevel;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Change access level command handler.
|
||||
*/
|
||||
public final class AdminChangeAccessLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_changelvl"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int lvl = Integer.parseInt(parts[1]);
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
onlineChange(activeChar, (L2PcInstance) activeChar.getTarget(), lvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //changelvl <target_new_level> | <player_name> <new_level>");
|
||||
}
|
||||
}
|
||||
else if (parts.length == 3)
|
||||
{
|
||||
final String name = parts[1];
|
||||
final int lvl = Integer.parseInt(parts[2]);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
onlineChange(activeChar, player, lvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?"))
|
||||
{
|
||||
ps.setInt(1, lvl);
|
||||
ps.setString(2, name);
|
||||
ps.execute();
|
||||
|
||||
if (ps.getUpdateCount() == 0)
|
||||
{
|
||||
activeChar.sendMessage("Character not found or access level unaltered.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Character's access level is now set to " + lvl);
|
||||
}
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while changing character's access level");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar the active GM
|
||||
* @param player the online target
|
||||
* @param lvl the access level
|
||||
*/
|
||||
private static void onlineChange(L2PcInstance activeChar, L2PcInstance player, int lvl)
|
||||
{
|
||||
if (lvl >= 0)
|
||||
{
|
||||
if (AdminData.getInstance().hasAccessLevel(lvl))
|
||||
{
|
||||
final L2AccessLevel acccessLevel = AdminData.getInstance().getAccessLevel(lvl);
|
||||
player.setAccessLevel(lvl, true);
|
||||
player.sendMessage("Your access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
activeChar.sendMessage(player.getName() + "'s access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You are trying to set unexisting access level: " + lvl + " please try again with a valid one!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAccessLevel(lvl, false);
|
||||
player.sendMessage("Your character has been banned. Bye.");
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2AccessLevel;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Change access level command handler.
|
||||
*/
|
||||
public final class AdminChangeAccessLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_changelvl"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int lvl = Integer.parseInt(parts[1]);
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
onlineChange(activeChar, (L2PcInstance) activeChar.getTarget(), lvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //changelvl <target_new_level> | <player_name> <new_level>");
|
||||
}
|
||||
}
|
||||
else if (parts.length == 3)
|
||||
{
|
||||
final String name = parts[1];
|
||||
final int lvl = Integer.parseInt(parts[2]);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
onlineChange(activeChar, player, lvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
|
||||
statement.setInt(1, lvl);
|
||||
statement.setString(2, name);
|
||||
statement.execute();
|
||||
final int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
if (count == 0)
|
||||
{
|
||||
activeChar.sendMessage("Character not found or access level unaltered.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Character's access level is now set to " + lvl);
|
||||
}
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while changing character's access level");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
se.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar the active GM
|
||||
* @param player the online target
|
||||
* @param lvl the access level
|
||||
*/
|
||||
private static void onlineChange(L2PcInstance activeChar, L2PcInstance player, int lvl)
|
||||
{
|
||||
if (lvl >= 0)
|
||||
{
|
||||
final L2AccessLevel acccessLevel = AdminData.getInstance().getAccessLevel(lvl);
|
||||
if (acccessLevel != null)
|
||||
{
|
||||
player.setAccessLevel(lvl, true, true);
|
||||
player.sendMessage("Your access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
activeChar.sendMessage(player.getName() + "'s access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You are trying to set unexisting access level: " + lvl + " please try again with a valid one!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAccessLevel(lvl, false, true);
|
||||
player.sendMessage("Your character has been banned. Bye.");
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,221 +1,221 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2ClanMember;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, Zoey76
|
||||
*/
|
||||
public class AdminClan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clan_info",
|
||||
"admin_clan_changeleader",
|
||||
"admin_clan_show_pending",
|
||||
"admin_clan_force_pending"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_clan_info":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/claninfo.htm"));
|
||||
html.replace("%clan_name%", clan.getName());
|
||||
html.replace("%clan_leader%", clan.getLeaderName());
|
||||
html.replace("%clan_level%", String.valueOf(clan.getLevel()));
|
||||
html.replace("%clan_has_castle%", clan.getCastleId() > 0 ? CastleManager.getInstance().getCastleById(clan.getCastleId()).getName() : "No");
|
||||
html.replace("%clan_has_clanhall%", clan.getHideoutId() > 0 ? ClanHallManager.getInstance().getClanHallById(clan.getHideoutId()).getName() : "No");
|
||||
html.replace("%clan_has_fortress%", clan.getFortId() > 0 ? FortManager.getInstance().getFortById(clan.getFortId()).getName() : "No");
|
||||
html.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
|
||||
html.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
|
||||
html.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
|
||||
html.replace("%current_player_objectId%", String.valueOf(player.getObjectId()));
|
||||
html.replace("%current_player_name%", player.getName());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_clan_changeleader":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2ClanMember member = clan.getClanMember(player.getObjectId());
|
||||
if (member != null)
|
||||
{
|
||||
if (player.isAcademyMember())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_PRIVILEGE_CANNOT_BE_GRANTED_TO_A_CLAN_ACADEMY_MEMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
clan.setNewLeader(member);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_clan_show_pending":
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/clanchanges.htm"));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (L2Clan clan : ClanTable.getInstance().getClans())
|
||||
{
|
||||
if (clan.getNewLeaderId() != 0)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td>" + clan.getName() + "</td>");
|
||||
sb.append("<td>" + clan.getNewLeaderName() + "</td>");
|
||||
sb.append("<td><a action=\"bypass -h admin_clan_force_pending " + clan.getId() + "\">Force</a></td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
}
|
||||
html.replace("%data%", sb.toString());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_clan_force_pending":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
break;
|
||||
}
|
||||
final int clanId = Integer.parseInt(token);
|
||||
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(clanId);
|
||||
if (clan == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2ClanMember member = clan.getClanMember(clan.getNewLeaderId());
|
||||
if (member == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
clan.setNewLeader(member);
|
||||
activeChar.sendMessage("Task have been forcely executed.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param st
|
||||
* @return
|
||||
*/
|
||||
private L2PcInstance getPlayer(L2PcInstance activeChar, StringTokenizer st)
|
||||
{
|
||||
String val;
|
||||
L2PcInstance player = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
val = st.nextToken();
|
||||
// From the HTML we receive player's object Id.
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(Integer.parseInt(val));
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(val);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_PLEASE_TRY_AGAIN);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object targetObj = activeChar.getTarget();
|
||||
if (targetObj instanceof L2PcInstance)
|
||||
{
|
||||
player = targetObj.getActingPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2ClanMember;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, Zoey76
|
||||
*/
|
||||
public class AdminClan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clan_info",
|
||||
"admin_clan_changeleader",
|
||||
"admin_clan_show_pending",
|
||||
"admin_clan_force_pending"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_clan_info":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/claninfo.htm"));
|
||||
html.replace("%clan_name%", clan.getName());
|
||||
html.replace("%clan_leader%", clan.getLeaderName());
|
||||
html.replace("%clan_level%", String.valueOf(clan.getLevel()));
|
||||
html.replace("%clan_has_castle%", clan.getCastleId() > 0 ? CastleManager.getInstance().getCastleById(clan.getCastleId()).getName() : "No");
|
||||
html.replace("%clan_has_clanhall%", clan.getHideoutId() > 0 ? ClanHallData.getInstance().getClanHallById(clan.getHideoutId()).getName() : "No");
|
||||
html.replace("%clan_has_fortress%", clan.getFortId() > 0 ? FortManager.getInstance().getFortById(clan.getFortId()).getName() : "No");
|
||||
html.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
|
||||
html.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
|
||||
html.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
|
||||
html.replace("%current_player_objectId%", String.valueOf(player.getObjectId()));
|
||||
html.replace("%current_player_name%", player.getName());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_clan_changeleader":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2ClanMember member = clan.getClanMember(player.getObjectId());
|
||||
if (member != null)
|
||||
{
|
||||
if (player.isAcademyMember())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_PRIVILEGE_CANNOT_BE_GRANTED_TO_A_CLAN_ACADEMY_MEMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
clan.setNewLeader(member);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_clan_show_pending":
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/clanchanges.htm"));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (L2Clan clan : ClanTable.getInstance().getClans())
|
||||
{
|
||||
if (clan.getNewLeaderId() != 0)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td>" + clan.getName() + "</td>");
|
||||
sb.append("<td>" + clan.getNewLeaderName() + "</td>");
|
||||
sb.append("<td><a action=\"bypass -h admin_clan_force_pending " + clan.getId() + "\">Force</a></td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
}
|
||||
html.replace("%data%", sb.toString());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_clan_force_pending":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
break;
|
||||
}
|
||||
final int clanId = Integer.parseInt(token);
|
||||
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(clanId);
|
||||
if (clan == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2ClanMember member = clan.getClanMember(clan.getNewLeaderId());
|
||||
if (member == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
clan.setNewLeader(member);
|
||||
activeChar.sendMessage("Task have been forcely executed.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param st
|
||||
* @return
|
||||
*/
|
||||
private L2PcInstance getPlayer(L2PcInstance activeChar, StringTokenizer st)
|
||||
{
|
||||
String val;
|
||||
L2PcInstance player = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
val = st.nextToken();
|
||||
// From the HTML we receive player's object Id.
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(Integer.parseInt(val));
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(val);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_PLEASE_TRY_AGAIN);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object targetObj = activeChar.getTarget();
|
||||
if (targetObj instanceof L2PcInstance)
|
||||
{
|
||||
player = targetObj.getActingPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,287 +1,277 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ClanHallAuctionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2ClanHallZone;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles Clan Hall commands.
|
||||
* @author Zoey76 (rework)
|
||||
*/
|
||||
public class AdminClanHall implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clanhall",
|
||||
"admin_clanhallset",
|
||||
"admin_clanhalldel",
|
||||
"admin_clanhallopendoors",
|
||||
"admin_clanhallclosedoors",
|
||||
"admin_clanhallteleportself"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken(); // Get actual command
|
||||
|
||||
ClanHall clanhall = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
player = activeChar.getTarget().getActingPlayer();
|
||||
}
|
||||
|
||||
final String val = st.nextToken();
|
||||
if (command.startsWith("admin_clanhall"))
|
||||
{
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(val));
|
||||
L2Clan clan = null;
|
||||
switch (command)
|
||||
{
|
||||
case "admin_clanhallset":
|
||||
{
|
||||
if ((player == null) || (player.getClan() == null))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (clanhall.getOwnerId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("This Clan Hall is not free!");
|
||||
return false;
|
||||
}
|
||||
|
||||
clan = player.getClan();
|
||||
if (clan.getHideoutId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("You have already a Clan Hall!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
ClanHallManager.getInstance().setOwner(clanhall.getId(), clan);
|
||||
if (ClanHallAuctionManager.getInstance().getAuction(clanhall.getId()) != null)
|
||||
{
|
||||
ClanHallAuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clanhall.setOwner(clan);
|
||||
clan.setHideoutId(clanhall.getId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_clanhalldel":
|
||||
{
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
|
||||
{
|
||||
ClanHallManager.getInstance().setFree(clanhall.getId());
|
||||
ClanHallAuctionManager.getInstance().initNPC(clanhall.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("This Clan Hall is already free!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int oldOwner = clanhall.getOwnerId();
|
||||
if (oldOwner > 0)
|
||||
{
|
||||
clanhall.free();
|
||||
clan = ClanTable.getInstance().getClan(oldOwner);
|
||||
if (clan != null)
|
||||
{
|
||||
clan.setHideoutId(0);
|
||||
clan.broadcastClanStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_clanhallopendoors":
|
||||
{
|
||||
clanhall.openCloseDoors(true);
|
||||
break;
|
||||
}
|
||||
case "admin_clanhallclosedoors":
|
||||
{
|
||||
clanhall.openCloseDoors(false);
|
||||
break;
|
||||
}
|
||||
case "admin_clanhallteleportself":
|
||||
{
|
||||
final L2ClanHallZone zone = clanhall.getZone();
|
||||
if (zone != null)
|
||||
{
|
||||
activeChar.teleToLocation(zone.getSpawnLoc(), true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
showClanHallPage(activeChar, clanhall);
|
||||
}
|
||||
else
|
||||
{
|
||||
showSiegableHallPage(activeChar, (SiegableHall) clanhall);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showClanHallSelectPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show clan hall select page.
|
||||
* @param activeChar the active char
|
||||
*/
|
||||
private void showClanHallSelectPage(L2PcInstance activeChar)
|
||||
{
|
||||
int i = 0;
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/clanhalls.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
|
||||
{
|
||||
if (hall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_chsiege_siegablehall ", String.valueOf(hall.getId()), "\">", hall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%siegableHalls%", cList.toString());
|
||||
cList.setLength(0);
|
||||
i = 0;
|
||||
for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values())
|
||||
{
|
||||
if (clanhall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%clanhalls%", cList.toString());
|
||||
cList.setLength(0);
|
||||
i = 0;
|
||||
for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values())
|
||||
{
|
||||
if (clanhall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%freeclanhalls%", cList.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the clan hall page.
|
||||
* @param activeChar the active char
|
||||
* @param clanhall the clan hall
|
||||
*/
|
||||
private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/clanhall.htm");
|
||||
adminReply.replace("%clanhallName%", clanhall.getName());
|
||||
adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
|
||||
adminReply.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the siegable hall page.
|
||||
* @param activeChar the active char
|
||||
* @param hall the siegable hall
|
||||
*/
|
||||
private void showSiegableHallPage(L2PcInstance activeChar, SiegableHall hall)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(null, "html/admin/siegablehall.htm");
|
||||
msg.replace("%clanhallId%", String.valueOf(hall.getId()));
|
||||
msg.replace("%clanhallName%", hall.getName());
|
||||
if (hall.getOwnerId() > 0)
|
||||
{
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
msg.replace("%clanhallOwner%", (owner != null) ? owner.getName() : "No Owner");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClanHallData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.ClanHall;
|
||||
import com.l2jmobius.gameserver.model.html.PageBuilder;
|
||||
import com.l2jmobius.gameserver.model.html.PageResult;
|
||||
import com.l2jmobius.gameserver.model.html.formatters.BypassParserFormatter;
|
||||
import com.l2jmobius.gameserver.model.html.pagehandlers.NextPrevPageHandler;
|
||||
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
|
||||
import com.l2jmobius.gameserver.model.residences.ResidenceFunction;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.BypassParser;
|
||||
|
||||
/**
|
||||
* Clan Hall admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminClanHall implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clanhall",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.toLowerCase().equals("admin_clanhall"))
|
||||
{
|
||||
processBypass(activeChar, new BypassParser(command));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void doAction(L2PcInstance player, int clanHallId, String action, String actionVal)
|
||||
{
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallById(clanHallId);
|
||||
if (clanHall != null)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case "openCloseDoors":
|
||||
{
|
||||
if (actionVal != null)
|
||||
{
|
||||
clanHall.openCloseDoors(Boolean.parseBoolean(actionVal));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "teleport":
|
||||
{
|
||||
if (actionVal != null)
|
||||
{
|
||||
final Location loc;
|
||||
switch (actionVal)
|
||||
{
|
||||
case "inside":
|
||||
loc = clanHall.getOwnerLocation();
|
||||
break;
|
||||
case "outside":
|
||||
loc = clanHall.getBanishLocation();
|
||||
break;
|
||||
default:
|
||||
loc = player.getLocation();
|
||||
}
|
||||
player.teleToLocation(loc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "give":
|
||||
{
|
||||
if ((player.getTarget() != null) && (player.getTarget().getActingPlayer() != null))
|
||||
{
|
||||
final L2Clan targetClan = player.getTarget().getActingPlayer().getClan();
|
||||
if ((targetClan == null) || (targetClan.getHideoutId() != 0))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
|
||||
clanHall.setOwner(targetClan);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "take":
|
||||
{
|
||||
final L2Clan clan = clanHall.getOwner();
|
||||
if (clan != null)
|
||||
{
|
||||
clanHall.setOwner(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("You cannot take Clan Hall which don't have any owner.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "cancelFunc":
|
||||
{
|
||||
final ResidenceFunction function = clanHall.getFunction(Integer.parseInt(actionVal));
|
||||
if (function != null)
|
||||
{
|
||||
clanHall.removeFunction(function);
|
||||
sendClanHallDetails(player, clanHallId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Clan Hall with id " + clanHallId + " does not exist!");
|
||||
}
|
||||
useAdminCommand("admin_clanhall id=" + clanHallId, player);
|
||||
}
|
||||
|
||||
private void sendClanHallList(L2PcInstance player, int page, BypassParser parser)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(player.getHtmlPrefix(), "data/html/admin/clanhall_list.htm");
|
||||
final List<ClanHall> clanHallList = ClanHallData.getInstance().getClanHalls().stream().sorted(Comparator.comparingLong(ClanHall::getResidenceId)).collect(Collectors.toList());
|
||||
|
||||
//@formatter:off
|
||||
final PageResult result = PageBuilder.newBuilder(clanHallList, 4, "bypass -h admin_clanhall")
|
||||
.currentPage(page)
|
||||
.pageHandler(NextPrevPageHandler.INSTANCE)
|
||||
.formatter(BypassParserFormatter.INSTANCE)
|
||||
.style(ButtonsStyle.INSTANCE)
|
||||
.bodyHandler((pages, clanHall, sb) ->
|
||||
{
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr><td align=center fixwidth=\"250\"><font color=\"LEVEL\">&%" + clanHall.getResidenceId() + "; (" + clanHall.getResidenceId() + ")</font></td></tr>");
|
||||
sb.append("</table>");
|
||||
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"83\">Status:</td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"83\">" + (clanHall.getOwner() == null ? "<font color=\"00FF00\">Free</font>" : "<font color=\"FF9900\">Owned</font>") + "</td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"83\">Location:</td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"83\">&^" + clanHall.getResidenceId() + ";</td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"83\">Detailed Info:</td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"><button value=\"Show me!\" action=\"bypass -h admin_clanhall id=" + clanHall.getResidenceId() + "\" width=\"85\" height=\"20\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
|
||||
sb.append("</table>");
|
||||
sb.append("<br>");
|
||||
}).build();
|
||||
//@formatter:on
|
||||
|
||||
html.replace("%pages%", result.getPages() > 0 ? "<center><table width=\"100%\" cellspacing=0><tr>" + result.getPagerTemplate() + "</tr></table></center>" : "");
|
||||
html.replace("%data%", result.getBodyTemplate().toString());
|
||||
player.sendPacket(html);
|
||||
}
|
||||
|
||||
private void sendClanHallDetails(L2PcInstance player, int clanHallId)
|
||||
{
|
||||
final ClanHall clanHall = ClanHallData.getInstance().getClanHallById(clanHallId);
|
||||
if (clanHall != null)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
html.setFile(player.getHtmlPrefix(), "data/html/admin/clanhall_detail.htm");
|
||||
html.replace("%clanHallId%", clanHall.getResidenceId());
|
||||
html.replace("%clanHallOwner%", (clanHall.getOwner() == null ? "<font color=\"00FF00\">Free</font>" : "<font color=\"FF9900\">" + clanHall.getOwner().getName() + "</font>"));
|
||||
final String grade = clanHall.getGrade().toString().replace("GRADE_", "") + " Grade";
|
||||
html.replace("%clanHallGrade%", grade);
|
||||
html.replace("%clanHallSize%", clanHall.getGrade().getGradeValue());
|
||||
|
||||
if (!clanHall.getFunctions().isEmpty())
|
||||
{
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"40\"><font color=\"LEVEL\">ID</font></td>");
|
||||
sb.append("<td align=center fixwidth=\"200\"><font color=\"LEVEL\">Type</font></td>");
|
||||
sb.append("<td align=center fixwidth=\"40\"><font color=\"LEVEL\">Lvl</font></td>");
|
||||
sb.append("<td align=center fixwidth=\"200\"><font color=\"LEVEL\">End date</font></td>");
|
||||
sb.append("<td align=center fixwidth=\"100\"><font color=\"LEVEL\">Action</font></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("</table>");
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
clanHall.getFunctions().forEach(function ->
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"40\">" + function.getId() + "</td>");
|
||||
sb.append("<td align=center fixwidth=\"200\">" + function.getType().toString() + "</td>");
|
||||
sb.append("<td align=center fixwidth=\"40\">" + function.getLevel() + "</td>");
|
||||
sb.append("<td align=center fixwidth=\"200\">" + new SimpleDateFormat("dd/MM HH:mm").format(new Date(function.getExpiration())) + "</td>");
|
||||
sb.append("<td align=center fixwidth=\"100\"><button value=\"Remove\" action=\"bypass -h admin_clanhall id=" + clanHallId + " action=cancelFunc actionVal=" + function.getId() + "\" width=50 height=21 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
|
||||
sb.append("</tr>");
|
||||
});
|
||||
sb.append("</table>");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("This Clan Hall doesn't have any Function yet.");
|
||||
}
|
||||
html.replace("%functionList%", sb.toString());
|
||||
player.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Clan Hall with id " + clanHallId + " does not exist!");
|
||||
useAdminCommand("admin_clanhall", player);
|
||||
}
|
||||
}
|
||||
|
||||
private void processBypass(L2PcInstance player, BypassParser parser)
|
||||
{
|
||||
final int page = parser.getInt("page", 0);
|
||||
final int clanHallId = parser.getInt("id", 0);
|
||||
final String action = parser.getString("action", null);
|
||||
final String actionVal = parser.getString("actionVal", null);
|
||||
|
||||
if ((clanHallId > 0) && (action != null))
|
||||
{
|
||||
doAction(player, clanHallId, action, actionVal);
|
||||
}
|
||||
else if (clanHallId > 0)
|
||||
{
|
||||
sendClanHallDetails(player, clanHallId);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendClanHallList(player, page, parser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,274 +1,361 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - itemcreate = show menu - create_item <id> [num] = creates num items with respective id, if num is not specified, assumes 1.
|
||||
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminCreateItem implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_itemcreate",
|
||||
"admin_create_item",
|
||||
"admin_create_coin",
|
||||
"admin_give_item_target",
|
||||
"admin_give_item_to_all"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_itemcreate"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_create_item"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(17);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
createItem(activeChar, activeChar, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //create_item <itemId> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_create_coin"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(17);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String name = st.nextToken();
|
||||
final int idval = getCoinId(name);
|
||||
if (idval > 0)
|
||||
{
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String name = st.nextToken();
|
||||
final int idval = getCoinId(name);
|
||||
createItem(activeChar, activeChar, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //create_coin <name> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_give_item_target"))
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target;
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
target = (L2PcInstance) activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String val = command.substring(22);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, target, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
createItem(activeChar, target, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //give_item_target <itemId> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_give_item_to_all"))
|
||||
{
|
||||
final String val = command.substring(22);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
int idval = 0;
|
||||
long numval = 0;
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
numval = Long.parseLong(num);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
numval = 1;
|
||||
}
|
||||
int counter = 0;
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(idval);
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("This item doesn't exist.");
|
||||
return false;
|
||||
}
|
||||
if ((numval > 10) && !template.isStackable())
|
||||
{
|
||||
activeChar.sendMessage("This item does not stack - Creation aborted.");
|
||||
return false;
|
||||
}
|
||||
for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if ((activeChar != onlinePlayer) && onlinePlayer.isOnline() && (onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached())
|
||||
{
|
||||
onlinePlayer.getInventory().addItem("Admin", idval, numval, onlinePlayer, activeChar);
|
||||
onlinePlayer.sendMessage("Admin spawned " + numval + " " + template.getName() + " in your inventory.");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(counter + " players rewarded with " + template.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void createItem(L2PcInstance activeChar, L2PcInstance target, int id, long num)
|
||||
{
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(id);
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("This item doesn't exist.");
|
||||
return;
|
||||
}
|
||||
if ((num > 10) && !template.isStackable())
|
||||
{
|
||||
activeChar.sendMessage("This item does not stack - Creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
target.getInventory().addItem("Admin", id, num, activeChar, null);
|
||||
|
||||
if (activeChar != target)
|
||||
{
|
||||
target.sendMessage("Admin spawned " + num + " " + template.getName() + " in your inventory.");
|
||||
}
|
||||
activeChar.sendMessage("You have spawned " + num + " " + template.getName() + "(" + id + ") in " + target.getName() + " inventory.");
|
||||
target.sendPacket(new ExAdenaInvenCount(target));
|
||||
}
|
||||
|
||||
private int getCoinId(String name)
|
||||
{
|
||||
int id;
|
||||
if (name.equalsIgnoreCase("adena"))
|
||||
{
|
||||
id = 57;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("ancientadena"))
|
||||
{
|
||||
id = 5575;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("festivaladena"))
|
||||
{
|
||||
id = 6673;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("blueeva"))
|
||||
{
|
||||
id = 4355;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("goldeinhasad"))
|
||||
{
|
||||
id = 4356;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("silvershilen"))
|
||||
{
|
||||
id = 4357;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("bloodypaagrio"))
|
||||
{
|
||||
id = 4358;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("fantasyislecoin"))
|
||||
{
|
||||
id = 13067;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IItemHandler;
|
||||
import com.l2jmobius.gameserver.handler.ItemHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.GMViewItemList;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - itemcreate = show menu - create_item <id> [num] = creates num items with respective id, if num is not specified, assumes 1.
|
||||
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminCreateItem implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_itemcreate",
|
||||
"admin_create_item",
|
||||
"admin_create_coin",
|
||||
"admin_give_item_target",
|
||||
"admin_give_item_to_all",
|
||||
"admin_delete_item",
|
||||
"admin_use_item"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_itemcreate"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_create_item"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(17);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
createItem(activeChar, activeChar, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //create_item <itemId> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_create_coin"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(17);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String name = st.nextToken();
|
||||
final int idval = getCoinId(name);
|
||||
if (idval > 0)
|
||||
{
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String name = st.nextToken();
|
||||
final int idval = getCoinId(name);
|
||||
createItem(activeChar, activeChar, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //create_coin <name> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_give_item_target"))
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target;
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
target = (L2PcInstance) activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid target.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String val = command.substring(22);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
final long numval = Long.parseLong(num);
|
||||
createItem(activeChar, target, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
final int idval = Integer.parseInt(id);
|
||||
createItem(activeChar, target, idval, 1);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //give_item_target <itemId> [amount]");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Specify a valid number.");
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_give_item_to_all"))
|
||||
{
|
||||
final String val = command.substring(22);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
int idval = 0;
|
||||
long numval = 0;
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
numval = Long.parseLong(num);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
numval = 1;
|
||||
}
|
||||
int counter = 0;
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(idval);
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("This item doesn't exist.");
|
||||
return false;
|
||||
}
|
||||
if ((numval > 10) && !template.isStackable())
|
||||
{
|
||||
activeChar.sendMessage("This item does not stack - Creation aborted.");
|
||||
return false;
|
||||
}
|
||||
for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if ((activeChar != onlinePlayer) && onlinePlayer.isOnline() && ((onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached()))
|
||||
{
|
||||
onlinePlayer.getInventory().addItem("Admin", idval, numval, onlinePlayer, activeChar);
|
||||
onlinePlayer.sendMessage("Admin spawned " + numval + " " + template.getName() + " in your inventory.");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(counter + " players rewarded with " + template.getName());
|
||||
}
|
||||
else if (command.startsWith("admin_delete_item"))
|
||||
{
|
||||
final String val = command.substring(18);
|
||||
final StringTokenizer st = new StringTokenizer(val);
|
||||
int idval = 0;
|
||||
long numval = 0;
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
final String num = st.nextToken();
|
||||
numval = Long.parseLong(num);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
final String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
numval = 1;
|
||||
}
|
||||
final L2ItemInstance item = (L2ItemInstance) L2World.getInstance().findObject(idval);
|
||||
final int ownerId = item.getOwnerId();
|
||||
if (ownerId > 0)
|
||||
{
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendMessage("Player is not online.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (numval == 0)
|
||||
{
|
||||
numval = item.getCount();
|
||||
}
|
||||
|
||||
player.getInventory().destroyItem("AdminDelete", idval, numval, activeChar, null);
|
||||
activeChar.sendPacket(new GMViewItemList(player));
|
||||
activeChar.sendMessage("Item deleted.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Item doesn't have owner.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_use_item"))
|
||||
{
|
||||
final String val = command.substring(15);
|
||||
final int idval = Integer.parseInt(val);
|
||||
final L2ItemInstance item = (L2ItemInstance) L2World.getInstance().findObject(idval);
|
||||
final int ownerId = item.getOwnerId();
|
||||
if (ownerId > 0)
|
||||
{
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(ownerId);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendMessage("Player is not online.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// equip
|
||||
if (item.isEquipable())
|
||||
{
|
||||
player.useEquippableItem(item, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
final IItemHandler ih = ItemHandler.getInstance().getHandler(item.getEtcItem());
|
||||
if (ih != null)
|
||||
{
|
||||
ih.useItem(player, item, false);
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(new GMViewItemList(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Item doesn't have owner.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void createItem(L2PcInstance activeChar, L2PcInstance target, int id, long num)
|
||||
{
|
||||
final L2Item template = ItemTable.getInstance().getTemplate(id);
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("This item doesn't exist.");
|
||||
return;
|
||||
}
|
||||
if ((num > 10) && !template.isStackable())
|
||||
{
|
||||
activeChar.sendMessage("This item does not stack - Creation aborted.");
|
||||
return;
|
||||
}
|
||||
|
||||
target.getInventory().addItem("Admin", id, num, activeChar, null);
|
||||
|
||||
if (activeChar != target)
|
||||
{
|
||||
target.sendMessage("Admin spawned " + num + " " + template.getName() + " in your inventory.");
|
||||
}
|
||||
activeChar.sendMessage("You have spawned " + num + " " + template.getName() + "(" + id + ") in " + target.getName() + " inventory.");
|
||||
target.sendPacket(new ExAdenaInvenCount(target));
|
||||
}
|
||||
|
||||
private int getCoinId(String name)
|
||||
{
|
||||
int id;
|
||||
if (name.equalsIgnoreCase("adena"))
|
||||
{
|
||||
id = 57;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("ancientadena"))
|
||||
{
|
||||
id = 5575;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("festivaladena"))
|
||||
{
|
||||
id = 6673;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("blueeva"))
|
||||
{
|
||||
id = 4355;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("goldeinhasad"))
|
||||
{
|
||||
id = 4356;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("silvershilen"))
|
||||
{
|
||||
id = 4357;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("bloodypaagrio"))
|
||||
{
|
||||
id = 4358;
|
||||
}
|
||||
else if (name.equalsIgnoreCase("fantasyislecoin"))
|
||||
{
|
||||
id = 13067;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,201 +1,232 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.CursedWeapon;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - cw_info = displays cursed weapon status - cw_remove = removes a cursed weapon from the world, item id or name must be provided - cw_add = adds a cursed weapon into the world, item id or name must be provided. Target will be the weilder - cw_goto =
|
||||
* teleports GM to the specified cursed weapon - cw_reload = reloads instance manager
|
||||
* @version $Revision: 1.1.6.3 $ $Date: 2007/07/31 10:06:06 $
|
||||
*/
|
||||
public class AdminCursedWeapons implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_cw_info",
|
||||
"admin_cw_remove",
|
||||
"admin_cw_goto",
|
||||
"admin_cw_reload",
|
||||
"admin_cw_add",
|
||||
"admin_cw_info_menu"
|
||||
};
|
||||
|
||||
private int itemId;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final CursedWeaponsManager cwm = CursedWeaponsManager.getInstance();
|
||||
int id = 0;
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
if (command.startsWith("admin_cw_info"))
|
||||
{
|
||||
if (!command.contains("menu"))
|
||||
{
|
||||
activeChar.sendMessage("====== Cursed Weapons: ======");
|
||||
for (CursedWeapon cw : cwm.getCursedWeapons())
|
||||
{
|
||||
activeChar.sendMessage("> " + cw.getName() + " (" + cw.getItemId() + ")");
|
||||
if (cw.isActivated())
|
||||
{
|
||||
final L2PcInstance pl = cw.getPlayer();
|
||||
activeChar.sendMessage(" Player holding: " + (pl == null ? "null" : pl.getName()));
|
||||
activeChar.sendMessage(" Player karma: " + cw.getPlayerKarma());
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
activeChar.sendMessage(" Lying on the ground.");
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(" Don't exist in the world.");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.EMPTY3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Collection<CursedWeapon> cws = cwm.getCursedWeapons();
|
||||
final StringBuilder replyMSG = new StringBuilder(cws.size() * 300);
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/cwinfo.htm");
|
||||
for (CursedWeapon cw : cwm.getCursedWeapons())
|
||||
{
|
||||
itemId = cw.getItemId();
|
||||
|
||||
StringUtil.append(replyMSG, "<table width=270><tr><td>Name:</td><td>", cw.getName(), "</td></tr>");
|
||||
|
||||
if (cw.isActivated())
|
||||
{
|
||||
final L2PcInstance pl = cw.getPlayer();
|
||||
StringUtil.append(replyMSG, "<tr><td>Weilder:</td><td>", pl == null ? "null" : pl.getName(), "</td></tr><tr><td>Karma:</td><td>", String.valueOf(cw.getPlayerKarma()), "</td></tr><tr><td>Kills:</td><td>", String.valueOf(cw.getPlayerPkKills()), "/", String.valueOf(cw.getNbKills()), "</td></tr><tr><td>Time remaining:</td><td>", String.valueOf(cw.getTimeLeft() / 60000), " min.</td></tr><tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Go\" action=\"bypass -h admin_cw_goto ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td>Position:</td><td>Lying on the ground</td></tr><tr><td>Time remaining:</td><td>", String.valueOf(cw.getTimeLeft() / 60000), " min.</td></tr><tr><td>Kills:</td><td>", String.valueOf(cw.getNbKills()), "</td></tr><tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Go\" action=\"bypass -h admin_cw_goto ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td>Position:</td><td>Doesn't exist.</td></tr><tr><td><button value=\"Give to Target\" action=\"bypass -h admin_cw_add ", String.valueOf(itemId), "\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td></td></tr>");
|
||||
}
|
||||
|
||||
replyMSG.append("</table><br>");
|
||||
}
|
||||
adminReply.replace("%cwinfo%", replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_cw_reload"))
|
||||
{
|
||||
cwm.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
CursedWeapon cw = null;
|
||||
try
|
||||
{
|
||||
String parameter = st.nextToken();
|
||||
if (parameter.matches("[0-9]*"))
|
||||
{
|
||||
id = Integer.parseInt(parameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = parameter.replace('_', ' ');
|
||||
for (CursedWeapon cwp : cwm.getCursedWeapons())
|
||||
{
|
||||
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
|
||||
{
|
||||
id = cwp.getItemId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cw = cwm.getCursedWeapon(id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cw_remove|//cw_goto|//cw_add <itemid|name>");
|
||||
}
|
||||
|
||||
if (cw == null)
|
||||
{
|
||||
activeChar.sendMessage("Unknown cursed weapon ID.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_cw_remove "))
|
||||
{
|
||||
cw.endOfLife();
|
||||
}
|
||||
else if (command.startsWith("admin_cw_goto "))
|
||||
{
|
||||
cw.goTo(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_cw_add"))
|
||||
{
|
||||
if (cw.isActive())
|
||||
{
|
||||
activeChar.sendMessage("This cursed weapon is already active.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) target).addItem("AdminCursedWeaponAdd", id, 1, target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addItem("AdminCursedWeaponAdd", id, 1, activeChar, true);
|
||||
}
|
||||
cw.setEndTime(System.currentTimeMillis() + (cw.getDuration() * 60000L));
|
||||
cw.reActivate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Unknown command.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.model.CursedWeapon;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - cw_info = displays cursed weapon status - cw_remove = removes a cursed weapon from the world, item id or name must be provided - cw_add = adds a cursed weapon into the world, item id or name must be provided. Target will be the weilder - cw_goto =
|
||||
* teleports GM to the specified cursed weapon - cw_reload = reloads instance manager
|
||||
* @version $Revision: 1.1.6.3 $ $Date: 2007/07/31 10:06:06 $
|
||||
*/
|
||||
public class AdminCursedWeapons implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_cw_info",
|
||||
"admin_cw_remove",
|
||||
"admin_cw_goto",
|
||||
"admin_cw_reload",
|
||||
"admin_cw_add",
|
||||
"admin_cw_info_menu"
|
||||
};
|
||||
|
||||
private int itemId;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
final CursedWeaponsManager cwm = CursedWeaponsManager.getInstance();
|
||||
int id = 0;
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
if (command.startsWith("admin_cw_info"))
|
||||
{
|
||||
if (!command.contains("menu"))
|
||||
{
|
||||
activeChar.sendMessage("====== Cursed Weapons: ======");
|
||||
for (CursedWeapon cw : cwm.getCursedWeapons())
|
||||
{
|
||||
activeChar.sendMessage("> " + cw.getName() + " (" + cw.getItemId() + ")");
|
||||
if (cw.isActivated())
|
||||
{
|
||||
final L2PcInstance pl = cw.getPlayer();
|
||||
activeChar.sendMessage(" Player holding: " + (pl == null ? "null" : pl.getName()));
|
||||
activeChar.sendMessage(" Player Reputation: " + cw.getPlayerReputation());
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
activeChar.sendMessage(" Lying on the ground.");
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(" Don't exist in the world.");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.EMPTY3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Collection<CursedWeapon> cws = cwm.getCursedWeapons();
|
||||
final StringBuilder replyMSG = new StringBuilder(cws.size() * 300);
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/cwinfo.htm");
|
||||
for (CursedWeapon cw : cwm.getCursedWeapons())
|
||||
{
|
||||
itemId = cw.getItemId();
|
||||
|
||||
replyMSG.append("<table width=270><tr><td>Name:</td><td>");
|
||||
replyMSG.append(cw.getName());
|
||||
replyMSG.append("</td></tr>");
|
||||
|
||||
if (cw.isActivated())
|
||||
{
|
||||
final L2PcInstance pl = cw.getPlayer();
|
||||
replyMSG.append("<tr><td>Weilder:</td><td>");
|
||||
replyMSG.append(pl == null ? "null" : pl.getName());
|
||||
replyMSG.append("</td></tr>");
|
||||
replyMSG.append("<tr><td>Karma:</td><td>");
|
||||
replyMSG.append(cw.getPlayerReputation());
|
||||
replyMSG.append("</td></tr>");
|
||||
replyMSG.append("<tr><td>Kills:</td><td>");
|
||||
replyMSG.append(cw.getPlayerPkKills());
|
||||
replyMSG.append("/");
|
||||
replyMSG.append(cw.getNbKills());
|
||||
replyMSG.append("</td></tr><tr><td>Time remaining:</td><td>");
|
||||
replyMSG.append(cw.getTimeLeft() / 60000);
|
||||
replyMSG.append(" min.</td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ");
|
||||
replyMSG.append(itemId);
|
||||
replyMSG.append("\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Go\" action=\"bypass -h admin_cw_goto ");
|
||||
replyMSG.append(itemId);
|
||||
replyMSG.append("\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
replyMSG.append("<tr><td>Position:</td><td>Lying on the ground</td></tr><tr><td>Time remaining:</td><td>");
|
||||
replyMSG.append(cw.getTimeLeft() / 60000);
|
||||
replyMSG.append(" min.</td></tr><tr><td>Kills:</td><td>");
|
||||
replyMSG.append(cw.getNbKills());
|
||||
replyMSG.append("</td></tr><tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ");
|
||||
replyMSG.append(itemId);
|
||||
replyMSG.append("\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Go\" action=\"bypass -h admin_cw_goto ");
|
||||
replyMSG.append(itemId);
|
||||
replyMSG.append("\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<tr><td>Position:</td><td>Doesn't exist.</td></tr><tr><td><button value=\"Give to Target\" action=\"bypass -h admin_cw_add ");
|
||||
replyMSG.append(itemId);
|
||||
replyMSG.append("\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td></td></tr>");
|
||||
}
|
||||
|
||||
replyMSG.append("</table><br>");
|
||||
}
|
||||
adminReply.replace("%cwinfo%", replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_cw_reload"))
|
||||
{
|
||||
cwm.load();
|
||||
}
|
||||
else
|
||||
{
|
||||
CursedWeapon cw = null;
|
||||
try
|
||||
{
|
||||
String parameter = st.nextToken();
|
||||
if (parameter.matches("[0-9]*"))
|
||||
{
|
||||
id = Integer.parseInt(parameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = parameter.replace('_', ' ');
|
||||
for (CursedWeapon cwp : cwm.getCursedWeapons())
|
||||
{
|
||||
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
|
||||
{
|
||||
id = cwp.getItemId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cw = cwm.getCursedWeapon(id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cw_remove|//cw_goto|//cw_add <itemid|name>");
|
||||
}
|
||||
|
||||
if (cw == null)
|
||||
{
|
||||
activeChar.sendMessage("Unknown cursed weapon ID.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_cw_remove "))
|
||||
{
|
||||
cw.endOfLife();
|
||||
}
|
||||
else if (command.startsWith("admin_cw_goto "))
|
||||
{
|
||||
cw.goTo(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_cw_add"))
|
||||
{
|
||||
if (cw.isActive())
|
||||
{
|
||||
activeChar.sendMessage("This cursed weapon is already active.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) target).addItem("AdminCursedWeaponAdd", id, 1, target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addItem("AdminCursedWeaponAdd", id, 1, activeChar, true);
|
||||
}
|
||||
cw.setEndTime(System.currentTimeMillis() + (cw.getDuration() * 60000L));
|
||||
cw.reActivate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Unknown command.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +1,85 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminDelete implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_delete"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_delete"))
|
||||
{
|
||||
handleDelete(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
// TODO: add possibility to delete any L2Object (except L2PcInstance)
|
||||
private void handleDelete(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
final L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
|
||||
final L2Spawn spawn = target.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminDelete implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_delete"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_delete"))
|
||||
{
|
||||
handleDelete(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
// TODO: add possibility to delete any L2Object (except L2PcInstance)
|
||||
private void handleDelete(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
final L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
|
||||
final L2Spawn spawn = target.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (DBSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
DBSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +1,74 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - character_disconnect = disconnects target player
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:00 $
|
||||
*/
|
||||
public class AdminDisconnect implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_character_disconnect"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_character_disconnect"))
|
||||
{
|
||||
disconnectCharacter(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void disconnectCharacter(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == activeChar)
|
||||
{
|
||||
activeChar.sendMessage("You cannot logout your own character.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Character " + player.getName() + " disconnected from server.");
|
||||
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - character_disconnect = disconnects target player
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:00 $
|
||||
*/
|
||||
public class AdminDisconnect implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_character_disconnect"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_character_disconnect"))
|
||||
{
|
||||
disconnectCharacter(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void disconnectCharacter(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == activeChar)
|
||||
{
|
||||
activeChar.sendMessage("You cannot logout your own character.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Character " + player.getName() + " disconnected from server.");
|
||||
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.l2jmobius.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
@@ -140,31 +140,27 @@ public class AdminDoorControl implements IAdminCommandHandler
|
||||
}
|
||||
else if (command.equals("admin_showdoors"))
|
||||
{
|
||||
for (L2Character ch : activeChar.getKnownList().getKnownCharacters())
|
||||
L2World.getInstance().forEachVisibleObject(activeChar, L2DoorInstance.class, door ->
|
||||
{
|
||||
final ExServerPrimitive packet = new ExServerPrimitive("door" + ch.getId(), activeChar.getX(), activeChar.getY(), -16000);
|
||||
if (ch.isDoor())
|
||||
{
|
||||
final L2DoorInstance door = (L2DoorInstance) ch;
|
||||
final Color color = door.getOpen() ? Color.GREEN : Color.RED;
|
||||
// box 1
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMin());
|
||||
packet.addLine(color, door.getX(1), door.getY(1), door.getZMin(), door.getX(2), door.getY(2), door.getZMax());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMax());
|
||||
packet.addLine(color, door.getX(3), door.getY(3), door.getZMax(), door.getX(0), door.getY(0), door.getZMin());
|
||||
// box 2
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMax());
|
||||
packet.addLine(color, door.getX(1), door.getY(1), door.getZMax(), door.getX(2), door.getY(2), door.getZMin());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMin());
|
||||
packet.addLine(color, door.getX(3), door.getY(3), door.getZMin(), door.getX(0), door.getY(0), door.getZMax());
|
||||
// diagonals
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMax());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMax());
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMin());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMin());
|
||||
}
|
||||
final ExServerPrimitive packet = new ExServerPrimitive("door" + door.getId(), activeChar.getX(), activeChar.getY(), -16000);
|
||||
final Color color = door.isOpen() ? Color.GREEN : Color.RED;
|
||||
// box 1
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMin());
|
||||
packet.addLine(color, door.getX(1), door.getY(1), door.getZMin(), door.getX(2), door.getY(2), door.getZMax());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMax());
|
||||
packet.addLine(color, door.getX(3), door.getY(3), door.getZMax(), door.getX(0), door.getY(0), door.getZMin());
|
||||
// box 2
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMax());
|
||||
packet.addLine(color, door.getX(1), door.getY(1), door.getZMax(), door.getX(2), door.getY(2), door.getZMin());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMin());
|
||||
packet.addLine(color, door.getX(3), door.getY(3), door.getZMin(), door.getX(0), door.getY(0), door.getZMax());
|
||||
// diagonals
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMin(), door.getX(1), door.getY(1), door.getZMax());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMin(), door.getX(3), door.getY(3), door.getZMax());
|
||||
packet.addLine(color, door.getX(0), door.getY(0), door.getZMax(), door.getX(1), door.getY(1), door.getZMin());
|
||||
packet.addLine(color, door.getX(2), door.getY(2), door.getZMax(), door.getX(3), door.getY(3), door.getZMin());
|
||||
activeChar.sendPacket(packet);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,186 +1,191 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.Elementals;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminElement implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_setlh",
|
||||
"admin_setlc",
|
||||
"admin_setll",
|
||||
"admin_setlg",
|
||||
"admin_setlb",
|
||||
"admin_setlw",
|
||||
"admin_setls"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int armorType = -1;
|
||||
|
||||
if (command.startsWith("admin_setlh"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_HEAD;
|
||||
}
|
||||
else if (command.startsWith("admin_setlc"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CHEST;
|
||||
}
|
||||
else if (command.startsWith("admin_setlg"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_GLOVES;
|
||||
}
|
||||
else if (command.startsWith("admin_setlb"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_FEET;
|
||||
}
|
||||
else if (command.startsWith("admin_setll"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEGS;
|
||||
}
|
||||
else if (command.startsWith("admin_setlw"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setls"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LHAND;
|
||||
}
|
||||
|
||||
if (armorType != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
final String[] args = command.split(" ");
|
||||
|
||||
final byte element = Elementals.getElementId(args[1]);
|
||||
final int value = Integer.parseInt(args[2]);
|
||||
if ((element < -1) || (element > 5) || (value < 0) || (value > 450))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element> <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
|
||||
setElement(activeChar, element, value, armorType);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element>[0-5] <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void setElement(L2PcInstance activeChar, byte type, int value, int armorType)
|
||||
{
|
||||
// get the target
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
final L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
String old, current;
|
||||
final Elementals element = itemInstance.getElemental(type);
|
||||
if (element != null)
|
||||
{
|
||||
old = element.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
old = "None";
|
||||
}
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
if (type == -1)
|
||||
{
|
||||
itemInstance.clearElementAttr(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInstance.setElementAttr(type, value);
|
||||
}
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
if (itemInstance.getElementals() != null)
|
||||
{
|
||||
current = itemInstance.getElemental(type).toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
current = "None";
|
||||
}
|
||||
|
||||
// send packets
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendPacket(iu);
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed elemental power of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
if (player != activeChar)
|
||||
{
|
||||
player.sendMessage(activeChar.getName() + " has changed the elemental power of your " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.enums.AttributeType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.enchant.attribute.AttributeHolder;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminElement implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_setlh",
|
||||
"admin_setlc",
|
||||
"admin_setll",
|
||||
"admin_setlg",
|
||||
"admin_setlb",
|
||||
"admin_setlw",
|
||||
"admin_setls"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int armorType = -1;
|
||||
|
||||
if (command.startsWith("admin_setlh"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_HEAD;
|
||||
}
|
||||
else if (command.startsWith("admin_setlc"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CHEST;
|
||||
}
|
||||
else if (command.startsWith("admin_setlg"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_GLOVES;
|
||||
}
|
||||
else if (command.startsWith("admin_setlb"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_FEET;
|
||||
}
|
||||
else if (command.startsWith("admin_setll"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEGS;
|
||||
}
|
||||
else if (command.startsWith("admin_setlw"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setls"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LHAND;
|
||||
}
|
||||
|
||||
if (armorType != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
final String[] args = command.split(" ");
|
||||
|
||||
final AttributeType type = AttributeType.findByName(args[1]);
|
||||
final int value = Integer.parseInt(args[2]);
|
||||
if ((type == null) || (value < 0) || (value > 450))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element> <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
|
||||
setElement(activeChar, type, value, armorType);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element>[0-5] <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void setElement(L2PcInstance activeChar, AttributeType type, int value, int armorType)
|
||||
{
|
||||
// get the target
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
final L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
String old, current;
|
||||
final AttributeHolder element = itemInstance.getAttribute(type);
|
||||
if (element == null)
|
||||
{
|
||||
old = "None";
|
||||
}
|
||||
else
|
||||
{
|
||||
old = element.toString();
|
||||
}
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
if (type == AttributeType.NONE)
|
||||
{
|
||||
itemInstance.clearAllAttributes();
|
||||
}
|
||||
else if (value < 1)
|
||||
{
|
||||
itemInstance.clearAttribute(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInstance.setAttribute(new AttributeHolder(type, value));
|
||||
}
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
if (itemInstance.getAttributes() == null)
|
||||
{
|
||||
current = "None";
|
||||
}
|
||||
else
|
||||
{
|
||||
current = itemInstance.getAttribute(type).toString();
|
||||
}
|
||||
|
||||
// send packets
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendInventoryUpdate(iu);
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed elemental power of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
if (player != activeChar)
|
||||
{
|
||||
player.sendMessage(activeChar.getName() + " has changed the elemental power of your " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,235 +1,222 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - enchant_armor
|
||||
* @version $Revision: 1.3.2.1.2.10 $ $Date: 2005/08/24 21:06:06 $
|
||||
*/
|
||||
public class AdminEnchant implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminEnchant.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_seteh", // 6
|
||||
"admin_setec", // 10
|
||||
"admin_seteg", // 9
|
||||
"admin_setel", // 11
|
||||
"admin_seteb", // 12
|
||||
"admin_setew", // 7
|
||||
"admin_setes", // 8
|
||||
"admin_setle", // 1
|
||||
"admin_setre", // 2
|
||||
"admin_setlf", // 4
|
||||
"admin_setrf", // 5
|
||||
"admin_seten", // 3
|
||||
"admin_setun", // 0
|
||||
"admin_setba", // 13
|
||||
"admin_setbe",
|
||||
"admin_enchant"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_enchant"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
int armorType = -1;
|
||||
|
||||
if (command.startsWith("admin_seteh"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_HEAD;
|
||||
}
|
||||
else if (command.startsWith("admin_setec"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CHEST;
|
||||
}
|
||||
else if (command.startsWith("admin_seteg"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_GLOVES;
|
||||
}
|
||||
else if (command.startsWith("admin_seteb"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_FEET;
|
||||
}
|
||||
else if (command.startsWith("admin_setel"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEGS;
|
||||
}
|
||||
else if (command.startsWith("admin_setew"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setes"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setle"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setre"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_REAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setlf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_setrf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_seten"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_NECK;
|
||||
}
|
||||
else if (command.startsWith("admin_setun"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_UNDER;
|
||||
}
|
||||
else if (command.startsWith("admin_setba"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CLOAK;
|
||||
}
|
||||
else if (command.startsWith("admin_setbe"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_BELT;
|
||||
}
|
||||
|
||||
if (armorType != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int ench = Integer.parseInt(command.substring(12));
|
||||
|
||||
// check value
|
||||
if ((ench < 0) || (ench > 127))
|
||||
{
|
||||
activeChar.sendMessage("You must set the enchant level to be between 0-127.");
|
||||
}
|
||||
else
|
||||
{
|
||||
setEnchant(activeChar, ench, armorType);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a new enchant value.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a valid new enchant value.");
|
||||
}
|
||||
}
|
||||
|
||||
// show the enchant menu after an action
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setEnchant(L2PcInstance activeChar, int ench, int armorType)
|
||||
{
|
||||
// get the target
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
// now we need to find the equipped weapon of the targeted character...
|
||||
int curEnchant = 0; // display purposes only
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
final L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
curEnchant = itemInstance.getEnchantLevel();
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
itemInstance.setEnchantLevel(ench);
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
// send packets
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendPacket(iu);
|
||||
player.broadcastPacket(new CharInfo(player));
|
||||
player.sendPacket(new UserInfo(player));
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "enchant.htm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - enchant_armor
|
||||
* @version $Revision: 1.3.2.1.2.10 $ $Date: 2005/08/24 21:06:06 $
|
||||
*/
|
||||
public class AdminEnchant implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminEnchant.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_seteh", // 6
|
||||
"admin_setec", // 10
|
||||
"admin_seteg", // 9
|
||||
"admin_setel", // 11
|
||||
"admin_seteb", // 12
|
||||
"admin_setew", // 7
|
||||
"admin_setes", // 8
|
||||
"admin_setle", // 1
|
||||
"admin_setre", // 2
|
||||
"admin_setlf", // 4
|
||||
"admin_setrf", // 5
|
||||
"admin_seten", // 3
|
||||
"admin_setun", // 0
|
||||
"admin_setba", // 13
|
||||
"admin_setbe",
|
||||
"admin_enchant"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_enchant"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
int armorType = -1;
|
||||
|
||||
if (command.startsWith("admin_seteh"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_HEAD;
|
||||
}
|
||||
else if (command.startsWith("admin_setec"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CHEST;
|
||||
}
|
||||
else if (command.startsWith("admin_seteg"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_GLOVES;
|
||||
}
|
||||
else if (command.startsWith("admin_seteb"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_FEET;
|
||||
}
|
||||
else if (command.startsWith("admin_setel"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEGS;
|
||||
}
|
||||
else if (command.startsWith("admin_setew"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setes"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setle"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setre"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_REAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setlf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_setrf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_seten"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_NECK;
|
||||
}
|
||||
else if (command.startsWith("admin_setun"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_UNDER;
|
||||
}
|
||||
else if (command.startsWith("admin_setba"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CLOAK;
|
||||
}
|
||||
else if (command.startsWith("admin_setbe"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_BELT;
|
||||
}
|
||||
|
||||
if (armorType != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
final int ench = Integer.parseInt(command.substring(12));
|
||||
|
||||
// check value
|
||||
if ((ench < 0) || (ench > 127))
|
||||
{
|
||||
activeChar.sendMessage("You must set the enchant level to be between 0-127.");
|
||||
}
|
||||
else
|
||||
{
|
||||
setEnchant(activeChar, ench, armorType);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a new enchant value.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a valid new enchant value.");
|
||||
}
|
||||
}
|
||||
|
||||
// show the enchant menu after an action
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setEnchant(L2PcInstance activeChar, int ench, int armorType)
|
||||
{
|
||||
// get the target
|
||||
|
||||
final L2PcInstance player = activeChar.getTarget() != null ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
// now we need to find the equipped weapon of the targeted character...
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
final L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
final int curEnchant = itemInstance.getEnchantLevel();
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
itemInstance.setEnchantLevel(ench);
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
// send packets
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendInventoryUpdate(iu);
|
||||
player.broadcastUserInfo();
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "enchant.htm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,165 +1,164 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class AdminEvents implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_event_menu",
|
||||
"admin_event_start",
|
||||
"admin_event_stop",
|
||||
"admin_event_start_menu",
|
||||
"admin_event_stop_menu",
|
||||
"admin_event_bypass"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String event_name = "";
|
||||
String _event_bypass = "";
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
event_name = st.nextToken();
|
||||
}
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
_event_bypass = st.nextToken();
|
||||
}
|
||||
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
showMenu(activeChar);
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_event_start"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
if (event.eventStart(activeChar))
|
||||
{
|
||||
activeChar.sendMessage("Event " + event_name + " started.");
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("There is problem starting " + event_name + " event.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_start <eventname>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_event_stop"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
if (event.eventStop())
|
||||
{
|
||||
activeChar.sendMessage("Event " + event_name + " stopped.");
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("There is problem with stoping " + event_name + " event.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_start <eventname>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_event_bypass"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
event.eventBypass(activeChar, _event_bypass);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_bypass <eventname> <bypass>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/gm_events.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (Quest event : QuestManager.getInstance().getScripts().values())
|
||||
{
|
||||
if (event instanceof Event)
|
||||
{
|
||||
StringUtil.append(cList, "<font color=\"LEVEL\">" + event.getName() + ":</font><br1>", "<table width=270><tr>", "<td><button value=\"Start\" action=\"bypass -h admin_event_start_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "<td><button value=\"Stop\" action=\"bypass -h admin_event_stop_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "<td><button value=\"Menu\" action=\"bypass -h admin_event_bypass " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "</tr></table><br>");
|
||||
}
|
||||
}
|
||||
html.replace("%LIST%", cList.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Event;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class AdminEvents implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_event_menu",
|
||||
"admin_event_start",
|
||||
"admin_event_stop",
|
||||
"admin_event_start_menu",
|
||||
"admin_event_stop_menu",
|
||||
"admin_event_bypass"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String event_name = "";
|
||||
String _event_bypass = "";
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
event_name = st.nextToken();
|
||||
}
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
_event_bypass = st.nextToken();
|
||||
}
|
||||
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
showMenu(activeChar);
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_event_start"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
if (event.eventStart(activeChar))
|
||||
{
|
||||
activeChar.sendMessage("Event " + event_name + " started.");
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("There is problem starting " + event_name + " event.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_start <eventname>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_event_stop"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
if (event.eventStop())
|
||||
{
|
||||
activeChar.sendMessage("Event " + event_name + " stopped.");
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("There is problem with stoping " + event_name + " event.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_start <eventname>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_event_bypass"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (event_name != null)
|
||||
{
|
||||
final Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
event.eventBypass(activeChar, _event_bypass);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_bypass <eventname> <bypass>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/gm_events.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (Quest event : QuestManager.getInstance().getScripts().values())
|
||||
{
|
||||
if (event instanceof Event)
|
||||
{
|
||||
cList.append("<font color=\"LEVEL\">" + event.getName() + ":</font><br1><table width=270><tr><td><button value=\"Start\" action=\"bypass -h admin_event_start_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Stop\" action=\"bypass -h admin_event_stop_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
}
|
||||
}
|
||||
html.replace("%LIST%", cList.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
}
|
||||
@@ -1,205 +1,207 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* <li>add_exp_sp_to_character <i>shows menu for add or remove</i>
|
||||
* <li>add_exp_sp exp sp <i>Adds exp & sp to target, displays menu if a parameter is missing</i>
|
||||
* <li>remove_exp_sp exp sp <i>Removes exp & sp from target, displays menu if a parameter is missing</i>
|
||||
* @version $Revision: 1.2.4.6 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminExpSp implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminExpSp.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_exp_sp_to_character",
|
||||
"admin_add_exp_sp",
|
||||
"admin_remove_exp_sp"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_add_exp_sp"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!adminAddExpSp(activeChar, command.substring(16)))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //add_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_remove_exp_sp"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!adminRemoveExpSP(activeChar, command.substring(19)))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //remove_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //remove_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
addExpSp(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void addExpSp(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/expsp.htm");
|
||||
adminReply.replace("%name%", player.getName());
|
||||
adminReply.replace("%level%", String.valueOf(player.getLevel()));
|
||||
adminReply.replace("%xp%", String.valueOf(player.getExp()));
|
||||
adminReply.replace("%sp%", String.valueOf(player.getSp()));
|
||||
adminReply.replace("%class%", ClassListData.getInstance().getClass(player.getClassId()).getClientCode());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private boolean adminAddExpSp(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String exp = st.nextToken();
|
||||
final String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
long spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Long.parseLong(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is adding you " + expval + " xp and " + spval + " sp.");
|
||||
player.addExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Added " + expval + " xp and " + spval + " sp to " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") added " + expval + " xp and " + spval + " sp to " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean adminRemoveExpSP(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String exp = st.nextToken();
|
||||
final String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
int spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Integer.parseInt(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is removing you " + expval + " xp and " + spval + " sp.");
|
||||
player.removeExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Removed " + expval + " xp and " + spval + " sp from " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") removed " + expval + " xp and " + spval + " sp from " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* <li>add_exp_sp_to_character <i>shows menu for add or remove</i>
|
||||
* <li>add_exp_sp exp sp <i>Adds exp & sp to target, displays menu if a parameter is missing</i>
|
||||
* <li>remove_exp_sp exp sp <i>Removes exp & sp from target, displays menu if a parameter is missing</i>
|
||||
* @version $Revision: 1.2.4.6 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminExpSp implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminExpSp.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_exp_sp_to_character",
|
||||
"admin_add_exp_sp",
|
||||
"admin_remove_exp_sp"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_add_exp_sp"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(16);
|
||||
if (!adminAddExpSp(activeChar, val))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //add_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_remove_exp_sp"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(19);
|
||||
if (!adminRemoveExpSP(activeChar, val))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //remove_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{ // Case of missing parameter
|
||||
activeChar.sendMessage("Usage: //remove_exp_sp exp sp");
|
||||
}
|
||||
}
|
||||
addExpSp(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void addExpSp(L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/expsp.htm");
|
||||
adminReply.replace("%name%", player.getName());
|
||||
adminReply.replace("%level%", String.valueOf(player.getLevel()));
|
||||
adminReply.replace("%xp%", String.valueOf(player.getExp()));
|
||||
adminReply.replace("%sp%", String.valueOf(player.getSp()));
|
||||
adminReply.replace("%class%", ClassListData.getInstance().getClass(player.getClassId()).getClientCode());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private boolean adminAddExpSp(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String exp = st.nextToken();
|
||||
final String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
long spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Long.parseLong(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is adding you " + expval + " xp and " + spval + " sp.");
|
||||
player.addExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Added " + expval + " xp and " + spval + " sp to " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") added " + expval + " xp and " + spval + " sp to " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean adminRemoveExpSP(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String exp = st.nextToken();
|
||||
final String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
int spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Integer.parseInt(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is removing you " + expval + " xp and " + spval + " sp.");
|
||||
player.removeExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Removed " + expval + " xp and " + spval + " sp from " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") removed " + expval + " xp and " + spval + " sp from " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,346 +1,357 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.stats.Formulas;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode on/off
|
||||
* @version $Revision: 1.1.2.1 $ $Date: 2005/03/15 21:32:48 $
|
||||
*/
|
||||
public class AdminFightCalculator implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fight_calculator",
|
||||
"admin_fight_calculator_show",
|
||||
"admin_fcs",
|
||||
};
|
||||
|
||||
// TODO: remove from gm list etc etc
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.startsWith("admin_fight_calculator_show"))
|
||||
{
|
||||
handleShow(command.substring("admin_fight_calculator_show".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fcs"))
|
||||
{
|
||||
handleShow(command.substring("admin_fcs".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fight_calculator"))
|
||||
{
|
||||
handleStart(command.substring("admin_fight_calculator".length()), activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleStart(String params, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params);
|
||||
int lvl1 = 0;
|
||||
int lvl2 = 0;
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String s = st.nextToken();
|
||||
if (s.equals("lvl1"))
|
||||
{
|
||||
lvl1 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("lvl2"))
|
||||
{
|
||||
lvl2 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("mid1"))
|
||||
{
|
||||
mid1 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("mid2"))
|
||||
{
|
||||
mid2 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
final L2NpcTemplate npc1 = mid1 != 0 ? NpcData.getInstance().getTemplate(mid1) : null;
|
||||
final L2NpcTemplate npc2 = mid2 != 0 ? NpcData.getInstance().getTemplate(mid2) : null;
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
final String replyMSG;
|
||||
|
||||
if ((npc1 != null) && (npc2 != null))
|
||||
{
|
||||
replyMSG = StringUtil.concat("<html><title>Selected mobs to fight</title><body><table><tr><td>First</td><td>Second</td></tr><tr><td>level ", String.valueOf(lvl1), "</td><td>level ", String.valueOf(lvl2), "</td></tr><tr><td>id ", String.valueOf(npc1.getId()), "</td><td>id ", String.valueOf(npc2.getId()), "</td></tr><tr><td>", npc1.getName(), "</td><td>", npc2.getName(), "</td></tr></table><center><br><br><br><button value=\"OK\" action=\"bypass -h admin_fight_calculator_show ", String.valueOf(npc1.getId()), " ", String.valueOf(npc2.getId()), "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else if ((lvl1 != 0) && (npc1 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl1);
|
||||
final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "<html><title>Select first mob to fight</title><body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 ", String.valueOf(lvl1), " lvl2 ", String.valueOf(lvl2), " mid1 ", String.valueOf(n.getId()), " mid2 ", String.valueOf(mid2), "\">", n.getName(), "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else if ((lvl2 != 0) && (npc2 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl2);
|
||||
final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "<html><title>Select second mob to fight</title><body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 ", String.valueOf(lvl1), " lvl2 ", String.valueOf(lvl2), " mid1 ", String.valueOf(mid1), " mid2 ", String.valueOf(n.getId()), "\">", n.getName(), "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG = "<html><title>Select mobs to fight</title><body><table><tr><td>First</td><td>Second</td></tr><tr><td><edit var=\"lvl1\" width=80></td><td><edit var=\"lvl2\" width=80></td></tr></table><center><br><br><br><button value=\"OK\" action=\"bypass -h admin_fight_calculator lvl1 $lvl1 lvl2 $lvl2\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>";
|
||||
}
|
||||
|
||||
adminReply.setHtml(replyMSG);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void handleShow(String params, L2PcInstance activeChar)
|
||||
{
|
||||
params = params.trim();
|
||||
|
||||
L2Character npc1 = null;
|
||||
L2Character npc2 = null;
|
||||
if (params.length() == 0)
|
||||
{
|
||||
npc1 = activeChar;
|
||||
npc2 = (L2Character) activeChar.getTarget();
|
||||
if (npc2 == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
final StringTokenizer st = new StringTokenizer(params);
|
||||
mid1 = Integer.parseInt(st.nextToken());
|
||||
mid2 = Integer.parseInt(st.nextToken());
|
||||
|
||||
npc1 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid1));
|
||||
npc2 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid2));
|
||||
}
|
||||
|
||||
int miss1 = 0;
|
||||
int miss2 = 0;
|
||||
int shld1 = 0;
|
||||
int shld2 = 0;
|
||||
int crit1 = 0;
|
||||
int crit2 = 0;
|
||||
double patk1 = 0;
|
||||
double patk2 = 0;
|
||||
double pdef1 = 0;
|
||||
double pdef2 = 0;
|
||||
double dmg1 = 0;
|
||||
double dmg2 = 0;
|
||||
|
||||
// ATTACK speed in milliseconds
|
||||
int sAtk1 = npc1.calculateTimeBetweenAttacks();
|
||||
int sAtk2 = npc2.calculateTimeBetweenAttacks();
|
||||
// number of ATTACK per 100 seconds
|
||||
sAtk1 = 100000 / sAtk1;
|
||||
sAtk2 = 100000 / sAtk2;
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
final boolean _miss1 = Formulas.calcHitMiss(npc1, npc2);
|
||||
if (_miss1)
|
||||
{
|
||||
miss1++;
|
||||
}
|
||||
final byte _shld1 = Formulas.calcShldUse(npc1, npc2, null, false);
|
||||
if (_shld1 > 0)
|
||||
{
|
||||
shld1++;
|
||||
}
|
||||
final boolean _crit1 = Formulas.calcCrit(npc1, npc2);
|
||||
if (_crit1)
|
||||
{
|
||||
crit1++;
|
||||
}
|
||||
|
||||
double _patk1 = npc1.getPAtk(npc2);
|
||||
_patk1 += npc1.getRandomDamageMultiplier();
|
||||
patk1 += _patk1;
|
||||
|
||||
final double _pdef1 = npc1.getPDef(npc2);
|
||||
pdef1 += _pdef1;
|
||||
|
||||
if (!_miss1)
|
||||
{
|
||||
final double _dmg1 = Formulas.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false);
|
||||
dmg1 += _dmg1;
|
||||
npc1.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
final boolean _miss2 = Formulas.calcHitMiss(npc2, npc1);
|
||||
if (_miss2)
|
||||
{
|
||||
miss2++;
|
||||
}
|
||||
final byte _shld2 = Formulas.calcShldUse(npc2, npc1, null, false);
|
||||
if (_shld2 > 0)
|
||||
{
|
||||
shld2++;
|
||||
}
|
||||
final boolean _crit2 = Formulas.calcCrit(npc2, npc1);
|
||||
if (_crit2)
|
||||
{
|
||||
crit2++;
|
||||
}
|
||||
|
||||
double _patk2 = npc2.getPAtk(npc1);
|
||||
_patk2 *= npc2.getRandomDamageMultiplier();
|
||||
patk2 += _patk2;
|
||||
|
||||
final double _pdef2 = npc2.getPDef(npc1);
|
||||
pdef2 += _pdef2;
|
||||
|
||||
if (!_miss2)
|
||||
{
|
||||
final double _dmg2 = Formulas.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false);
|
||||
dmg2 += _dmg2;
|
||||
npc2.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
miss1 /= 100;
|
||||
miss2 /= 100;
|
||||
shld1 /= 100;
|
||||
shld2 /= 100;
|
||||
crit1 /= 100;
|
||||
crit2 /= 100;
|
||||
patk1 /= 10000;
|
||||
patk2 /= 10000;
|
||||
pdef1 /= 10000;
|
||||
pdef2 /= 10000;
|
||||
dmg1 /= 10000;
|
||||
dmg2 /= 10000;
|
||||
|
||||
// total damage per 100 seconds
|
||||
final int tdmg1 = (int) (sAtk1 * dmg1);
|
||||
final int tdmg2 = (int) (sAtk2 * dmg2);
|
||||
// HP restored per 100 seconds
|
||||
final double maxHp1 = npc1.getMaxHp();
|
||||
final int hp1 = (int) ((Formulas.calcHpRegen(npc1) * 100000) / Formulas.getRegeneratePeriod(npc1));
|
||||
|
||||
final double maxHp2 = npc2.getMaxHp();
|
||||
final int hp2 = (int) ((Formulas.calcHpRegen(npc2) * 100000) / Formulas.getRegeneratePeriod(npc2));
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(1000, "<html><title>Selected mobs to fight</title><body><table>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td width=140>Parameter</td><td width=70>", ((L2NpcTemplate) npc1.getTemplate()).getName(), "</td><td width=70>", ((L2NpcTemplate) npc2.getTemplate()).getName(), "</td></tr>");
|
||||
}
|
||||
|
||||
StringUtil.append(replyMSG, "<tr><td>miss</td><td>", String.valueOf(miss1), "%</td><td>", String.valueOf(miss2), "%</td></tr><tr><td>shld</td><td>", String.valueOf(shld2), "%</td><td>", String.valueOf(shld1), "%</td></tr><tr><td>crit</td><td>", String.valueOf(crit1), "%</td><td>", String.valueOf(crit2), "%</td></tr><tr><td>pAtk / pDef</td><td>", String.valueOf((int) patk1), " / ", String.valueOf((int) pdef1), "</td><td>", String.valueOf((int) patk2), " / ", String.valueOf((int) pdef2), "</td></tr><tr><td>made hits</td><td>", String.valueOf(sAtk1), "</td><td>", String.valueOf(sAtk2), "</td></tr><tr><td>dmg per hit</td><td>", String.valueOf((int) dmg1), "</td><td>", String.valueOf((int) dmg2), "</td></tr><tr><td>got dmg</td><td>", String.valueOf(tdmg2), "</td><td>", String.valueOf(tdmg1), "</td></tr><tr><td>got regen</td><td>", String.valueOf(hp1), "</td><td>", String.valueOf(hp2), "</td></tr><tr><td>had HP</td><td>", String.valueOf((int) maxHp1), "</td><td>", String.valueOf((int) maxHp2), "</td></tr><tr><td>die</td>");
|
||||
|
||||
if ((tdmg2 - hp1) > 1)
|
||||
{
|
||||
StringUtil.append(replyMSG, "<td>", String.valueOf((int) ((100 * maxHp1) / (tdmg2 - hp1))), " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
if ((tdmg1 - hp2) > 1)
|
||||
{
|
||||
StringUtil.append(replyMSG, "<td>", String.valueOf((int) ((100 * maxHp2) / (tdmg1 - hp2))), " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
replyMSG.append("</tr></table><center><br>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show ", String.valueOf(((L2NpcTemplate) npc1.getTemplate()).getId()), " ", String.valueOf(((L2NpcTemplate) npc2.getTemplate()).getId()), "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
|
||||
replyMSG.append("</center></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
|
||||
if (params.length() != 0)
|
||||
{
|
||||
((L2MonsterInstance) npc1).deleteMe();
|
||||
((L2MonsterInstance) npc2).deleteMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.stats.Formulas;
|
||||
import com.l2jmobius.gameserver.model.stats.Stats;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode on/off
|
||||
* @version $Revision: 1.1.2.1 $ $Date: 2005/03/15 21:32:48 $
|
||||
*/
|
||||
public class AdminFightCalculator implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fight_calculator",
|
||||
"admin_fight_calculator_show",
|
||||
"admin_fcs",
|
||||
};
|
||||
|
||||
// TODO: remove from gm list etc etc
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.startsWith("admin_fight_calculator_show"))
|
||||
{
|
||||
handleShow(command.substring("admin_fight_calculator_show".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fcs"))
|
||||
{
|
||||
handleShow(command.substring("admin_fcs".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fight_calculator"))
|
||||
{
|
||||
handleStart(command.substring("admin_fight_calculator".length()), activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleStart(String params, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(params);
|
||||
int lvl1 = 0;
|
||||
int lvl2 = 0;
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
final String s = st.nextToken();
|
||||
if (s.equals("lvl1"))
|
||||
{
|
||||
lvl1 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("lvl2"))
|
||||
{
|
||||
lvl2 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("mid1"))
|
||||
{
|
||||
mid1 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
if (s.equals("mid2"))
|
||||
{
|
||||
mid2 = Integer.parseInt(st.nextToken());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
L2NpcTemplate npc1 = null;
|
||||
if (mid1 != 0)
|
||||
{
|
||||
npc1 = NpcData.getInstance().getTemplate(mid1);
|
||||
}
|
||||
L2NpcTemplate npc2 = null;
|
||||
if (mid2 != 0)
|
||||
{
|
||||
npc2 = NpcData.getInstance().getTemplate(mid2);
|
||||
}
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
|
||||
final String replyMSG;
|
||||
|
||||
if ((npc1 != null) && (npc2 != null))
|
||||
{
|
||||
replyMSG = "<html><title>Selected mobs to fight</title><body><table><tr><td>First</td><td>Second</td></tr><tr><td>level " + lvl1 + "</td><td>level " + lvl2 + "</td></tr><tr><td>id " + npc1.getId() + "</td><td>id " + npc2.getId() + "</td></tr><tr><td>" + npc1.getName() + "</td><td>" + npc2.getName() + "</td></tr></table><center><br><br><br><button value=\"OK\" action=\"bypass -h admin_fight_calculator_show " + npc1.getId() + " " + npc2.getId() + "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>";
|
||||
}
|
||||
else if ((lvl1 != 0) && (npc1 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl1);
|
||||
final StringBuilder sb = new StringBuilder(50 + (npcs.size() * 200));
|
||||
sb.append("<html><title>Select first mob to fight</title><body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
sb.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + n.getId() + " mid2 " + mid2 + "\">" + n.getName() + "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else if ((lvl2 != 0) && (npc2 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl2);
|
||||
final StringBuilder sb = new StringBuilder(50 + (npcs.size() * 200));
|
||||
sb.append("<html><title>Select second mob to fight</title><body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
sb.append("<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 " + lvl1 + " lvl2 " + lvl2 + " mid1 " + mid1 + " mid2 " + n.getId() + "\">" + n.getName() + "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG = "<html><title>Select mobs to fight</title><body><table><tr><td>First</td><td>Second</td></tr><tr><td><edit var=\"lvl1\" width=80></td><td><edit var=\"lvl2\" width=80></td></tr></table><center><br><br><br><button value=\"OK\" action=\"bypass -h admin_fight_calculator lvl1 $lvl1 lvl2 $lvl2\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>";
|
||||
}
|
||||
|
||||
adminReply.setHtml(replyMSG);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void handleShow(String params, L2PcInstance activeChar)
|
||||
{
|
||||
params = params.trim();
|
||||
|
||||
L2Character npc1 = null;
|
||||
L2Character npc2 = null;
|
||||
if (params.length() == 0)
|
||||
{
|
||||
npc1 = activeChar;
|
||||
npc2 = (L2Character) activeChar.getTarget();
|
||||
if (npc2 == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
final StringTokenizer st = new StringTokenizer(params);
|
||||
mid1 = Integer.parseInt(st.nextToken());
|
||||
mid2 = Integer.parseInt(st.nextToken());
|
||||
|
||||
npc1 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid1));
|
||||
npc2 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid2));
|
||||
}
|
||||
|
||||
int miss1 = 0;
|
||||
int miss2 = 0;
|
||||
int shld1 = 0;
|
||||
int shld2 = 0;
|
||||
int crit1 = 0;
|
||||
int crit2 = 0;
|
||||
double patk1 = 0;
|
||||
double patk2 = 0;
|
||||
double pdef1 = 0;
|
||||
double pdef2 = 0;
|
||||
double dmg1 = 0;
|
||||
double dmg2 = 0;
|
||||
|
||||
// ATTACK speed in milliseconds
|
||||
int sAtk1 = Formulas.calculateTimeBetweenAttacks(npc1, null);
|
||||
int sAtk2 = Formulas.calculateTimeBetweenAttacks(npc2, null);
|
||||
// number of ATTACK per 100 seconds
|
||||
sAtk1 = 100000 / sAtk1;
|
||||
sAtk2 = 100000 / sAtk2;
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
final boolean _miss1 = Formulas.calcHitMiss(npc1, npc2);
|
||||
if (_miss1)
|
||||
{
|
||||
miss1++;
|
||||
}
|
||||
final byte _shld1 = Formulas.calcShldUse(npc1, npc2, false);
|
||||
if (_shld1 > 0)
|
||||
{
|
||||
shld1++;
|
||||
}
|
||||
final boolean _crit1 = Formulas.calcCrit(npc1.getCriticalHit(), npc1, npc2, null);
|
||||
if (_crit1)
|
||||
{
|
||||
crit1++;
|
||||
}
|
||||
|
||||
double _patk1 = npc1.getPAtk();
|
||||
_patk1 += npc1.getRandomDamageMultiplier();
|
||||
patk1 += _patk1;
|
||||
|
||||
final double _pdef1 = npc1.getPDef();
|
||||
pdef1 += _pdef1;
|
||||
|
||||
if (!_miss1)
|
||||
{
|
||||
final double _dmg1 = Formulas.calcAutoAttackDamage(npc1, npc2, 0, _shld1, _crit1, false);
|
||||
dmg1 += _dmg1;
|
||||
npc1.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
final boolean _miss2 = Formulas.calcHitMiss(npc2, npc1);
|
||||
if (_miss2)
|
||||
{
|
||||
miss2++;
|
||||
}
|
||||
final byte _shld2 = Formulas.calcShldUse(npc2, npc1, false);
|
||||
if (_shld2 > 0)
|
||||
{
|
||||
shld2++;
|
||||
}
|
||||
final boolean _crit2 = Formulas.calcCrit(npc2.getCriticalHit(), npc2, npc1, null);
|
||||
if (_crit2)
|
||||
{
|
||||
crit2++;
|
||||
}
|
||||
|
||||
double _patk2 = npc2.getPAtk();
|
||||
_patk2 *= npc2.getRandomDamageMultiplier();
|
||||
patk2 += _patk2;
|
||||
|
||||
final double _pdef2 = npc2.getPDef();
|
||||
pdef2 += _pdef2;
|
||||
|
||||
if (!_miss2)
|
||||
{
|
||||
final double _dmg2 = Formulas.calcAutoAttackDamage(npc2, npc1, 0, _shld2, _crit2, false);
|
||||
dmg2 += _dmg2;
|
||||
npc2.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
miss1 /= 100;
|
||||
miss2 /= 100;
|
||||
shld1 /= 100;
|
||||
shld2 /= 100;
|
||||
crit1 /= 100;
|
||||
crit2 /= 100;
|
||||
patk1 /= 10000;
|
||||
patk2 /= 10000;
|
||||
pdef1 /= 10000;
|
||||
pdef2 /= 10000;
|
||||
dmg1 /= 10000;
|
||||
dmg2 /= 10000;
|
||||
|
||||
// total damage per 100 seconds
|
||||
final int tdmg1 = (int) (sAtk1 * dmg1);
|
||||
final int tdmg2 = (int) (sAtk2 * dmg2);
|
||||
// HP restored per 100 seconds
|
||||
final double maxHp1 = npc1.getMaxHp();
|
||||
final int hp1 = (int) ((npc1.getStat().getValue(Stats.REGENERATE_HP_RATE) * 100000) / Formulas.getRegeneratePeriod(npc1));
|
||||
|
||||
final double maxHp2 = npc2.getMaxHp();
|
||||
final int hp2 = (int) ((npc2.getStat().getValue(Stats.REGENERATE_HP_RATE) * 100000) / Formulas.getRegeneratePeriod(npc2));
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
|
||||
final StringBuilder replyMSG = new StringBuilder(1000);
|
||||
replyMSG.append("<html><title>Selected mobs to fight</title><body><table>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>" + ((L2NpcTemplate) npc1.getTemplate()).getName() + "</td><td width=70>" + ((L2NpcTemplate) npc2.getTemplate()).getName() + "</td></tr>");
|
||||
}
|
||||
|
||||
replyMSG.append("<tr><td>miss</td><td>" + miss1 + "%</td><td>" + miss2 + "%</td></tr><tr><td>shld</td><td>" + shld2 + "%</td><td>" + shld1 + "%</td></tr><tr><td>crit</td><td>" + crit1 + "%</td><td>" + crit2 + "%</td></tr><tr><td>pAtk / pDef</td><td>" + (int) patk1 + " / " + (int) pdef1 + "</td><td>" + (int) patk2 + " / " + (int) pdef2 + "</td></tr><tr><td>made hits</td><td>" + sAtk1 + "</td><td>" + sAtk2 + "</td></tr><tr><td>dmg per hit</td><td>" + (int) dmg1 + "</td><td>" + (int) dmg2 + "</td></tr><tr><td>got dmg</td><td>" + tdmg2 + "</td><td>" + tdmg1 + "</td></tr><tr><td>got regen</td><td>" + hp1 + "</td><td>" + hp2 + "</td></tr><tr><td>had HP</td><td>" + (int) maxHp1 + "</td><td>" + (int) maxHp2 + "</td></tr><tr><td>die</td>");
|
||||
|
||||
if ((tdmg2 - hp1) > 1)
|
||||
{
|
||||
replyMSG.append("<td>" + ((int) ((100 * maxHp1) / (tdmg2 - hp1))) + " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
if ((tdmg1 - hp2) > 1)
|
||||
{
|
||||
replyMSG.append("<td>" + ((int) ((100 * maxHp2) / (tdmg1 - hp2))) + " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
replyMSG.append("</tr></table><center><br>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show " + ((L2NpcTemplate) npc1.getTemplate()).getId() + " " + ((L2NpcTemplate) npc2.getTemplate()).getId() + "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
|
||||
replyMSG.append("</center></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
|
||||
if (params.length() != 0)
|
||||
{
|
||||
npc1.deleteMe();
|
||||
npc2.deleteMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,188 +1,191 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Fort;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles all siege commands: Todo: change the class name, and neaten it up
|
||||
*/
|
||||
public class AdminFortSiege implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminFortSiege.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fortsiege",
|
||||
"admin_add_fortattacker",
|
||||
"admin_list_fortsiege_clans",
|
||||
"admin_clear_fortsiege_list",
|
||||
"admin_spawn_fortdoors",
|
||||
"admin_endfortsiege",
|
||||
"admin_startfortsiege",
|
||||
"admin_setfort",
|
||||
"admin_removefort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken(); // Get actual command
|
||||
|
||||
// Get fort
|
||||
Fort fort = null;
|
||||
int fortId = 0;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
fortId = Integer.parseInt(st.nextToken());
|
||||
fort = FortManager.getInstance().getFortById(fortId);
|
||||
}
|
||||
// Get fort
|
||||
if ((fort == null) || (fortId == 0))
|
||||
{
|
||||
// No fort specified
|
||||
showFortSelectPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase("admin_add_fortattacker"))
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
else if (fort.getSiege().addAttacker(player, false) == 4)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_CLAN_HAS_BEEN_REGISTERED_TO_S1_S_FORTRESS_BATTLE);
|
||||
sm.addCastleId(fort.getResidenceId());
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("During registering error occurred!");
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clear_fortsiege_list"))
|
||||
{
|
||||
fort.getSiege().clearSiegeClan();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_endfortsiege"))
|
||||
{
|
||||
fort.getSiege().endSiege();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_list_fortsiege_clans"))
|
||||
{
|
||||
activeChar.sendMessage("Not implemented yet.");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_setfort"))
|
||||
{
|
||||
if ((player == null) || (player.getClan() == null))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
fort.endOfSiege(player.getClan());
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_removefort"))
|
||||
{
|
||||
if (fort.getOwnerClan() != null)
|
||||
{
|
||||
fort.removeOwner(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Unable to remove fort");
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_fortdoors"))
|
||||
{
|
||||
fort.resetDoors();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_startfortsiege"))
|
||||
{
|
||||
fort.getSiege().startSiege();
|
||||
}
|
||||
|
||||
showFortSiegePage(activeChar, fort);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showFortSelectPage(L2PcInstance activeChar)
|
||||
{
|
||||
int i = 0;
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/forts.htm");
|
||||
|
||||
final List<Fort> forts = FortManager.getInstance().getForts();
|
||||
final StringBuilder cList = new StringBuilder(forts.size() * 100);
|
||||
|
||||
for (Fort fort : forts)
|
||||
{
|
||||
if (fort != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ", String.valueOf(fort.getResidenceId()), "\">", fort.getName(), " id: ", String.valueOf(fort.getResidenceId()), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > 2)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
adminReply.replace("%forts%", cList.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showFortSiegePage(L2PcInstance activeChar, Fort fort)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/fort.htm");
|
||||
adminReply.replace("%fortName%", fort.getName());
|
||||
adminReply.replace("%fortId%", String.valueOf(fort.getResidenceId()));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.FortManager;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Fort;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class handles all siege commands: Todo: change the class name, and neaten it up
|
||||
*/
|
||||
public class AdminFortSiege implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fortsiege",
|
||||
"admin_add_fortattacker",
|
||||
"admin_list_fortsiege_clans",
|
||||
"admin_clear_fortsiege_list",
|
||||
"admin_spawn_fortdoors",
|
||||
"admin_endfortsiege",
|
||||
"admin_startfortsiege",
|
||||
"admin_setfort",
|
||||
"admin_removefort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken(); // Get actual command
|
||||
|
||||
// Get fort
|
||||
Fort fort = null;
|
||||
int fortId = 0;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
fortId = Integer.parseInt(st.nextToken());
|
||||
fort = FortManager.getInstance().getFortById(fortId);
|
||||
}
|
||||
// Get fort
|
||||
if (((fort == null) || (fortId == 0)))
|
||||
{
|
||||
// No fort specified
|
||||
showFortSelectPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase("admin_add_fortattacker"))
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fort.getSiege().addAttacker(player, false) == 4)
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOUR_CLAN_HAS_BEEN_REGISTERED_TO_S1_S_FORTRESS_BATTLE);
|
||||
sm.addCastleId(fort.getResidenceId());
|
||||
player.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("During registering error occurred!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clear_fortsiege_list"))
|
||||
{
|
||||
fort.getSiege().clearSiegeClan();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_endfortsiege"))
|
||||
{
|
||||
fort.getSiege().endSiege();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_list_fortsiege_clans"))
|
||||
{
|
||||
activeChar.sendMessage("Not implemented yet.");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_setfort"))
|
||||
{
|
||||
if ((player == null) || (player.getClan() == null))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
fort.endOfSiege(player.getClan());
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_removefort"))
|
||||
{
|
||||
final L2Clan clan = fort.getOwnerClan();
|
||||
if (clan != null)
|
||||
{
|
||||
fort.removeOwner(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Unable to remove fort");
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_fortdoors"))
|
||||
{
|
||||
fort.resetDoors();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_startfortsiege"))
|
||||
{
|
||||
fort.getSiege().startSiege();
|
||||
}
|
||||
|
||||
showFortSiegePage(activeChar, fort);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showFortSelectPage(L2PcInstance activeChar)
|
||||
{
|
||||
int i = 0;
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/forts.htm");
|
||||
|
||||
final Collection<Fort> forts = FortManager.getInstance().getForts();
|
||||
final StringBuilder cList = new StringBuilder(forts.size() * 100);
|
||||
|
||||
for (Fort fort : forts)
|
||||
{
|
||||
if (fort != null)
|
||||
{
|
||||
cList.append("<td fixwidth=90><a action=\"bypass -h admin_fortsiege " + fort.getResidenceId() + "\">" + fort.getName() + " id: " + fort.getResidenceId() + "</a></td>");
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > 2)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
adminReply.replace("%forts%", cList.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showFortSiegePage(L2PcInstance activeChar, Fort fort)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/fort.htm");
|
||||
adminReply.replace("%fortName%", fort.getName());
|
||||
adminReply.replace("%fortId%", String.valueOf(fort.getResidenceId()));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,55 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminGm implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminGm.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gm"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_gm") && activeChar.isGM())
|
||||
{
|
||||
AdminData.getInstance().deleteGm(activeChar);
|
||||
activeChar.setAccessLevel(0, true);
|
||||
activeChar.sendMessage("You no longer have GM status.");
|
||||
_log.info("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") turned his GM status off");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminGm implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gm"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_gm") && activeChar.isGM())
|
||||
{
|
||||
AdminData.getInstance().deleteGm(activeChar);
|
||||
activeChar.setAccessLevel(0, true, false);
|
||||
activeChar.sendMessage("You deactivated your GM access for this session, if you login again you will be GM again, in order to remove your access completely please shift yourself and set your accesslevel to 0.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,124 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gmchat text = sends text to all online GM's - gmchat_menu text = same as gmchat, displays the admin panel after chat
|
||||
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminGmChat implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gmchat",
|
||||
"admin_snoop",
|
||||
"admin_gmchat_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_gmchat"))
|
||||
{
|
||||
handleGmChat(command, activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_snoop"))
|
||||
{
|
||||
snoop(command, activeChar);
|
||||
}
|
||||
if (command.startsWith("admin_gmchat_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param activeChar
|
||||
*/
|
||||
private void snoop(String command, L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = null;
|
||||
if (command.length() > 12)
|
||||
{
|
||||
target = L2World.getInstance().getPlayer(command.substring(12));
|
||||
}
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.SELECT_TARGET);
|
||||
return;
|
||||
}
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
final L2PcInstance player = (L2PcInstance) target;
|
||||
player.addSnooper(activeChar);
|
||||
activeChar.addSnooped(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param activeChar
|
||||
*/
|
||||
private void handleGmChat(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
int offset = 0;
|
||||
String text;
|
||||
if (command.startsWith("admin_gmchat_menu"))
|
||||
{
|
||||
offset = 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 13;
|
||||
}
|
||||
text = command.substring(offset);
|
||||
AdminData.getInstance().broadcastToGMs(new CreatureSay(0, ChatType.ALLIANCE, activeChar.getName(), text));
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
// Who cares?
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gmchat text = sends text to all online GM's - gmchat_menu text = same as gmchat, displays the admin panel after chat
|
||||
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminGmChat implements IAdminCommandHandler
|
||||
{
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gmchat",
|
||||
"admin_snoop",
|
||||
"admin_gmchat_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_gmchat"))
|
||||
{
|
||||
handleGmChat(command, activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_snoop"))
|
||||
{
|
||||
snoop(command, activeChar);
|
||||
}
|
||||
if (command.startsWith("admin_gmchat_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param activeChar
|
||||
*/
|
||||
private void snoop(String command, L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = null;
|
||||
if (command.length() > 12)
|
||||
{
|
||||
target = L2World.getInstance().getPlayer(command.substring(12));
|
||||
}
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar.getTarget();
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.SELECT_TARGET);
|
||||
return;
|
||||
}
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
final L2PcInstance player = (L2PcInstance) target;
|
||||
player.addSnooper(activeChar);
|
||||
activeChar.addSnooped(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param command
|
||||
* @param activeChar
|
||||
*/
|
||||
private void handleGmChat(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
int offset = 0;
|
||||
String text;
|
||||
if (command.startsWith("admin_gmchat_menu"))
|
||||
{
|
||||
offset = 18;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 13;
|
||||
}
|
||||
text = command.substring(offset);
|
||||
final CreatureSay cs = new CreatureSay(0, ChatType.ALLIANCE, activeChar.getName(), text);
|
||||
AdminData.getInstance().broadcastToGMs(cs);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
// Who cares?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,85 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Calendar;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class AdminGraciaSeeds implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gracia_seeds",
|
||||
"admin_kill_tiat",
|
||||
"admin_set_sodstate"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
final String val = st.countTokens() >= 1 ? st.nextToken() : "";
|
||||
if (actualCommand.equalsIgnoreCase("admin_kill_tiat"))
|
||||
{
|
||||
GraciaSeedsManager.getInstance().increaseSoDTiatKilled();
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_set_sodstate"))
|
||||
{
|
||||
GraciaSeedsManager.getInstance().setSoDState(Integer.parseInt(val), true);
|
||||
}
|
||||
|
||||
showMenu(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/graciaseeds.htm");
|
||||
html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
|
||||
html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
|
||||
if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
|
||||
{
|
||||
final Calendar nextChangeDate = Calendar.getInstance();
|
||||
nextChangeDate.setTimeInMillis(System.currentTimeMillis() + GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange());
|
||||
html.replace("%sodtime%", nextChangeDate.getTime().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%sodtime%", "-1");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Calendar;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.GraciaSeedsManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class AdminGraciaSeeds implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gracia_seeds",
|
||||
"admin_kill_tiat",
|
||||
"admin_set_sodstate"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
String val = "";
|
||||
if (st.countTokens() >= 1)
|
||||
{
|
||||
val = st.nextToken();
|
||||
}
|
||||
|
||||
if (actualCommand.equalsIgnoreCase("admin_kill_tiat"))
|
||||
{
|
||||
GraciaSeedsManager.getInstance().increaseSoDTiatKilled();
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_set_sodstate"))
|
||||
{
|
||||
GraciaSeedsManager.getInstance().setSoDState(Integer.parseInt(val), true);
|
||||
}
|
||||
|
||||
showMenu(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/graciaseeds.htm");
|
||||
html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
|
||||
html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
|
||||
if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
|
||||
{
|
||||
final Calendar nextChangeDate = Calendar.getInstance();
|
||||
nextChangeDate.setTimeInMillis(System.currentTimeMillis() + GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange());
|
||||
html.replace("%sodtime%", nextChangeDate.getTime().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%sodtime%", "-1");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,330 +1,343 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 java.util.Arrays;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2NoRestartZone;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
import ai.individual.Antharas.Antharas;
|
||||
import ai.individual.Baium.Baium;
|
||||
|
||||
/**
|
||||
* @author St3eT
|
||||
*/
|
||||
public class AdminGrandBoss implements IAdminCommandHandler
|
||||
{
|
||||
private static final int ANTHARAS = 29068; // Antharas
|
||||
private static final int ANTHARAS_ZONE = 70050; // Antharas Nest
|
||||
private static final int VALAKAS = 29028; // Valakas
|
||||
private static final int BAIUM = 29020; // Baium
|
||||
private static final int BAIUM_ZONE = 70051; // Baium Nest
|
||||
private static final int QUEENANT = 29001; // Queen Ant
|
||||
private static final int ORFEN = 29014; // Orfen
|
||||
private static final int CORE = 29006; // Core
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_grandboss",
|
||||
"admin_grandboss_skip",
|
||||
"admin_grandboss_respawn",
|
||||
"admin_grandboss_minions",
|
||||
"admin_grandboss_abort",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_grandboss":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
manageHtml(activeChar, Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/grandboss.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "admin_grandboss_skip":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
if (grandBossId == ANTHARAS)
|
||||
{
|
||||
antharasAi().notifyEvent("SKIP_WAITING", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_skip Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_respawn":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("RESPAWN_ANTHARAS", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("RESPAWN_BAIUM", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_respawn Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_minions":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
switch (Integer.parseInt(st.nextToken()))
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("DESPAWN_MINIONS", null, activeChar);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("DESPAWN_MINIONS", null, activeChar);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_minions Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_abort":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("ABORT_FIGHT", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("ABORT_FIGHT", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_abort Id");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void manageHtml(L2PcInstance activeChar, int grandBossId)
|
||||
{
|
||||
if (Arrays.asList(ANTHARAS, VALAKAS, BAIUM, QUEENANT, ORFEN, CORE).contains(grandBossId))
|
||||
{
|
||||
final int bossStatus = GrandBossManager.getInstance().getBossStatus(grandBossId);
|
||||
L2NoRestartZone bossZone = null;
|
||||
String textColor = null;
|
||||
String text = null;
|
||||
String htmlPatch = null;
|
||||
int deadStatus = 0;
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
bossZone = ZoneManager.getInstance().getZoneById(ANTHARAS_ZONE, L2NoRestartZone.class);
|
||||
htmlPatch = "html/admin/grandboss_antharas.htm";
|
||||
break;
|
||||
}
|
||||
case VALAKAS:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_valakas.htm";
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
bossZone = ZoneManager.getInstance().getZoneById(BAIUM_ZONE, L2NoRestartZone.class);
|
||||
htmlPatch = "html/admin/grandboss_baium.htm";
|
||||
break;
|
||||
}
|
||||
case QUEENANT:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_queenant.htm";
|
||||
break;
|
||||
}
|
||||
case ORFEN:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_orfen.htm";
|
||||
break;
|
||||
}
|
||||
case CORE:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_core.htm";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Arrays.asList(ANTHARAS, VALAKAS, BAIUM).contains(grandBossId))
|
||||
{
|
||||
deadStatus = 3;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FFFF00"; // Yellow
|
||||
text = "Waiting";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
textColor = "FF9900"; // Orange
|
||||
text = "In Fight";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deadStatus = 1;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StatsSet info = GrandBossManager.getInstance().getStatsSet(grandBossId);
|
||||
final String bossRespawn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(info.getLong("respawn_time"));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPatch));
|
||||
html.replace("%bossStatus%", text);
|
||||
html.replace("%bossColor%", textColor);
|
||||
html.replace("%respawnTime%", bossStatus == deadStatus ? bossRespawn : "Already respawned!");
|
||||
html.replace("%playersInside%", bossZone != null ? String.valueOf(bossZone.getPlayersInside().size()) : "Zone not found!");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
|
||||
private Quest antharasAi()
|
||||
{
|
||||
return QuestManager.getInstance().getQuest(Antharas.class.getSimpleName());
|
||||
}
|
||||
|
||||
private Quest baiumAi()
|
||||
{
|
||||
return QuestManager.getInstance().getQuest(Baium.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 java.util.Arrays;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2NoRestartZone;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
import ai.areas.LairOfAntharas.Antharas.Antharas;
|
||||
import ai.areas.TowerOfInsolence.Baium.Baium;
|
||||
|
||||
/**
|
||||
* @author St3eT
|
||||
*/
|
||||
public class AdminGrandBoss implements IAdminCommandHandler
|
||||
{
|
||||
private static final int ANTHARAS = 29068; // Antharas
|
||||
private static final int ANTHARAS_ZONE = 70050; // Antharas Nest
|
||||
private static final int VALAKAS = 29028; // Valakas
|
||||
private static final int BAIUM = 29020; // Baium
|
||||
private static final int BAIUM_ZONE = 70051; // Baium Nest
|
||||
private static final int QUEENANT = 29001; // Queen Ant
|
||||
private static final int ORFEN = 29014; // Orfen
|
||||
private static final int CORE = 29006; // Core
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_grandboss",
|
||||
"admin_grandboss_skip",
|
||||
"admin_grandboss_respawn",
|
||||
"admin_grandboss_minions",
|
||||
"admin_grandboss_abort",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_grandboss":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
manageHtml(activeChar, grandBossId);
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/grandboss.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "admin_grandboss_skip":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
if (grandBossId == ANTHARAS)
|
||||
{
|
||||
antharasAi().notifyEvent("SKIP_WAITING", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_skip Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_respawn":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("RESPAWN_ANTHARAS", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("RESPAWN_BAIUM", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_respawn Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_minions":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("DESPAWN_MINIONS", null, activeChar);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("DESPAWN_MINIONS", null, activeChar);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_minions Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_abort":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("ABORT_FIGHT", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("ABORT_FIGHT", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_abort Id");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void manageHtml(L2PcInstance activeChar, int grandBossId)
|
||||
{
|
||||
if (Arrays.asList(ANTHARAS, VALAKAS, BAIUM, QUEENANT, ORFEN, CORE).contains(grandBossId))
|
||||
{
|
||||
final int bossStatus = GrandBossManager.getInstance().getBossStatus(grandBossId);
|
||||
L2NoRestartZone bossZone = null;
|
||||
String textColor = null;
|
||||
String text = null;
|
||||
String htmlPatch = null;
|
||||
int deadStatus = 0;
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
bossZone = ZoneManager.getInstance().getZoneById(ANTHARAS_ZONE, L2NoRestartZone.class);
|
||||
htmlPatch = "data/html/admin/grandboss_antharas.htm";
|
||||
break;
|
||||
}
|
||||
case VALAKAS:
|
||||
{
|
||||
htmlPatch = "data/html/admin/grandboss_valakas.htm";
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
bossZone = ZoneManager.getInstance().getZoneById(BAIUM_ZONE, L2NoRestartZone.class);
|
||||
htmlPatch = "data/html/admin/grandboss_baium.htm";
|
||||
break;
|
||||
}
|
||||
case QUEENANT:
|
||||
{
|
||||
htmlPatch = "data/html/admin/grandboss_queenant.htm";
|
||||
break;
|
||||
}
|
||||
case ORFEN:
|
||||
{
|
||||
htmlPatch = "data/html/admin/grandboss_orfen.htm";
|
||||
break;
|
||||
}
|
||||
case CORE:
|
||||
{
|
||||
htmlPatch = "data/html/admin/grandboss_core.htm";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Arrays.asList(ANTHARAS, VALAKAS, BAIUM).contains(grandBossId))
|
||||
{
|
||||
deadStatus = 3;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FFFF00"; // Yellow
|
||||
text = "Waiting";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
textColor = "FF9900"; // Orange
|
||||
text = "In Fight";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
textColor = "FFFFFF"; // White
|
||||
text = "Unk " + bossStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deadStatus = 1;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
textColor = "FFFFFF"; // White
|
||||
text = "Unk " + bossStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StatsSet info = GrandBossManager.getInstance().getStatsSet(grandBossId);
|
||||
final String bossRespawn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(info.getLong("respawn_time"));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), htmlPatch));
|
||||
html.replace("%bossStatus%", text);
|
||||
html.replace("%bossColor%", textColor);
|
||||
html.replace("%respawnTime%", bossStatus == deadStatus ? bossRespawn : "Already respawned!");
|
||||
html.replace("%playersInside%", bossZone != null ? String.valueOf(bossZone.getPlayersInside().size()) : "Zone not found!");
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
|
||||
private Quest antharasAi()
|
||||
{
|
||||
return QuestManager.getInstance().getQuest(Antharas.class.getSimpleName());
|
||||
}
|
||||
|
||||
private Quest baiumAi()
|
||||
{
|
||||
return QuestManager.getInstance().getQuest(Baium.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,138 +1,135 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - heal = restores HP/MP/CP on target, name or radius
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $ Small typo fix by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminHeal implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_heal"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_heal"))
|
||||
{
|
||||
handleHeal(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_heal"))
|
||||
{
|
||||
try
|
||||
{
|
||||
handleHeal(activeChar, command.substring(11));
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Heal error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Incorrect target/radius specified.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleHeal(L2PcInstance activeChar)
|
||||
{
|
||||
handleHeal(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleHeal(L2PcInstance activeChar, String player)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (player != null)
|
||||
{
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(player);
|
||||
final Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
for (L2Object object : objs)
|
||||
{
|
||||
if (object instanceof L2Character)
|
||||
{
|
||||
final L2Character character = (L2Character) object;
|
||||
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
|
||||
if (object instanceof L2PcInstance)
|
||||
{
|
||||
character.setCurrentCp(character.getMaxCp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Healed within " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException nbe)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
final L2Character target = (L2Character) obj;
|
||||
target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.setCurrentCp(target.getMaxCp());
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") healed character " + target.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - heal = restores HP/MP/CP on target, name or radius
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $ Small typo fix by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminHeal implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_heal"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.equals("admin_heal"))
|
||||
{
|
||||
handleHeal(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_heal"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String healTarget = command.substring(11);
|
||||
handleHeal(activeChar, healTarget);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Heal error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Incorrect target/radius specified.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleHeal(L2PcInstance activeChar)
|
||||
{
|
||||
handleHeal(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleHeal(L2PcInstance activeChar, String player)
|
||||
{
|
||||
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (player != null)
|
||||
{
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(player);
|
||||
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, character ->
|
||||
{
|
||||
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
|
||||
if (character instanceof L2PcInstance)
|
||||
{
|
||||
character.setCurrentCp(character.getMaxCp());
|
||||
}
|
||||
});
|
||||
|
||||
activeChar.sendMessage("Healed within " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException nbe)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
final L2Character target = (L2Character) obj;
|
||||
target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.setCurrentCp(target.getMaxCp());
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") healed character " + target.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +1,120 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminHtml implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_html",
|
||||
"admin_loadhtml"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_html":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //html path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showAdminHtml(activeChar, path);
|
||||
break;
|
||||
}
|
||||
case "admin_loadhtml":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //loadhtml path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showHtml(activeChar, path, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar
|
||||
* @param activeChar activeChar where html is shown
|
||||
* @param path relative path from directory html/admin/ to html
|
||||
*/
|
||||
static void showAdminHtml(L2PcInstance activeChar, String path)
|
||||
{
|
||||
showHtml(activeChar, "html/admin/" + path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar.
|
||||
* @param activeChar activeChar where html message is shown.
|
||||
* @param path relative path from Config.DATAPACK_ROOT to html.
|
||||
* @param reload {@code true} will reload html and show it {@code false} will show it from cache.
|
||||
*/
|
||||
private static void showHtml(L2PcInstance activeChar, String path, boolean reload)
|
||||
{
|
||||
String content = null;
|
||||
if (!reload)
|
||||
{
|
||||
content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
content = HtmCache.getInstance().loadFile(new File(Config.DATAPACK_ROOT, path));
|
||||
}
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
if (content != null)
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml("<html><body>My text is missing:<br>" + path + "</body></html>");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminHtml implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_html",
|
||||
"admin_loadhtml"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_html":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //html path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showAdminHtml(activeChar, path);
|
||||
break;
|
||||
}
|
||||
case "admin_loadhtml":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //loadhtml path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showHtml(activeChar, path, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar
|
||||
* @param activeChar activeChar where html is shown
|
||||
* @param path relative path from directory data/html/admin/ to html
|
||||
*/
|
||||
public static void showAdminHtml(L2PcInstance activeChar, String path)
|
||||
{
|
||||
showHtml(activeChar, "data/html/admin/" + path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar.
|
||||
* @param activeChar activeChar where html message is shown.
|
||||
* @param path relative path from Config.DATAPACK_ROOT to html.
|
||||
* @param reload {@code true} will reload html and show it {@code false} will show it from cache.
|
||||
*/
|
||||
public static void showHtml(L2PcInstance activeChar, String path, boolean reload)
|
||||
{
|
||||
String content = null;
|
||||
if (!reload)
|
||||
{
|
||||
content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
content = HtmCache.getInstance().loadFile(new File(Config.DATAPACK_ROOT, path));
|
||||
}
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
if (content != null)
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml("<html><body>My text is missing:<br>" + path + "</body></html>");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,162 +1,310 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Summon;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Instance;
|
||||
|
||||
/**
|
||||
* @author evill33t, GodKratos
|
||||
*/
|
||||
public class AdminInstance implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_setinstance",
|
||||
"admin_ghoston",
|
||||
"admin_ghostoff",
|
||||
"admin_createinstance",
|
||||
"admin_destroyinstance",
|
||||
"admin_listinstances"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
// create new instance
|
||||
if (command.startsWith("admin_createinstance"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length != 3)
|
||||
{
|
||||
activeChar.sendMessage("Example: //createinstance <id> <templatefile> - ids => 300000 are reserved for dynamic instances");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int id = Integer.parseInt(parts[1]);
|
||||
if ((id < 300000) && InstanceManager.getInstance().createInstanceFromTemplate(id, parts[2]))
|
||||
{
|
||||
activeChar.sendMessage("Instance created.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Failed to create instance.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1] + " " + parts[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_listinstances"))
|
||||
{
|
||||
for (Instance temp : InstanceManager.getInstance().getInstances().values())
|
||||
{
|
||||
activeChar.sendMessage("Id: " + temp.getId() + " Name: " + temp.getName());
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setinstance"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final int val = Integer.parseInt(st.nextToken());
|
||||
if (InstanceManager.getInstance().getInstance(val) == null)
|
||||
{
|
||||
activeChar.sendMessage("Instance " + val + " doesnt exist.");
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || (target instanceof L2Summon)) // Don't separate summons from masters
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
return false;
|
||||
}
|
||||
target.setInstanceId(val);
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
final L2PcInstance player = (L2PcInstance) target;
|
||||
player.sendMessage("Admin set your instance to:" + val);
|
||||
player.teleToLocation(player.getLocation());
|
||||
}
|
||||
activeChar.sendMessage("Moved " + target.getName() + " to instance " + target.getInstanceId() + ".");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Use //setinstance id");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_destroyinstance"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final int val = Integer.parseInt(st.nextToken());
|
||||
InstanceManager.getInstance().destroyInstance(val);
|
||||
activeChar.sendMessage("Instance destroyed");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Use //destroyinstance id");
|
||||
}
|
||||
}
|
||||
|
||||
// set ghost mode on aka not appearing on any knownlist
|
||||
// you will be invis to all players but you also dont get update packets ;)
|
||||
// you will see snapshots (knownlist echoes?) if you port
|
||||
// so kinda useless atm
|
||||
// TODO: enable broadcast packets for ghosts
|
||||
else if (command.startsWith("admin_ghoston"))
|
||||
{
|
||||
activeChar.getAppearance().setGhostMode(true);
|
||||
activeChar.sendMessage("Ghost mode enabled");
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
}
|
||||
// ghost mode off
|
||||
else if (command.startsWith("admin_ghostoff"))
|
||||
{
|
||||
activeChar.getAppearance().setGhostMode(false);
|
||||
activeChar.sendMessage("Ghost mode disabled");
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.html.PageBuilder;
|
||||
import com.l2jmobius.gameserver.model.html.PageResult;
|
||||
import com.l2jmobius.gameserver.model.html.formatters.BypassParserFormatter;
|
||||
import com.l2jmobius.gameserver.model.html.pagehandlers.NextPrevPageHandler;
|
||||
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.model.instancezone.InstanceTemplate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.BypassParser;
|
||||
|
||||
/**
|
||||
* Instance admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminInstance implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_instance",
|
||||
"admin_instances",
|
||||
"admin_instancelist",
|
||||
"admin_instancecreate",
|
||||
"admin_instanceteleport",
|
||||
"admin_instancedestroy",
|
||||
};
|
||||
private static final int[] IGNORED_TEMPLATES =
|
||||
{
|
||||
127, // Chamber of Delusion
|
||||
128, // Chamber of Delusion
|
||||
129, // Chamber of Delusion
|
||||
130, // Chamber of Delusion
|
||||
131, // Chamber of Delusion
|
||||
132, // Chamber of Delusion
|
||||
147, // Grassy Arena
|
||||
149, // Heros's Vestiges Arena
|
||||
150, // Orbis Arena
|
||||
148, // Three Bridges Arena
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_instance":
|
||||
case "admin_instances":
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/instances.htm");
|
||||
html.replace("%instCount%", InstanceManager.getInstance().getInstances().size());
|
||||
html.replace("%tempCount%", InstanceManager.getInstance().getInstanceTemplates().size());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_instancelist":
|
||||
{
|
||||
processBypass(activeChar, new BypassParser(command));
|
||||
break;
|
||||
}
|
||||
case "admin_instancecreate":
|
||||
{
|
||||
final int templateId = CommonUtil.parseNextInt(st, 0);
|
||||
final InstanceTemplate template = InstanceManager.getInstance().getInstanceTemplate(templateId);
|
||||
|
||||
if (template != null)
|
||||
{
|
||||
final String enterGroup = st.hasMoreTokens() ? st.nextToken() : "Alone";
|
||||
final List<L2PcInstance> members = new ArrayList<>();
|
||||
|
||||
switch (enterGroup)
|
||||
{
|
||||
case "Alone":
|
||||
{
|
||||
members.add(activeChar);
|
||||
break;
|
||||
}
|
||||
case "Party":
|
||||
{
|
||||
if (activeChar.isInParty())
|
||||
{
|
||||
members.addAll(activeChar.getParty().getMembers());
|
||||
}
|
||||
else
|
||||
{
|
||||
members.add(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "CommandChannel":
|
||||
{
|
||||
if (activeChar.isInCommandChannel())
|
||||
{
|
||||
members.addAll(activeChar.getParty().getCommandChannel().getMembers());
|
||||
}
|
||||
else if (activeChar.isInParty())
|
||||
{
|
||||
members.addAll(activeChar.getParty().getMembers());
|
||||
}
|
||||
else
|
||||
{
|
||||
members.add(activeChar);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong enter group usage! Please use those values: Alone, Party or CommandChannel.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
final Instance instance = InstanceManager.getInstance().createInstance(template, activeChar);
|
||||
final Location loc = instance.getEnterLocation();
|
||||
if (loc != null)
|
||||
{
|
||||
for (L2PcInstance players : members)
|
||||
{
|
||||
instance.addAllowed(players);
|
||||
players.teleToLocation(loc, instance);
|
||||
}
|
||||
}
|
||||
sendTemplateDetails(activeChar, instance.getTemplateId());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong parameters! Please try again.");
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_instanceteleport":
|
||||
{
|
||||
final Instance instance = InstanceManager.getInstance().getInstance(CommonUtil.parseNextInt(st, -1));
|
||||
if (instance != null)
|
||||
{
|
||||
final Location loc = instance.getEnterLocation();
|
||||
if (loc != null)
|
||||
{
|
||||
if (!instance.isAllowed(activeChar))
|
||||
{
|
||||
instance.addAllowed(activeChar);
|
||||
}
|
||||
activeChar.teleToLocation(loc, false);
|
||||
activeChar.setInstance(instance);
|
||||
sendTemplateDetails(activeChar, instance.getTemplateId());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_instancedestroy":
|
||||
{
|
||||
final Instance instance = InstanceManager.getInstance().getInstance(CommonUtil.parseNextInt(st, -1));
|
||||
if (instance != null)
|
||||
{
|
||||
instance.getPlayers().forEach(player -> player.sendPacket(new ExShowScreenMessage("Your instance has been destroyed by Game Master!", 10000)));
|
||||
activeChar.sendMessage("You destroyed Instance " + instance.getId() + " with " + instance.getPlayersCount() + " players inside.");
|
||||
instance.destroy();
|
||||
sendTemplateDetails(activeChar, instance.getTemplateId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendTemplateDetails(L2PcInstance player, int templateId)
|
||||
{
|
||||
if (InstanceManager.getInstance().getInstanceTemplate(templateId) != null)
|
||||
{
|
||||
final InstanceTemplate template = InstanceManager.getInstance().getInstanceTemplate(templateId);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
html.setFile(player.getHtmlPrefix(), "data/html/admin/instances_detail.htm");
|
||||
html.replace("%templateId%", template.getId());
|
||||
html.replace("%templateName%", template.getName());
|
||||
html.replace("%activeWorlds%", template.getWorldCount() + " / " + (template.getMaxWorlds() == -1 ? "Unlimited" : template.getMaxWorlds()));
|
||||
html.replace("%duration%", template.getDuration() + " minutes");
|
||||
html.replace("%emptyDuration%", TimeUnit.MILLISECONDS.toMinutes(template.getEmptyDestroyTime()) + " minutes");
|
||||
html.replace("%ejectDuration%", template.getEjectTime() + " minutes");
|
||||
html.replace("%removeBuff%", template.isRemoveBuffEnabled());
|
||||
|
||||
sb.append("<table border=0 cellpadding=2 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"83\"><font color=\"LEVEL\">Instance ID</font></td>");
|
||||
sb.append("<td fixwidth=\"83\"><font color=\"LEVEL\">Teleport</font></td>");
|
||||
sb.append("<td fixwidth=\"83\"><font color=\"LEVEL\">Destroy</font></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("</table>");
|
||||
|
||||
InstanceManager.getInstance().getInstances().stream().filter(inst -> (inst.getTemplateId() == templateId)).sorted(Comparator.comparingInt(Instance::getPlayersCount)).forEach(instance ->
|
||||
{
|
||||
sb.append("<table border=0 cellpadding=2 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=\"83\">" + instance.getId() + "</td>");
|
||||
sb.append("<td fixwidth=\"83\"><button value=\"Teleport!\" action=\"bypass -h admin_instanceteleport " + instance.getId() + "\" width=75 height=18 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
|
||||
sb.append("<td fixwidth=\"83\"><button value=\"Destroy!\" action=\"bypass -h admin_instancedestroy " + instance.getId() + "\" width=75 height=18 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
|
||||
sb.append("</tr>");
|
||||
sb.append("</table>");
|
||||
});
|
||||
|
||||
html.replace("%instanceList%", sb.toString());
|
||||
player.sendPacket(html);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Instance template with id " + templateId + " does not exist!");
|
||||
useAdminCommand("admin_instance", player);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendTemplateList(L2PcInstance player, int page, BypassParser parser)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(player.getHtmlPrefix(), "data/html/admin/instances_list.htm");
|
||||
|
||||
final InstanceManager instManager = InstanceManager.getInstance();
|
||||
final List<InstanceTemplate> templateList = instManager.getInstanceTemplates().stream().sorted(Comparator.comparingLong(InstanceTemplate::getWorldCount).reversed()).filter(template -> !CommonUtil.contains(IGNORED_TEMPLATES, template.getId())).collect(Collectors.toList());
|
||||
|
||||
//@formatter:off
|
||||
final PageResult result = PageBuilder.newBuilder(templateList, 4, "bypass -h admin_instancelist")
|
||||
.currentPage(page)
|
||||
.pageHandler(NextPrevPageHandler.INSTANCE)
|
||||
.formatter(BypassParserFormatter.INSTANCE)
|
||||
.style(ButtonsStyle.INSTANCE)
|
||||
.bodyHandler((pages, template, sb) ->
|
||||
{
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr><td align=center fixwidth=\"250\"><font color=\"LEVEL\">" + template.getName() + " (" + template.getId() + ")</font></td></tr>");
|
||||
sb.append("</table>");
|
||||
|
||||
sb.append("<table border=0 cellpadding=0 cellspacing=0 bgcolor=\"363636\">");
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"83\">Active worlds:</td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"83\">" + template.getWorldCount() + " / " + (template.getMaxWorlds() == -1 ? "Unlimited" : template.getMaxWorlds()) + "</td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td align=center fixwidth=\"83\">Detailed info:</td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"></td>");
|
||||
sb.append("<td align=center fixwidth=\"83\"><button value=\"Show me!\" action=\"bypass -h admin_instancelist id=" + template.getId() + "\" width=\"85\" height=\"20\" back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
sb.append("</tr>");
|
||||
|
||||
|
||||
sb.append("</table>");
|
||||
sb.append("<br>");
|
||||
}).build();
|
||||
//@formatter:on
|
||||
|
||||
html.replace("%pages%", result.getPages() > 0 ? "<center><table width=\"100%\" cellspacing=0><tr>" + result.getPagerTemplate() + "</tr></table></center>" : "");
|
||||
html.replace("%data%", result.getBodyTemplate().toString());
|
||||
player.sendPacket(html);
|
||||
}
|
||||
|
||||
private void processBypass(L2PcInstance player, BypassParser parser)
|
||||
{
|
||||
final int page = parser.getInt("page", 0);
|
||||
final int templateId = parser.getInt("id", 0);
|
||||
|
||||
if (templateId > 0)
|
||||
{
|
||||
sendTemplateDetails(player, templateId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sendTemplateList(player, page, parser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,144 +1,143 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
public class AdminInstanceZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_instancezone",
|
||||
"admin_instancezone_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
|
||||
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
|
||||
|
||||
if (command.startsWith("admin_instancezone_clear"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
|
||||
final int instanceId = Integer.parseInt(st.nextToken());
|
||||
final String name = InstanceManager.getInstance().getInstanceIdName(instanceId);
|
||||
InstanceManager.getInstance().deleteInstanceTime(player.getObjectId(), instanceId);
|
||||
activeChar.sendMessage("Instance zone " + name + " cleared for player " + player.getName());
|
||||
player.sendMessage("Admin cleared instance zone " + name + " for you");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed clearing instance time: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //instancezone_clear <playername> [instanceId]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_instancezone"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
final String playername = st.nextToken();
|
||||
|
||||
try
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(playername);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
display(player, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The player " + playername + " is not online");
|
||||
activeChar.sendMessage("Usage: //instancezone [playername]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (activeChar.getTarget() != null)
|
||||
{
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
display((L2PcInstance) activeChar.getTarget(), activeChar);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
display(activeChar, activeChar);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void display(L2PcInstance player, L2PcInstance activeChar)
|
||||
{
|
||||
final Map<Integer, Long> instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(player.getObjectId());
|
||||
|
||||
final StringBuilder html = StringUtil.startAppend(500 + (instanceTimes.size() * 200), "<html><center><table width=260><tr><td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>Character Instances</center></td><td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><font color=\"LEVEL\">Instances for ", player.getName(), "</font><center><br><table><tr><td width=150>Name</td><td width=50>Time</td><td width=70>Action</td></tr>");
|
||||
|
||||
for (int id : instanceTimes.keySet())
|
||||
{
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
final long remainingTime = (instanceTimes.get(id) - System.currentTimeMillis()) / 1000;
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
hours = (int) (remainingTime / 3600);
|
||||
minutes = (int) ((remainingTime % 3600) / 60);
|
||||
}
|
||||
|
||||
StringUtil.append(html, "<tr><td>", InstanceManager.getInstance().getInstanceIdName(id), "</td><td>", String.valueOf(hours), ":", String.valueOf(minutes), "</td><td><button value=\"Clear\" action=\"bypass -h admin_instancezone_clear ", player.getName(), " ", String.valueOf(id), "\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
|
||||
StringUtil.append(html, "</table></html>");
|
||||
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage();
|
||||
ms.setHtml(html.toString());
|
||||
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.GMAudit;
|
||||
|
||||
public class AdminInstanceZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_instancezone",
|
||||
"admin_instancezone_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
|
||||
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
|
||||
|
||||
if (command.startsWith("admin_instancezone_clear"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
|
||||
final int instanceId = Integer.parseInt(st.nextToken());
|
||||
final String name = InstanceManager.getInstance().getInstanceName(instanceId);
|
||||
InstanceManager.getInstance().deleteInstanceTime(player, instanceId);
|
||||
activeChar.sendMessage("Instance zone " + name + " cleared for player " + player.getName());
|
||||
player.sendMessage("Admin cleared instance zone " + name + " for you");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed clearing instance time: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //instancezone_clear <playername> [instanceId]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_instancezone"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
final String playername = st.nextToken();
|
||||
|
||||
try
|
||||
{
|
||||
player = L2World.getInstance().getPlayer(playername);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
display(player, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The player " + playername + " is not online");
|
||||
activeChar.sendMessage("Usage: //instancezone [playername]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (activeChar.getTarget() != null)
|
||||
{
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
display((L2PcInstance) activeChar.getTarget(), activeChar);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
display(activeChar, activeChar);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void display(L2PcInstance player, L2PcInstance activeChar)
|
||||
{
|
||||
final Map<Integer, Long> instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(player);
|
||||
|
||||
final StringBuilder html = new StringBuilder(500 + (instanceTimes.size() * 200));
|
||||
html.append("<html><center><table width=260><tr><td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>Character Instances</center></td><td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><font color=\"LEVEL\">Instances for " + player.getName() + "</font><center><br><table><tr><td width=150>Name</td><td width=50>Time</td><td width=70>Action</td></tr>");
|
||||
|
||||
for (int id : instanceTimes.keySet())
|
||||
{
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
final long remainingTime = (instanceTimes.get(id) - System.currentTimeMillis()) / 1000;
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
hours = (int) (remainingTime / 3600);
|
||||
minutes = (int) ((remainingTime % 3600) / 60);
|
||||
}
|
||||
|
||||
html.append("<tr><td>" + InstanceManager.getInstance().getInstanceName(id) + "</td><td>" + hours + ":" + minutes + "</td><td><button value=\"Clear\" action=\"bypass -h admin_instancezone_clear " + player.getName() + " " + id + "\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
|
||||
html.append("</table></html>");
|
||||
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage(0, 1);
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +1,129 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2007/07/31 10:06:02 $
|
||||
*/
|
||||
public class AdminInvul implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_invul",
|
||||
"admin_setinvul"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_invul"))
|
||||
{
|
||||
handleInvul(activeChar);
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
if (command.equals("admin_setinvul"))
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
handleInvul((L2PcInstance) target);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleInvul(L2PcInstance activeChar)
|
||||
{
|
||||
String text;
|
||||
if (activeChar.isInvul())
|
||||
{
|
||||
activeChar.setIsInvul(false);
|
||||
text = activeChar.getName() + " is now mortal";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
text = activeChar.getName() + " is now invulnerable";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2007/07/31 10:06:02 $
|
||||
*/
|
||||
public class AdminInvul implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_invul",
|
||||
"admin_setinvul",
|
||||
"admin_undying",
|
||||
"admin_setundying"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.equals("admin_invul"))
|
||||
{
|
||||
handleInvul(activeChar);
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.equals("admin_undying"))
|
||||
{
|
||||
handleUndying(activeChar);
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
|
||||
else if (command.equals("admin_setinvul"))
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
handleInvul((L2PcInstance) target);
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_setundying"))
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2Character)
|
||||
{
|
||||
handleUndying((L2Character) target);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleInvul(L2PcInstance activeChar)
|
||||
{
|
||||
String text;
|
||||
if (activeChar.isInvul())
|
||||
{
|
||||
activeChar.setIsInvul(false);
|
||||
text = activeChar.getName() + " is now mortal";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
text = activeChar.getName() + " is now invulnerable";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
|
||||
private void handleUndying(L2Character activeChar)
|
||||
{
|
||||
String text;
|
||||
if (activeChar.isUndying())
|
||||
{
|
||||
activeChar.setUndying(false);
|
||||
text = activeChar.getName() + " is now mortal";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: Gm removed undying mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setUndying(true);
|
||||
text = activeChar.getName() + " is now undying";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: Gm activated undying mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class AdminKick implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_kick",
|
||||
"admin_kick_non_gm"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_kick"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String player = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
if (plyr != null)
|
||||
{
|
||||
plyr.logout();
|
||||
activeChar.sendMessage("You kicked " + plyr.getName() + " from the game.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_kick_non_gm"))
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if (!player.isGM())
|
||||
{
|
||||
counter++;
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("Kicked " + counter + " players");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class AdminKick implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_kick",
|
||||
"admin_kick_non_gm"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_kick"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String player = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
if (plyr != null)
|
||||
{
|
||||
plyr.logout();
|
||||
activeChar.sendMessage("You kicked " + plyr.getName() + " from the game.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_kick_non_gm"))
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance player : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if (!player.isGM())
|
||||
{
|
||||
counter++;
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("Kicked " + counter + " players");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,167 +1,168 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - kill = kills target L2Character - kill_monster = kills target non-player - kill <radius> = If radius is specified, then ALL players only in that radius will be killed. - kill_monster <radius> = If radius is specified, then ALL non-players only in
|
||||
* that radius will be killed.
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2007/07/31 10:06:06 $
|
||||
*/
|
||||
public class AdminKill implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminKill.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_kill",
|
||||
"admin_kill_monster"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_kill"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken(); // skip command
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String firstParam = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);
|
||||
if (plyr != null)
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(st.nextToken());
|
||||
for (L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
kill(activeChar, knownChar);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Invalid radius.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
kill(activeChar, plyr);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(firstParam);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kill(activeChar, knownChar);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //kill <player_name | radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2ControllableMobInstance) || !(obj instanceof L2Character))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
kill(activeChar, (L2Character) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void kill(L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
if (!((L2PcInstance) target).isGM())
|
||||
{
|
||||
target.stopAllEffects(); // e.g. invincibility effect
|
||||
}
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean targetIsInvul = false;
|
||||
if (target.isInvul())
|
||||
{
|
||||
targetIsInvul = true;
|
||||
target.setIsInvul(false);
|
||||
}
|
||||
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
|
||||
if (targetIsInvul)
|
||||
{
|
||||
target.setIsInvul(true);
|
||||
}
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") killed character " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.FriendlyNpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - kill = kills target L2Character - kill_monster = kills target non-player - kill <radius> = If radius is specified, then ALL players only in that radius will be killed. - kill_monster <radius> = If radius is specified, then ALL non-players only in
|
||||
* that radius will be killed.
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2007/07/31 10:06:06 $
|
||||
*/
|
||||
public class AdminKill implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminKill.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_kill",
|
||||
"admin_kill_monster"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_kill"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken(); // skip command
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String firstParam = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);
|
||||
if (plyr != null)
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(st.nextToken());
|
||||
L2World.getInstance().forEachVisibleObjectInRange(plyr, L2Character.class, radius, knownChar ->
|
||||
{
|
||||
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar instanceof FriendlyNpcInstance) || (knownChar == activeChar))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
kill(activeChar, knownChar);
|
||||
});
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Invalid radius.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
kill(activeChar, plyr);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(firstParam);
|
||||
|
||||
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, wo ->
|
||||
{
|
||||
if ((wo instanceof L2ControllableMobInstance) || (wo instanceof FriendlyNpcInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
kill(activeChar, wo);
|
||||
});
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //kill <player_name | radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2ControllableMobInstance) || !(obj instanceof L2Character))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
kill(activeChar, (L2Character) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void kill(L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
if (!target.isGM())
|
||||
{
|
||||
target.stopAllEffects(); // e.g. invincibility effect
|
||||
}
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean targetIsInvul = false;
|
||||
if (target.isInvul())
|
||||
{
|
||||
targetIsInvul = true;
|
||||
target.setIsInvul(false);
|
||||
}
|
||||
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
|
||||
if (targetIsInvul)
|
||||
{
|
||||
target.setIsInvul(true);
|
||||
}
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") killed character " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,99 +1,109 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class AdminLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_level",
|
||||
"admin_set_level"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object targetChar = activeChar.getTarget();
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
final String val = st.countTokens() >= 1 ? st.nextToken() : "";
|
||||
if (actualCommand.equalsIgnoreCase("admin_add_level"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (targetChar instanceof L2Playable)
|
||||
{
|
||||
((L2Playable) targetChar).getStat().addLevel(Byte.parseByte(val));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Wrong Number Format");
|
||||
}
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_set_level"))
|
||||
{
|
||||
final int maxLevel = ExperienceData.getInstance().getMaxLevel();
|
||||
try
|
||||
{
|
||||
if (!(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
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);
|
||||
targetPlayer.setCurrentHpMp(targetPlayer.getMaxHp(), targetPlayer.getMaxMp());
|
||||
targetPlayer.setCurrentCp(targetPlayer.getMaxCp());
|
||||
targetPlayer.broadcastUserInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + maxLevel + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + maxLevel + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Playable;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
public class AdminLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_level",
|
||||
"admin_set_level"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final L2Object targetChar = activeChar.getTarget();
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
String val = "";
|
||||
if (st.countTokens() >= 1)
|
||||
{
|
||||
val = st.nextToken();
|
||||
}
|
||||
|
||||
if (actualCommand.equalsIgnoreCase("admin_add_level"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (targetChar instanceof L2Playable)
|
||||
{
|
||||
((L2Playable) targetChar).getStat().addLevel(Byte.parseByte(val));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Wrong Number Format");
|
||||
}
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_set_level"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
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()))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + ExperienceData.getInstance().getMaxLevel() + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + ExperienceData.getInstance().getMaxLevel() + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,256 +1,244 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.gameserverpackets.ServerStatus;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles the admin commands that acts on the login
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2007/07/31 10:05:56 $
|
||||
*/
|
||||
public class AdminLogin implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_server_gm_only",
|
||||
"admin_server_all",
|
||||
"admin_server_max_player",
|
||||
"admin_server_list_type",
|
||||
"admin_server_list_age",
|
||||
"admin_server_login"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_server_gm_only"))
|
||||
{
|
||||
gmOnly();
|
||||
activeChar.sendMessage("Server is now GM only");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_server_all"))
|
||||
{
|
||||
allowToAll();
|
||||
activeChar.sendMessage("Server is not GM only anymore");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_server_max_player"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String number = st.nextToken();
|
||||
try
|
||||
{
|
||||
LoginServerThread.getInstance().setMaxPlayer(Integer.parseInt(number));
|
||||
activeChar.sendMessage("maxPlayer set to " + number);
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Max players must be a number.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_max_player <max>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_list_type"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final int tokens = st.countTokens();
|
||||
if (tokens > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String[] modes = new String[tokens - 1];
|
||||
|
||||
for (int i = 0; i < (tokens - 1); i++)
|
||||
{
|
||||
modes[i] = st.nextToken().trim();
|
||||
}
|
||||
int newType = 0;
|
||||
try
|
||||
{
|
||||
newType = Integer.parseInt(modes[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
newType = Config.getServerTypeId(modes);
|
||||
}
|
||||
if (Config.SERVER_LIST_TYPE != newType)
|
||||
{
|
||||
Config.SERVER_LIST_TYPE = newType;
|
||||
LoginServerThread.getInstance().sendServerType();
|
||||
activeChar.sendMessage("Server Type changed to " + getServerTypeName(newType));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Server Type is already " + getServerTypeName(newType));
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_list_type <normal/relax/test/nolabel/restricted/event/free>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_list_age"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String mode = st.nextToken();
|
||||
int age = 0;
|
||||
try
|
||||
{
|
||||
age = Integer.parseInt(mode);
|
||||
if (Config.SERVER_LIST_AGE != age)
|
||||
{
|
||||
Config.SERVER_LIST_TYPE = age;
|
||||
LoginServerThread.getInstance().sendServerStatus(ServerStatus.SERVER_AGE, age);
|
||||
activeChar.sendMessage("Server Age changed to " + age);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Server Age is already " + age);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Age must be a number");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_list_age <number>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_server_login"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/login.htm");
|
||||
html.replace("%server_name%", LoginServerThread.getInstance().getServerName());
|
||||
html.replace("%status%", LoginServerThread.getInstance().getStatusString());
|
||||
html.replace("%clock%", getServerTypeName(Config.SERVER_LIST_TYPE));
|
||||
html.replace("%brackets%", String.valueOf(Config.SERVER_LIST_BRACKET));
|
||||
html.replace("%max_players%", String.valueOf(LoginServerThread.getInstance().getMaxPlayer()));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private String getServerTypeName(int serverType)
|
||||
{
|
||||
String nameType = "";
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
final int currentType = serverType & (int) Math.pow(2, i);
|
||||
|
||||
if (currentType > 0)
|
||||
{
|
||||
if (!nameType.isEmpty())
|
||||
{
|
||||
nameType += "+";
|
||||
}
|
||||
|
||||
switch (currentType)
|
||||
{
|
||||
case 0x01:
|
||||
{
|
||||
nameType += "Normal";
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
nameType += "Relax";
|
||||
break;
|
||||
}
|
||||
case 0x04:
|
||||
{
|
||||
nameType += "Test";
|
||||
break;
|
||||
}
|
||||
case 0x08:
|
||||
{
|
||||
nameType += "NoLabel";
|
||||
break;
|
||||
}
|
||||
case 0x10:
|
||||
{
|
||||
nameType += "Restricted";
|
||||
break;
|
||||
}
|
||||
case 0x20:
|
||||
{
|
||||
nameType += "Event";
|
||||
break;
|
||||
}
|
||||
case 0x40:
|
||||
{
|
||||
nameType += "Free";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nameType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void allowToAll()
|
||||
{
|
||||
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_AUTO);
|
||||
Config.SERVER_GMONLY = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void gmOnly()
|
||||
{
|
||||
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_GM_ONLY);
|
||||
Config.SERVER_GMONLY = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.LoginServerThread;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.gameserverpackets.ServerStatus;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles the admin commands that acts on the login
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2007/07/31 10:05:56 $
|
||||
*/
|
||||
public class AdminLogin implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_server_gm_only",
|
||||
"admin_server_all",
|
||||
"admin_server_max_player",
|
||||
"admin_server_list_type",
|
||||
"admin_server_list_age",
|
||||
"admin_server_login"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_server_gm_only"))
|
||||
{
|
||||
gmOnly();
|
||||
activeChar.sendMessage("Server is now GM only");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_server_all"))
|
||||
{
|
||||
allowToAll();
|
||||
activeChar.sendMessage("Server is not GM only anymore");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_server_max_player"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String number = st.nextToken();
|
||||
try
|
||||
{
|
||||
LoginServerThread.getInstance().setMaxPlayer(Integer.parseInt(number));
|
||||
activeChar.sendMessage("maxPlayer set to " + number);
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Max players must be a number.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_max_player <max>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_list_type"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final int tokens = st.countTokens();
|
||||
if (tokens > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String[] modes = new String[tokens - 1];
|
||||
|
||||
for (int i = 0; i < (tokens - 1); i++)
|
||||
{
|
||||
modes[i] = st.nextToken().trim();
|
||||
}
|
||||
int newType = 0;
|
||||
try
|
||||
{
|
||||
newType = Integer.parseInt(modes[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
newType = Config.getServerTypeId(modes);
|
||||
}
|
||||
if (Config.SERVER_LIST_TYPE != newType)
|
||||
{
|
||||
Config.SERVER_LIST_TYPE = newType;
|
||||
LoginServerThread.getInstance().sendServerType();
|
||||
activeChar.sendMessage("Server Type changed to " + getServerTypeName(newType));
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Server Type is already " + getServerTypeName(newType));
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_list_type <normal/relax/test/nolabel/restricted/event/free>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_list_age"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String mode = st.nextToken();
|
||||
int age = 0;
|
||||
try
|
||||
{
|
||||
age = Integer.parseInt(mode);
|
||||
if (Config.SERVER_LIST_AGE != age)
|
||||
{
|
||||
Config.SERVER_LIST_TYPE = age;
|
||||
LoginServerThread.getInstance().sendServerStatus(ServerStatus.SERVER_AGE, age);
|
||||
activeChar.sendMessage("Server Age changed to " + age);
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Server Age is already " + age);
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Age must be a number");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Format is server_list_age <number>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_server_login"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/login.htm");
|
||||
html.replace("%server_name%", LoginServerThread.getInstance().getServerName());
|
||||
html.replace("%status%", LoginServerThread.getInstance().getStatusString());
|
||||
html.replace("%clock%", getServerTypeName(Config.SERVER_LIST_TYPE));
|
||||
html.replace("%brackets%", String.valueOf(Config.SERVER_LIST_BRACKET));
|
||||
html.replace("%max_players%", String.valueOf(LoginServerThread.getInstance().getMaxPlayer()));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private String getServerTypeName(int serverType)
|
||||
{
|
||||
String nameType = "";
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
final int currentType = serverType & (int) Math.pow(2, i);
|
||||
|
||||
if (currentType > 0)
|
||||
{
|
||||
if (!nameType.isEmpty())
|
||||
{
|
||||
nameType += "+";
|
||||
}
|
||||
|
||||
switch (currentType)
|
||||
{
|
||||
case 0x01:
|
||||
nameType += "Normal";
|
||||
break;
|
||||
case 0x02:
|
||||
nameType += "Relax";
|
||||
break;
|
||||
case 0x04:
|
||||
nameType += "Test";
|
||||
break;
|
||||
case 0x08:
|
||||
nameType += "NoLabel";
|
||||
break;
|
||||
case 0x10:
|
||||
nameType += "Restricted";
|
||||
break;
|
||||
case 0x20:
|
||||
nameType += "Event";
|
||||
break;
|
||||
case 0x40:
|
||||
nameType += "Free";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nameType;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void allowToAll()
|
||||
{
|
||||
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_AUTO);
|
||||
Config.SERVER_GMONLY = false;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void gmOnly()
|
||||
{
|
||||
LoginServerThread.getInstance().setServerStatus(ServerStatus.STATUS_GM_ONLY);
|
||||
Config.SERVER_GMONLY = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,65 +1,64 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class AdminManor implements IAdminCommandHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final CastleManorManager manor = CastleManorManager.getInstance();
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/manor.htm");
|
||||
msg.replace("%status%", manor.getCurrentModeName());
|
||||
msg.replace("%change%", manor.getNextModeChange());
|
||||
|
||||
final StringBuilder sb = new StringBuilder(3400);
|
||||
for (Castle c : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td>Name:</td><td><font color=008000>" + c.getName() + "</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td>Current period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)), " Adena</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td>Next period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)), " Adena</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td><font color=808080>--------------------------</font></td><td><font color=808080>--------------------------</font></td></tr>");
|
||||
}
|
||||
msg.replace("%castleInfo%", sb.toString());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
sb.setLength(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return new String[]
|
||||
{
|
||||
"admin_manor"
|
||||
};
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.Castle;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class AdminManor implements IAdminCommandHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final CastleManorManager manor = CastleManorManager.getInstance();
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/manor.htm");
|
||||
msg.replace("%status%", manor.getCurrentModeName());
|
||||
msg.replace("%change%", manor.getNextModeChange());
|
||||
|
||||
final StringBuilder sb = new StringBuilder(3400);
|
||||
for (Castle c : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
sb.append("<tr><td>Name:</td><td><font color=008000>" + c.getName() + "</font></td></tr>");
|
||||
sb.append("<tr><td>Current period cost:</td><td><font color=FF9900>" + Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)) + " Adena</font></td></tr>");
|
||||
sb.append("<tr><td>Next period cost:</td><td><font color=FF9900>" + Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)) + " Adena</font></td></tr>");
|
||||
sb.append("<tr><td><font color=808080>--------------------------</font></td><td><font color=808080>--------------------------</font></td></tr>");
|
||||
}
|
||||
msg.replace("%castleInfo%", sb.toString());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
sb.setLength(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return new String[]
|
||||
{
|
||||
"admin_manor"
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,308 +1,306 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - handles every admin menu command
|
||||
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminMenu implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminMenu.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_char_manage",
|
||||
"admin_teleport_character_to_menu",
|
||||
"admin_recall_char_menu",
|
||||
"admin_recall_party_menu",
|
||||
"admin_recall_clan_menu",
|
||||
"admin_goto_char_menu",
|
||||
"admin_kick_menu",
|
||||
"admin_kill_menu",
|
||||
"admin_ban_menu",
|
||||
"admin_unban_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_char_manage"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_teleport_character_to_menu"))
|
||||
{
|
||||
final String[] data = command.split(" ");
|
||||
if (data.length == 5)
|
||||
{
|
||||
final String playerName = data[1];
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(playerName);
|
||||
if (player != null)
|
||||
{
|
||||
teleportCharacter(player, new Location(Integer.parseInt(data[2]), Integer.parseInt(data[3]), Integer.parseInt(data[4])), activeChar, "Admin is teleporting you.");
|
||||
}
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_recall_char_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
teleportCharacter(L2World.getInstance().getPlayer(command.substring(23)), activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall_party_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(24);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return true;
|
||||
}
|
||||
if (!player.isInParty())
|
||||
{
|
||||
activeChar.sendMessage("Player is not in party.");
|
||||
teleportCharacter(player, activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
for (L2PcInstance pm : player.getParty().getMembers())
|
||||
{
|
||||
teleportCharacter(pm, activeChar.getLocation(), activeChar, "Your party is being teleported by an Admin.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall_clan_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(23);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return true;
|
||||
}
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Player is not in a clan.");
|
||||
teleportCharacter(player, activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (L2PcInstance member : clan.getOnlineMembers(0))
|
||||
{
|
||||
teleportCharacter(member, activeChar.getLocation(), activeChar, "Your clan is being teleported by an Admin.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_goto_char_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(21);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
activeChar.setInstanceId(player.getInstanceId());
|
||||
teleportToCharacter(activeChar, player);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_kill_menu"))
|
||||
{
|
||||
handleKill(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_kick_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String player = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
String text;
|
||||
if (plyr != null)
|
||||
{
|
||||
plyr.logout();
|
||||
text = "You kicked " + plyr.getName() + " from the game.";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "Player " + player + " was not found in the game.";
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_ban_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
final String subCommand = "admin_ban_char";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
AdminCommandHandler.getInstance().getHandler(subCommand).useAdminCommand(subCommand + command.substring(14), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_unban_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
final String subCommand = "admin_unban_char";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
AdminCommandHandler.getInstance().getHandler(subCommand).useAdminCommand(subCommand + command.substring(16), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleKill(L2PcInstance activeChar)
|
||||
{
|
||||
handleKill(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleKill(L2PcInstance activeChar, String player)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
L2Character target = (L2Character) obj;
|
||||
String filename = "main_menu.htm";
|
||||
if (player != null)
|
||||
{
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
if (plyr != null)
|
||||
{
|
||||
target = plyr;
|
||||
activeChar.sendMessage("You killed " + plyr.getName());
|
||||
}
|
||||
}
|
||||
if (target != null)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
filename = "charmanage.htm";
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, filename);
|
||||
}
|
||||
|
||||
private void teleportCharacter(L2PcInstance player, Location loc, L2PcInstance activeChar, String message)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(message);
|
||||
player.teleToLocation(loc, true);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_ON_YOURSELF);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setInstanceId(player.getInstanceId());
|
||||
activeChar.teleToLocation(player.getLocation(), true);
|
||||
activeChar.sendMessage("You're teleporting yourself to character " + player.getName());
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "charmanage.htm");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - handles every admin menu command
|
||||
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminMenu implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminMenu.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_char_manage",
|
||||
"admin_teleport_character_to_menu",
|
||||
"admin_recall_char_menu",
|
||||
"admin_recall_party_menu",
|
||||
"admin_recall_clan_menu",
|
||||
"admin_goto_char_menu",
|
||||
"admin_kick_menu",
|
||||
"admin_kill_menu",
|
||||
"admin_ban_menu",
|
||||
"admin_unban_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_char_manage"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_teleport_character_to_menu"))
|
||||
{
|
||||
final String[] data = command.split(" ");
|
||||
if (data.length == 5)
|
||||
{
|
||||
final String playerName = data[1];
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(playerName);
|
||||
if (player != null)
|
||||
{
|
||||
teleportCharacter(player, new Location(Integer.parseInt(data[2]), Integer.parseInt(data[3]), Integer.parseInt(data[4])), activeChar, "Admin is teleporting you.");
|
||||
}
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_recall_char_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(23);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
teleportCharacter(player, activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall_party_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(24);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return true;
|
||||
}
|
||||
if (!player.isInParty())
|
||||
{
|
||||
activeChar.sendMessage("Player is not in party.");
|
||||
teleportCharacter(player, activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
for (L2PcInstance pm : player.getParty().getMembers())
|
||||
{
|
||||
teleportCharacter(pm, activeChar.getLocation(), activeChar, "Your party is being teleported by an Admin.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall_clan_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(23);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return true;
|
||||
}
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Player is not in a clan.");
|
||||
teleportCharacter(player, activeChar.getLocation(), activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (L2PcInstance member : clan.getOnlineMembers(0))
|
||||
{
|
||||
teleportCharacter(member, activeChar.getLocation(), activeChar, "Your clan is being teleported by an Admin.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_goto_char_menu"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(command.substring(21));
|
||||
teleportToCharacter(activeChar, player);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_kill_menu"))
|
||||
{
|
||||
handleKill(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_kick_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
final String player = st.nextToken();
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
String text;
|
||||
if (plyr != null)
|
||||
{
|
||||
plyr.logout();
|
||||
text = "You kicked " + plyr.getName() + " from the game.";
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "Player " + player + " was not found in the game.";
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_ban_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
final String subCommand = "admin_ban_char";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_unban_menu"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
final String subCommand = "admin_unban_char";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand + command.substring(16), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleKill(L2PcInstance activeChar)
|
||||
{
|
||||
handleKill(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleKill(L2PcInstance activeChar, String player)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
L2Character target = (L2Character) obj;
|
||||
String filename = "main_menu.htm";
|
||||
if (player != null)
|
||||
{
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
if (plyr != null)
|
||||
{
|
||||
target = plyr;
|
||||
activeChar.sendMessage("You killed " + plyr.getName());
|
||||
}
|
||||
}
|
||||
if (target != null)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
filename = "charmanage.htm";
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, filename);
|
||||
}
|
||||
|
||||
private void teleportCharacter(L2PcInstance player, Location loc, L2PcInstance activeChar, String message)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(message);
|
||||
player.teleToLocation(loc, true);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
if (!target.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
final L2PcInstance player = target.getActingPlayer();
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_ON_YOURSELF);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.teleToLocation(player.getLocation(), true, player.getInstanceWorld());
|
||||
activeChar.sendMessage("You're teleporting yourself to character " + player.getName());
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "charmanage.htm");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,116 +1,116 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Allows Game Masters to test System Messages.<br>
|
||||
* admin_msg display the raw message.<br>
|
||||
* admin_msgx is an extended version that allows to set parameters.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class AdminMessages implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_msg",
|
||||
"admin_msgx"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_msg "))
|
||||
{
|
||||
try
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(Integer.parseInt(command.substring(10).trim())));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_msgx "))
|
||||
{
|
||||
final String[] tokens = command.split(" ");
|
||||
if ((tokens.length <= 2) || !Util.isDigit(tokens[1]))
|
||||
{
|
||||
activeChar.sendMessage("Command format: //msgx <SYSTEM_MSG_ID> [item:Id] [skill:Id] [npc:Id] [zone:x,y,x] [castle:Id] [str:'text']");
|
||||
return false;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(Integer.parseInt(tokens[1]));
|
||||
String val;
|
||||
int lastPos = 0;
|
||||
for (int i = 2; i < tokens.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
val = tokens[i];
|
||||
if (val.startsWith("item:"))
|
||||
{
|
||||
sm.addItemName(Integer.parseInt(val.substring(5)));
|
||||
}
|
||||
else if (val.startsWith("skill:"))
|
||||
{
|
||||
sm.addSkillName(Integer.parseInt(val.substring(6)));
|
||||
}
|
||||
else if (val.startsWith("npc:"))
|
||||
{
|
||||
sm.addNpcName(Integer.parseInt(val.substring(4)));
|
||||
}
|
||||
else if (val.startsWith("zone:"))
|
||||
{
|
||||
final int x = Integer.parseInt(val.substring(5, val.indexOf(",")));
|
||||
final int y = Integer.parseInt(val.substring(val.indexOf(",") + 1, val.lastIndexOf(",")));
|
||||
final int z = Integer.parseInt(val.substring(val.lastIndexOf(",") + 1, val.length()));
|
||||
sm.addZoneName(x, y, z);
|
||||
}
|
||||
else if (val.startsWith("castle:"))
|
||||
{
|
||||
sm.addCastleId(Integer.parseInt(val.substring(7)));
|
||||
}
|
||||
else if (val.startsWith("str:"))
|
||||
{
|
||||
final int pos = command.indexOf("'", lastPos + 1);
|
||||
lastPos = command.indexOf("'", pos + 1);
|
||||
sm.addString(command.substring(pos + 1, lastPos));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Exception: " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Allows Game Masters to test System Messages.<br>
|
||||
* admin_msg display the raw message.<br>
|
||||
* admin_msgx is an extended version that allows to set parameters.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class AdminMessages implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_msg",
|
||||
"admin_msgx"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_msg "))
|
||||
{
|
||||
try
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(Integer.parseInt(command.substring(10).trim())));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_msgx "))
|
||||
{
|
||||
final String[] tokens = command.split(" ");
|
||||
if ((tokens.length <= 2) || !Util.isDigit(tokens[1]))
|
||||
{
|
||||
activeChar.sendMessage("Command format: //msgx <SYSTEM_MSG_ID> [item:Id] [skill:Id] [npc:Id] [zone:x,y,x] [castle:Id] [str:'text']");
|
||||
return false;
|
||||
}
|
||||
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(Integer.parseInt(tokens[1]));
|
||||
String val;
|
||||
int lastPos = 0;
|
||||
for (int i = 2; i < tokens.length; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
val = tokens[i];
|
||||
if (val.startsWith("item:"))
|
||||
{
|
||||
sm.addItemName(Integer.parseInt(val.substring(5)));
|
||||
}
|
||||
else if (val.startsWith("skill:"))
|
||||
{
|
||||
sm.addSkillName(Integer.parseInt(val.substring(6)));
|
||||
}
|
||||
else if (val.startsWith("npc:"))
|
||||
{
|
||||
sm.addNpcName(Integer.parseInt(val.substring(4)));
|
||||
}
|
||||
else if (val.startsWith("zone:"))
|
||||
{
|
||||
final int x = Integer.parseInt(val.substring(5, val.indexOf(",")));
|
||||
final int y = Integer.parseInt(val.substring(val.indexOf(",") + 1, val.lastIndexOf(",")));
|
||||
final int z = Integer.parseInt(val.substring(val.lastIndexOf(",") + 1, val.length()));
|
||||
sm.addZoneName(x, y, z);
|
||||
}
|
||||
else if (val.startsWith("castle:"))
|
||||
{
|
||||
sm.addCastleId(Integer.parseInt(val.substring(7)));
|
||||
}
|
||||
else if (val.startsWith("str:"))
|
||||
{
|
||||
final int pos = command.indexOf("'", lastPos + 1);
|
||||
lastPos = command.indexOf("'", pos + 1);
|
||||
sm.addString(command.substring(pos + 1, lastPos));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Exception: " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,165 +1,166 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.MonsterRace;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MonRaceInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.1.6.4 $ $Date: 2007/07/31 10:06:00 $
|
||||
*/
|
||||
public class AdminMonsterRace implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminMonsterRace.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_mons"
|
||||
};
|
||||
static int state = -1;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equalsIgnoreCase("admin_mons"))
|
||||
{
|
||||
handleSendPacket(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleSendPacket(L2PcInstance activeChar)
|
||||
{
|
||||
/*
|
||||
* -1 0 to initialize the race 0 15322 to start race 13765 -1 in middle of race -1 0 to end the race 8003 to 8027
|
||||
*/
|
||||
|
||||
final int[][] codes =
|
||||
{
|
||||
{
|
||||
-1,
|
||||
0
|
||||
},
|
||||
{
|
||||
0,
|
||||
15322
|
||||
},
|
||||
{
|
||||
13765,
|
||||
-1
|
||||
},
|
||||
{
|
||||
-1,
|
||||
0
|
||||
}
|
||||
};
|
||||
final MonsterRace race = MonsterRace.getInstance();
|
||||
|
||||
if (state == -1)
|
||||
{
|
||||
state++;
|
||||
race.newRace();
|
||||
race.newSpeeds();
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
}
|
||||
else if (state == 0)
|
||||
{
|
||||
state++;
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THEY_RE_OFF);
|
||||
sm.addInt(0);
|
||||
activeChar.sendPacket(sm);
|
||||
final PlaySound SRace = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
|
||||
activeChar.sendPacket(SRace);
|
||||
activeChar.broadcastPacket(SRace);
|
||||
final PlaySound SRace2 = new PlaySound(0, "ItemSound2.race_start", 1, 121209259, 12125, 182487, -3559);
|
||||
activeChar.sendPacket(SRace2);
|
||||
activeChar.broadcastPacket(SRace2);
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
private class RunRace implements Runnable
|
||||
{
|
||||
private final int[][] codes;
|
||||
private final L2PcInstance activeChar;
|
||||
|
||||
RunRace(int[][] pCodes, L2PcInstance pActiveChar)
|
||||
{
|
||||
codes = pCodes;
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// int[][] speeds1 = MonsterRace.getInstance().getSpeeds();
|
||||
// MonsterRace.getInstance().newSpeeds();
|
||||
// int[][] speeds2 = MonsterRace.getInstance().getSpeeds();
|
||||
/*
|
||||
* int[] speed = new int[8]; for (int i=0; i<8; i++) { for (int j=0; j<20; j++) { //_log.info("Adding "+speeds1[i][j] +" and "+ speeds2[i][j]); speed[i] += (speeds1[i][j]*1); // + (speeds2[i][j]*1); } _log.info("Total speed for "+(i+1)+" = "+speed[i]); }
|
||||
*/
|
||||
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RunEnd implements Runnable
|
||||
{
|
||||
private final L2PcInstance activeChar;
|
||||
|
||||
public RunEnd(L2PcInstance pActiveChar)
|
||||
{
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
DeleteObject obj = null;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
obj = new DeleteObject(MonsterRace.getInstance().getMonsters()[i]);
|
||||
activeChar.sendPacket(obj);
|
||||
activeChar.broadcastPacket(obj);
|
||||
}
|
||||
state = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.MonsterRace;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MonRaceInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.1.6.4 $ $Date: 2007/07/31 10:06:00 $
|
||||
*/
|
||||
public class AdminMonsterRace implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_mons"
|
||||
};
|
||||
|
||||
protected static int state = -1;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equalsIgnoreCase("admin_mons"))
|
||||
{
|
||||
handleSendPacket(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleSendPacket(L2PcInstance activeChar)
|
||||
{
|
||||
/*
|
||||
* -1 0 to initialize the race 0 15322 to start race 13765 -1 in middle of race -1 0 to end the race 8003 to 8027
|
||||
*/
|
||||
|
||||
final int[][] codes =
|
||||
{
|
||||
{
|
||||
-1,
|
||||
0
|
||||
},
|
||||
{
|
||||
0,
|
||||
15322
|
||||
},
|
||||
{
|
||||
13765,
|
||||
-1
|
||||
},
|
||||
{
|
||||
-1,
|
||||
0
|
||||
}
|
||||
};
|
||||
final MonsterRace race = MonsterRace.getInstance();
|
||||
|
||||
if (state == -1)
|
||||
{
|
||||
state++;
|
||||
race.newRace();
|
||||
race.newSpeeds();
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
}
|
||||
else if (state == 0)
|
||||
{
|
||||
state++;
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THEY_RE_OFF);
|
||||
sm.addInt(0);
|
||||
activeChar.sendPacket(sm);
|
||||
final PlaySound SRace = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
|
||||
activeChar.sendPacket(SRace);
|
||||
activeChar.broadcastPacket(SRace);
|
||||
final PlaySound SRace2 = new PlaySound(0, "ItemSound2.race_start", 1, 121209259, 12125, 182487, -3559);
|
||||
activeChar.sendPacket(SRace2);
|
||||
activeChar.broadcastPacket(SRace2);
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[state][0], codes[state][1], race.getMonsters(), race.getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new RunRace(codes, activeChar), 5000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class RunRace implements Runnable
|
||||
{
|
||||
|
||||
private final int[][] codes;
|
||||
private final L2PcInstance activeChar;
|
||||
|
||||
public RunRace(int[][] pCodes, L2PcInstance pActiveChar)
|
||||
{
|
||||
codes = pCodes;
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// int[][] speeds1 = MonsterRace.getInstance().getSpeeds();
|
||||
// MonsterRace.getInstance().newSpeeds();
|
||||
// int[][] speeds2 = MonsterRace.getInstance().getSpeeds();
|
||||
/*
|
||||
* int[] speed = new int[8]; for (int i=0; i<8; i++) { for (int j=0; j<20; j++) { //LOGGER.info("Adding "+speeds1[i][j] +" and "+ speeds2[i][j]); speed[i] += (speeds1[i][j]*1); // + (speeds2[i][j]*1); } LOGGER.info("Total speed for "+(i+1)+" = "+speed[i]); }
|
||||
*/
|
||||
|
||||
final MonRaceInfo spk = new MonRaceInfo(codes[2][0], codes[2][1], MonsterRace.getInstance().getMonsters(), MonsterRace.getInstance().getSpeeds());
|
||||
activeChar.sendPacket(spk);
|
||||
activeChar.broadcastPacket(spk);
|
||||
ThreadPoolManager.getInstance().scheduleGeneral(new RunEnd(activeChar), 30000);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RunEnd implements Runnable
|
||||
{
|
||||
private final L2PcInstance activeChar;
|
||||
|
||||
public RunEnd(L2PcInstance pActiveChar)
|
||||
{
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
DeleteObject obj = null;
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
obj = new DeleteObject(MonsterRace.getInstance().getMonsters()[i]);
|
||||
activeChar.sendPacket(obj);
|
||||
activeChar.broadcastPacket(obj);
|
||||
}
|
||||
state = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
292
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
vendored
Normal file
292
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminOlympiad.java
vendored
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadGameManager;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadGameNonClassed;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadGameTask;
|
||||
import com.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import com.l2jmobius.gameserver.model.olympiad.Participant;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AdminOlympiad implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_olympiad_game",
|
||||
"admin_addolypoints",
|
||||
"admin_removeolypoints",
|
||||
"admin_setolypoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_olympiad_game":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //olympiad_game <player name>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player == activeChar)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_ON_YOURSELF);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!checkplayer(player, activeChar) || !checkplayer(activeChar, activeChar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < OlympiadGameManager.getInstance().getNumberOfStadiums(); i++)
|
||||
{
|
||||
final OlympiadGameTask task = OlympiadGameManager.getInstance().getOlympiadTask(i);
|
||||
if (task != null)
|
||||
{
|
||||
synchronized (task)
|
||||
{
|
||||
if (!task.isRunning())
|
||||
{
|
||||
final Participant[] players = new Participant[2];
|
||||
players[0] = new Participant(activeChar, 1);
|
||||
players[1] = new Participant(player, 2);
|
||||
task.attachGame(new OlympiadGameNonClassed(i, players));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_addolypoints":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
final L2PcInstance player = target != null ? target.getActingPlayer() : null;
|
||||
if (player != null)
|
||||
{
|
||||
final int val = parseInt(st, Integer.MIN_VALUE);
|
||||
if (val == Integer.MIN_VALUE)
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //addolypoints <points>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isNoble())
|
||||
{
|
||||
final StatsSet statDat = getPlayerSet(player);
|
||||
final int oldpoints = Olympiad.getInstance().getNoblePoints(player);
|
||||
final int points = Math.max(oldpoints + val, 0);
|
||||
if (points > 1000)
|
||||
{
|
||||
activeChar.sendMessage("You can't set more than 1000 or less than 0 Olympiad points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
statDat.set(Olympiad.POINTS, points);
|
||||
activeChar.sendMessage("Player " + player.getName() + " now has " + points + " Olympiad points.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("This player is not noblesse!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: target a player and write the amount of points you would like to add.");
|
||||
activeChar.sendMessage("Example: //addolypoints 10");
|
||||
activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 1000 points.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_removeolypoints":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
final L2PcInstance player = target != null ? target.getActingPlayer() : null;
|
||||
if (player != null)
|
||||
{
|
||||
final int val = parseInt(st, Integer.MIN_VALUE);
|
||||
if (val == Integer.MIN_VALUE)
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //removeolypoints <points>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isNoble())
|
||||
{
|
||||
final StatsSet playerStat = Olympiad.getNobleStats(player.getObjectId());
|
||||
if (playerStat == null)
|
||||
{
|
||||
activeChar.sendMessage("This player hasn't played on Olympiad yet!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int oldpoints = Olympiad.getInstance().getNoblePoints(player);
|
||||
final int points = Math.max(oldpoints - val, 0);
|
||||
playerStat.set(Olympiad.POINTS, points);
|
||||
|
||||
activeChar.sendMessage("Player " + player.getName() + " now has " + points + " Olympiad points.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("This player is not noblesse!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: target a player and write the amount of points you would like to remove.");
|
||||
activeChar.sendMessage("Example: //removeolypoints 10");
|
||||
activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 1000 points.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_setolypoints":
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
final L2PcInstance player = target != null ? target.getActingPlayer() : null;
|
||||
if (player != null)
|
||||
{
|
||||
final int val = parseInt(st, Integer.MIN_VALUE);
|
||||
if (val == Integer.MIN_VALUE)
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //setolypoints <points>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isNoble())
|
||||
{
|
||||
final StatsSet statDat = getPlayerSet(player);
|
||||
final int oldpoints = Olympiad.getInstance().getNoblePoints(player);
|
||||
final int points = oldpoints - val;
|
||||
if ((points < 1) && (points > 1000))
|
||||
{
|
||||
activeChar.sendMessage("You can't set more than 1000 or less than 0 Olympiad points! or lower then 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
statDat.set(Olympiad.POINTS, points);
|
||||
activeChar.sendMessage("Player " + player.getName() + " now has " + points + " Olympiad points.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("This player is not noblesse!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: target a player and write the amount of points you would like to set.");
|
||||
activeChar.sendMessage("Example: //setolypoints 10");
|
||||
activeChar.sendMessage("However, keep in mind that you can't have less than 0 or more than 1000 points.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private int parseInt(StringTokenizer st, int defaultVal)
|
||||
{
|
||||
final String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return Integer.decode(token);
|
||||
}
|
||||
|
||||
private StatsSet getPlayerSet(L2PcInstance player)
|
||||
{
|
||||
StatsSet statDat = Olympiad.getNobleStats(player.getObjectId());
|
||||
if (statDat == null)
|
||||
{
|
||||
statDat = new StatsSet();
|
||||
statDat.set(Olympiad.CLASS_ID, player.getBaseClass());
|
||||
statDat.set(Olympiad.CHAR_NAME, player.getName());
|
||||
statDat.set(Olympiad.POINTS, Olympiad.DEFAULT_POINTS);
|
||||
statDat.set(Olympiad.COMP_DONE, 0);
|
||||
statDat.set(Olympiad.COMP_WON, 0);
|
||||
statDat.set(Olympiad.COMP_LOST, 0);
|
||||
statDat.set(Olympiad.COMP_DRAWN, 0);
|
||||
statDat.set(Olympiad.COMP_DONE_WEEK, 0);
|
||||
statDat.set(Olympiad.COMP_DONE_WEEK_CLASSED, 0);
|
||||
statDat.set(Olympiad.COMP_DONE_WEEK_NON_CLASSED, 0);
|
||||
statDat.set(Olympiad.COMP_DONE_WEEK_TEAM, 0);
|
||||
statDat.set("to_save", true);
|
||||
Olympiad.addNobleStats(player.getObjectId(), statDat);
|
||||
}
|
||||
return statDat;
|
||||
}
|
||||
|
||||
private boolean checkplayer(L2PcInstance player, L2PcInstance activeChar)
|
||||
{
|
||||
if (player.isSubClassActive())
|
||||
{
|
||||
activeChar.sendMessage("Player " + player + " subclass active.");
|
||||
return false;
|
||||
}
|
||||
else if (player.getClassId().level() < 3)
|
||||
{
|
||||
activeChar.sendMessage("Player " + player + " has not 3rd class.");
|
||||
return false;
|
||||
}
|
||||
else if (Olympiad.getInstance().getNoblePoints(player) <= 0)
|
||||
{
|
||||
activeChar.sendMessage("Player " + player + " has 0 oly points (add them with (//addolypoints).");
|
||||
return false;
|
||||
}
|
||||
else if (OlympiadManager.getInstance().isRegistered(player))
|
||||
{
|
||||
activeChar.sendMessage("Player " + player + " registered to oly.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,204 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExPCCafePointInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin PC Points manage admin commands.<br>
|
||||
* Based on AdminPrimePoints by St3eT.
|
||||
*/
|
||||
public final class AdminPCBangPoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pcbangpoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_pcbangpoints"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
try
|
||||
{
|
||||
value = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("Invalid Value!");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "set":
|
||||
{
|
||||
if (value > Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("You cannot set more than " + Config.PC_BANG_MAX_POINTS + " PC points!");
|
||||
return false;
|
||||
}
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
target.setPcBangPoints(value);
|
||||
target.sendMessage("Admin set your PC point(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " PC point(s) to player " + target.getName());
|
||||
target.sendPacket(new ExPCCafePointInfo(value, value, 1));
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPcBangPoints() == Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min(target.getPcBangPoints() + value, Config.PC_BANG_MAX_POINTS);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Config.PC_BANG_MAX_POINTS;
|
||||
}
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPcBangPoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int pcBangCount = Math.max(target.getPcBangPoints() - value, 0);
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin decreased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
break;
|
||||
}
|
||||
case "rewardOnline":
|
||||
{
|
||||
int range = 0;
|
||||
try
|
||||
{
|
||||
range = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (range <= 0)
|
||||
{
|
||||
activeChar.sendMessage("You increased PC point(s) of all online players (" + increaseForAll(L2World.getInstance().getPlayers(), value) + ") by " + value + ".");
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
activeChar.sendMessage("You increased PC point(s) of all players (" + increaseForAll(activeChar.getKnownList().getKnownPlayers().values(), value) + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPcBangPoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min(temp.getPcBangPoints() + value, Integer.MAX_VALUE);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPcBangPoints(pcBangCount);
|
||||
temp.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
temp.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private L2PcInstance getTarget(L2PcInstance activeChar)
|
||||
{
|
||||
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
}
|
||||
|
||||
private void showMenuHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
final int points = target.getPcBangPoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/pcbang.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,98 +1,101 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.pathfinding.AbstractNodeLoc;
|
||||
import com.l2jmobius.gameserver.pathfinding.PathFinding;
|
||||
|
||||
public class AdminPathNode implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pn_info",
|
||||
"admin_show_path",
|
||||
"admin_path_debug",
|
||||
"admin_show_pn",
|
||||
"admin_find_path",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_pn_info"))
|
||||
{
|
||||
final String[] info = PathFinding.getInstance().getStat();
|
||||
if (info == null)
|
||||
{
|
||||
activeChar.sendMessage("Not supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String msg : info)
|
||||
{
|
||||
activeChar.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_show_path"))
|
||||
{
|
||||
}
|
||||
else if (command.equals("admin_path_debug"))
|
||||
{
|
||||
}
|
||||
else if (command.equals("admin_show_pn"))
|
||||
{
|
||||
}
|
||||
else if (command.equals("admin_find_path"))
|
||||
{
|
||||
if (Config.PATHFINDING == 0)
|
||||
{
|
||||
activeChar.sendMessage("PathFinding is disabled.");
|
||||
return true;
|
||||
}
|
||||
if (activeChar.getTarget() != null)
|
||||
{
|
||||
final List<AbstractNodeLoc> path = PathFinding.getInstance().findPath(activeChar.getX(), activeChar.getY(), (short) activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), (short) activeChar.getTarget().getZ(), activeChar.getInstanceId(), true);
|
||||
if (path == null)
|
||||
{
|
||||
activeChar.sendMessage("No Route!");
|
||||
return true;
|
||||
}
|
||||
for (AbstractNodeLoc a : path)
|
||||
{
|
||||
activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("No Target!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.pathfinding.AbstractNodeLoc;
|
||||
import com.l2jmobius.gameserver.pathfinding.PathFinding;
|
||||
|
||||
public class AdminPathNode implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pn_info",
|
||||
"admin_show_path",
|
||||
"admin_path_debug",
|
||||
"admin_show_pn",
|
||||
"admin_find_path",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_pn_info"))
|
||||
{
|
||||
final String[] info = PathFinding.getInstance().getStat();
|
||||
if (info == null)
|
||||
{
|
||||
activeChar.sendMessage("Not supported");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (String msg : info)
|
||||
{
|
||||
activeChar.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_show_path"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (command.equals("admin_path_debug"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (command.equals("admin_show_pn"))
|
||||
{
|
||||
|
||||
}
|
||||
else if (command.equals("admin_find_path"))
|
||||
{
|
||||
if (Config.PATHFINDING == 0)
|
||||
{
|
||||
activeChar.sendMessage("PathFinding is disabled.");
|
||||
return true;
|
||||
}
|
||||
if (activeChar.getTarget() != null)
|
||||
{
|
||||
final List<AbstractNodeLoc> path = PathFinding.getInstance().findPath(activeChar.getX(), activeChar.getY(), (short) activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), (short) activeChar.getTarget().getZ(), activeChar.getInstanceWorld(), true);
|
||||
if (path == null)
|
||||
{
|
||||
activeChar.sendMessage("No Route!");
|
||||
return true;
|
||||
}
|
||||
for (AbstractNodeLoc a : path)
|
||||
{
|
||||
activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("No Target!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,11 +25,15 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Handler provides ability to override server's conditions for admin.
|
||||
* @author UnAfraid
|
||||
* Handler provides ability to override server's conditions for admin.<br>
|
||||
* Note: //setparam command uses any XML value and ignores case sensitivity.<br>
|
||||
* For best results by //setparam enable the maximum stats PcCondOverride here.
|
||||
* @author UnAfraid, Nik
|
||||
*/
|
||||
public class AdminPcCondOverride implements IAdminCommandHandler
|
||||
{
|
||||
// private static final int SETPARAM_ORDER = 0x90;
|
||||
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"admin_exceptions",
|
||||
@@ -48,7 +52,7 @@ public class AdminPcCondOverride implements IAdminCommandHandler
|
||||
case "admin_exceptions":
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/cond_override.htm");
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/cond_override.htm");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (PcCondOverride ex : PcCondOverride.values())
|
||||
{
|
||||
|
||||
@@ -1,130 +1,130 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles commands for GMs to respond to petitions.
|
||||
* @author Tempy
|
||||
*/
|
||||
public class AdminPetition implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_view_petitions",
|
||||
"admin_view_petition",
|
||||
"admin_accept_petition",
|
||||
"admin_reject_petition",
|
||||
"admin_reset_petitions",
|
||||
"admin_force_peti"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int petitionId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
petitionId = Integer.parseInt(command.split(" ")[1]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (command.equals("admin_view_petitions"))
|
||||
{
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_view_petition"))
|
||||
{
|
||||
PetitionManager.getInstance().viewPetition(activeChar, petitionId);
|
||||
}
|
||||
else if (command.startsWith("admin_accept_petition"))
|
||||
{
|
||||
if (PetitionManager.getInstance().isPlayerInConsultation(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_ONLY_SUBMIT_ONE_PETITION_ACTIVE_AT_A_TIME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PetitionManager.getInstance().isPetitionInProcess(petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_PETITION_IS_BEING_PROCESSED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PetitionManager.getInstance().acceptPetition(activeChar, petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.NOT_UNDER_PETITION_CONSULTATION);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_reject_petition"))
|
||||
{
|
||||
if (!PetitionManager.getInstance().rejectPetition(activeChar, petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CANCEL_PETITION_PLEASE_TRY_AGAIN_LATER);
|
||||
}
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_reset_petitions"))
|
||||
{
|
||||
if (PetitionManager.getInstance().isPetitionInProcess())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_PETITION_IS_BEING_PROCESSED);
|
||||
return false;
|
||||
}
|
||||
PetitionManager.getInstance().clearPendingPetitions();
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_force_peti"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2Object targetChar = activeChar.getTarget();
|
||||
if ((targetChar == null) || !(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
final L2PcInstance targetPlayer = (L2PcInstance) targetChar;
|
||||
|
||||
final String val = command.substring(15);
|
||||
|
||||
petitionId = PetitionManager.getInstance().submitPetition(targetPlayer, val, 9);
|
||||
PetitionManager.getInstance().acceptPetition(activeChar, petitionId);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //force_peti text");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* This class handles commands for GMs to respond to petitions.
|
||||
* @author Tempy
|
||||
*/
|
||||
public class AdminPetition implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_view_petitions",
|
||||
"admin_view_petition",
|
||||
"admin_accept_petition",
|
||||
"admin_reject_petition",
|
||||
"admin_reset_petitions",
|
||||
"admin_force_peti"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int petitionId = -1;
|
||||
|
||||
try
|
||||
{
|
||||
petitionId = Integer.parseInt(command.split(" ")[1]);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (command.equals("admin_view_petitions"))
|
||||
{
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_view_petition"))
|
||||
{
|
||||
PetitionManager.getInstance().viewPetition(activeChar, petitionId);
|
||||
}
|
||||
else if (command.startsWith("admin_accept_petition"))
|
||||
{
|
||||
if (PetitionManager.getInstance().isPlayerInConsultation(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_MAY_ONLY_SUBMIT_ONE_PETITION_ACTIVE_AT_A_TIME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PetitionManager.getInstance().isPetitionInProcess(petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_PETITION_IS_BEING_PROCESSED);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PetitionManager.getInstance().acceptPetition(activeChar, petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.NOT_UNDER_PETITION_CONSULTATION);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_reject_petition"))
|
||||
{
|
||||
if (!PetitionManager.getInstance().rejectPetition(activeChar, petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CANCEL_PETITION_PLEASE_TRY_AGAIN_LATER);
|
||||
}
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_reset_petitions"))
|
||||
{
|
||||
if (PetitionManager.getInstance().isPetitionInProcess())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_PETITION_IS_BEING_PROCESSED);
|
||||
return false;
|
||||
}
|
||||
PetitionManager.getInstance().clearPendingPetitions();
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_force_peti"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2Object targetChar = activeChar.getTarget();
|
||||
if ((targetChar == null) || !(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
final L2PcInstance targetPlayer = (L2PcInstance) targetChar;
|
||||
|
||||
final String val = command.substring(15);
|
||||
|
||||
petitionId = PetitionManager.getInstance().submitPetition(targetPlayer, val, 9);
|
||||
PetitionManager.getInstance().acceptPetition(activeChar, petitionId);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //force_peti text");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,216 +1,217 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.GMViewPledgeInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* <B>Pledge Manipulation:</B><BR>
|
||||
* <LI>With target in a character without clan:<BR>
|
||||
* //pledge create clanname
|
||||
* <LI>With target in a clan leader:<BR>
|
||||
* //pledge info<BR>
|
||||
* //pledge dismiss<BR>
|
||||
* //pledge setlevel level<BR>
|
||||
* //pledge rep reputation_points<BR>
|
||||
*/
|
||||
public class AdminPledge implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pledge"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
final L2Object target = activeChar.getTarget();
|
||||
final L2PcInstance targetPlayer = target instanceof L2PcInstance ? (L2PcInstance) target : null;
|
||||
L2Clan clan = targetPlayer != null ? targetPlayer.getClan() : null;
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_pledge":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing parameters!");
|
||||
break;
|
||||
}
|
||||
final String action = st.nextToken();
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing parameters!");
|
||||
break;
|
||||
}
|
||||
final String param = st.nextToken();
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "create":
|
||||
{
|
||||
if (clan != null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
final long penalty = targetPlayer.getClanCreateExpiryTime();
|
||||
targetPlayer.setClanCreateExpiryTime(0);
|
||||
clan = ClanTable.getInstance().createClan(targetPlayer, param);
|
||||
if (clan != null)
|
||||
{
|
||||
activeChar.sendMessage("Clan " + param + " created. Leader: " + targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlayer.setClanCreateExpiryTime(penalty);
|
||||
activeChar.sendMessage("There was a problem while creating the clan.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "dismiss":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!targetPlayer.isClanLeader())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER);
|
||||
sm.addCharName(targetPlayer);
|
||||
activeChar.sendPacket(sm);
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
ClanTable.getInstance().destroyClan(targetPlayer.getClanId());
|
||||
clan = targetPlayer.getClan();
|
||||
if (clan != null)
|
||||
{
|
||||
activeChar.sendMessage("There was a problem while destroying the clan.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Clan disbanded.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new GMViewPledgeInfo(clan, targetPlayer));
|
||||
break;
|
||||
}
|
||||
case "setlevel":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
else if (param == null)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //pledge <setlevel|rep> <number>");
|
||||
break;
|
||||
}
|
||||
|
||||
final int level = Integer.parseInt(param);
|
||||
if ((level >= 0) && (level < 12))
|
||||
{
|
||||
clan.changeLevel(level);
|
||||
for (L2PcInstance member : clan.getOnlineMembers(0))
|
||||
{
|
||||
member.broadcastUserInfo(UserInfoType.RELATION, UserInfoType.CLAN);
|
||||
}
|
||||
activeChar.sendMessage("You set level " + level + " for clan " + clan.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Level incorrect.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "rep":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
else if (clan.getLevel() < 5)
|
||||
{
|
||||
activeChar.sendMessage("Only clans of level 5 or above may receive reputation points.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final int points = Integer.parseInt(param);
|
||||
clan.addReputationScore(points, true);
|
||||
activeChar.sendMessage("You " + (points > 0 ? "add " : "remove ") + Math.abs(points) + " points " + (points > 0 ? "to " : "from ") + clan.getName() + "'s reputation. Their current score is " + clan.getReputationScore());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //pledge <rep> <number>");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "game_menu.htm");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jmobius.gameserver.enums.UserInfoType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Clan;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.GMViewPledgeInfo;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* <B>Pledge Manipulation:</B><BR>
|
||||
* <LI>With target in a character without clan:<BR>
|
||||
* //pledge create clanname
|
||||
* <LI>With target in a clan leader:<BR>
|
||||
* //pledge info<BR>
|
||||
* //pledge dismiss<BR>
|
||||
* //pledge setlevel level<BR>
|
||||
* //pledge rep reputation_points<BR>
|
||||
*/
|
||||
public class AdminPledge implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pledge"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
final L2Object target = activeChar.getTarget();
|
||||
final L2PcInstance targetPlayer = target instanceof L2PcInstance ? (L2PcInstance) target : null;
|
||||
L2Clan clan = targetPlayer != null ? targetPlayer.getClan() : null;
|
||||
if (targetPlayer == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_pledge":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing parameters!");
|
||||
break;
|
||||
}
|
||||
final String action = st.nextToken();
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing parameters!");
|
||||
break;
|
||||
}
|
||||
final String param = st.nextToken();
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "create":
|
||||
{
|
||||
if (clan != null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
final long penalty = targetPlayer.getClanCreateExpiryTime();
|
||||
targetPlayer.setClanCreateExpiryTime(0);
|
||||
clan = ClanTable.getInstance().createClan(targetPlayer, param);
|
||||
if (clan != null)
|
||||
{
|
||||
activeChar.sendMessage("Clan " + param + " created. Leader: " + targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlayer.setClanCreateExpiryTime(penalty);
|
||||
activeChar.sendMessage("There was a problem while creating the clan.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "dismiss":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!targetPlayer.isClanLeader())
|
||||
{
|
||||
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER);
|
||||
sm.addCharName(targetPlayer);
|
||||
activeChar.sendPacket(sm);
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
ClanTable.getInstance().destroyClan(targetPlayer.getClanId());
|
||||
clan = targetPlayer.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Clan disbanded.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("There was a problem while destroying the clan.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "info":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new GMViewPledgeInfo(clan, targetPlayer));
|
||||
break;
|
||||
}
|
||||
case "setlevel":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
else if (param == null)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //pledge <setlevel|rep> <number>");
|
||||
break;
|
||||
}
|
||||
|
||||
final int level = Integer.parseInt(param);
|
||||
if ((level >= 0) && (level < 12))
|
||||
{
|
||||
clan.changeLevel(level);
|
||||
for (L2PcInstance member : clan.getOnlineMembers(0))
|
||||
{
|
||||
member.broadcastUserInfo(UserInfoType.RELATION, UserInfoType.CLAN);
|
||||
}
|
||||
activeChar.sendMessage("You set level " + level + " for clan " + clan.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Level incorrect.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "rep":
|
||||
{
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Target player has no clan!");
|
||||
break;
|
||||
}
|
||||
else if (clan.getLevel() < 5)
|
||||
{
|
||||
activeChar.sendMessage("Only clans of level 5 or above may receive reputation points.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final int points = Integer.parseInt(param);
|
||||
clan.addReputationScore(points, true);
|
||||
activeChar.sendMessage("You " + (points > 0 ? "add " : "remove ") + Math.abs(points) + " points " + (points > 0 ? "to " : "from ") + clan.getName() + "'s reputation. Their current score is " + clan.getReputationScore());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //pledge <rep> <number>");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "game_menu.htm");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,199 +1,199 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Polymorph admin command implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class AdminPolymorph implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_polymorph",
|
||||
"admin_unpolymorph",
|
||||
"admin_transform",
|
||||
"admin_untransform",
|
||||
"admin_transform_menu",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_transform_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "transform.htm");
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_untransform"))
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
((L2Character) obj).stopTransformation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_transform"))
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj == null) || !obj.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance player = obj.getActingPlayer();
|
||||
if (activeChar.isSitting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_SITTING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
if (!command.contains(" "))
|
||||
{
|
||||
player.untransform();
|
||||
return true;
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isInWater())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_POLYMORPH_INTO_THE_DESIRED_FORM_IN_WATER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isFlyingMounted() || player.isMounted())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_RIDING_A_PET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length != 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //transform <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int id = Integer.parseInt(parts[1]);
|
||||
if (!TransformData.getInstance().transformPlayer(id, player))
|
||||
{
|
||||
player.sendMessage("Unknown transformation ID: " + id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_polymorph"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length < 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //polymorph [type] <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parts.length > 2)
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[2], parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[1], "npc");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpolymorph"))
|
||||
{
|
||||
doUnPolymorph(activeChar, activeChar.getTarget());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Polymorph a creature.
|
||||
* @param activeChar the active Game Master
|
||||
* @param obj the target
|
||||
* @param id the polymorph ID
|
||||
* @param type the polymorph type
|
||||
*/
|
||||
private static void doPolymorph(L2PcInstance activeChar, L2Object obj, String id, String type)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
obj.getPoly().setPolyInfo(type, id);
|
||||
// animation
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
final L2Character Char = (L2Character) obj;
|
||||
final MagicSkillUse msk = new MagicSkillUse(Char, 1008, 1, 4000, 0);
|
||||
Char.broadcastPacket(msk);
|
||||
Char.sendPacket(new SetupGauge(0, 4000));
|
||||
}
|
||||
// end of animation
|
||||
obj.decayMe();
|
||||
obj.spawnMe(obj.getX(), obj.getY(), obj.getZ());
|
||||
activeChar.sendMessage("Polymorph succeed");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpolymorh a creature.
|
||||
* @param activeChar the active Game Master
|
||||
* @param target the target
|
||||
*/
|
||||
private static void doUnPolymorph(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
target.getPoly().setPolyInfo(null, "1");
|
||||
target.decayMe();
|
||||
target.spawnMe(target.getX(), target.getY(), target.getZ());
|
||||
activeChar.sendMessage("Unpolymorph succeed");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SetupGauge;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Polymorph admin command implementation.
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class AdminPolymorph implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_polymorph",
|
||||
"admin_unpolymorph",
|
||||
"admin_transform",
|
||||
"admin_untransform",
|
||||
"admin_transform_menu",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_transform_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "transform.htm");
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_untransform"))
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
((L2Character) obj).stopTransformation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_transform"))
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj == null) || !obj.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance player = obj.getActingPlayer();
|
||||
if (activeChar.isSitting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_SITTING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isTransformed())
|
||||
{
|
||||
if (!command.contains(" "))
|
||||
{
|
||||
player.untransform();
|
||||
return true;
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isInWater())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_POLYMORPH_INTO_THE_DESIRED_FORM_IN_WATER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isFlyingMounted() || player.isMounted())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_RIDING_A_PET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length != 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //transform <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int id = Integer.parseInt(parts[1]);
|
||||
if (!player.transform(id, true))
|
||||
{
|
||||
player.sendMessage("Unknown transformation ID: " + id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_polymorph"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length < 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //polymorph [type] <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parts.length > 2)
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[2], parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[1], "npc");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpolymorph"))
|
||||
{
|
||||
doUnPolymorph(activeChar, activeChar.getTarget());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Polymorph a creature.
|
||||
* @param activeChar the active Game Master
|
||||
* @param obj the target
|
||||
* @param id the polymorph ID
|
||||
* @param type the polymorph type
|
||||
*/
|
||||
private static void doPolymorph(L2PcInstance activeChar, L2Object obj, String id, String type)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
obj.getPoly().setPolyInfo(type, id);
|
||||
// animation
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
final L2Character Char = (L2Character) obj;
|
||||
final MagicSkillUse msk = new MagicSkillUse(Char, 1008, 1, 4000, 0);
|
||||
Char.broadcastPacket(msk);
|
||||
final SetupGauge sg = new SetupGauge(activeChar.getObjectId(), 0, 4000);
|
||||
Char.sendPacket(sg);
|
||||
}
|
||||
// end of animation
|
||||
obj.decayMe();
|
||||
obj.spawnMe(obj.getX(), obj.getY(), obj.getZ());
|
||||
activeChar.sendMessage("Polymorph succeed");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpolymorh a creature.
|
||||
* @param activeChar the active Game Master
|
||||
* @param target the target
|
||||
*/
|
||||
private static void doUnPolymorph(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
target.getPoly().setPolyInfo(null, "1");
|
||||
target.decayMe();
|
||||
target.spawnMe(target.getX(), target.getY(), target.getZ());
|
||||
activeChar.sendMessage("Unpolymorph succeed");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class AdminPremium implements IAdminCommandHandler
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/premium_menu.htm"));
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/premium_menu.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,187 +1,189 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Prime Points manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminPrimePoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_primepoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_primepoints"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
try
|
||||
{
|
||||
value = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("Invalid Value!");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "set":
|
||||
{
|
||||
target.setPrimePoints(value);
|
||||
target.sendMessage("Admin set your NCoin(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " NCoin(s) to player " + target.getName());
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of NCoins!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int primeCount = Math.min(target.getPrimePoints() + value, Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin increased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased NCoin(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPrimePoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of NCoins!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int primeCount = Math.max(target.getPrimePoints() - value, 0);
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin decreased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased NCoin(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "rewardOnline":
|
||||
{
|
||||
int range = 0;
|
||||
try
|
||||
{
|
||||
range = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (range <= 0)
|
||||
{
|
||||
activeChar.sendMessage("You increased NCoin(s) of all online players (" + increaseForAll(L2World.getInstance().getPlayers(), value) + ") by " + value + ".");
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
activeChar.sendMessage("You increased NCoin(s) of all players (" + increaseForAll(activeChar.getKnownList().getKnownPlayers().values(), value) + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int primeCount = Math.min(temp.getPrimePoints() + value, Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPrimePoints(primeCount);
|
||||
temp.sendMessage("Admin increased your NCoin(s) by " + value + "!");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private L2PcInstance getTarget(L2PcInstance activeChar)
|
||||
{
|
||||
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
}
|
||||
|
||||
private void showMenuHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
final int points = target.getPrimePoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/primepoints.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.Collection;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Prime Points manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminPrimePoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_primepoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_primepoints"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
try
|
||||
{
|
||||
value = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("Invalid Value!");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "set":
|
||||
{
|
||||
target.setPrimePoints(value);
|
||||
target.sendMessage("Admin set your Prime Point(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " Prime Point(s) to player " + target.getName());
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of Prime Points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int primeCount = Math.min((target.getPrimePoints() + value), Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin increase your Prime Point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased Prime Point(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPrimePoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of Prime Points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int primeCount = Math.max(target.getPrimePoints() - value, 0);
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin decreased your Prime Point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased Prime Point(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "rewardOnline":
|
||||
{
|
||||
int range = 0;
|
||||
try
|
||||
{
|
||||
range = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (range <= 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getPlayers(), value);
|
||||
activeChar.sendMessage("You increased Prime Point(s) of all online players (" + count + ") by " + value + ".");
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getVisibleObjects(activeChar, L2PcInstance.class, range), value);
|
||||
activeChar.sendMessage("You increased Prime Point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int primeCount = Math.min((temp.getPrimePoints() + value), Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPrimePoints(primeCount);
|
||||
temp.sendMessage("Admin increase your Prime Point(s) by " + value + "!");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private L2PcInstance getTarget(L2PcInstance activeChar)
|
||||
{
|
||||
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
}
|
||||
|
||||
private void showMenuHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
final int points = target.getPrimePoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/primepoints.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ import java.net.UnknownHostException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
@@ -77,21 +77,22 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/punishment.htm");
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment.htm");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%affects%", Util.implode(PunishmentAffect.values(), ";"));
|
||||
content = content.replaceAll("%punishments%", CommonUtil.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%affects%", CommonUtil.implode(PunishmentAffect.values(), ";"));
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment.htm is missing");
|
||||
_log.warning(getClass().getSimpleName() + ": data/html/admin/punishment.htm is missing");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (st.nextToken())
|
||||
final String subcmd = st.nextToken();
|
||||
switch (subcmd)
|
||||
{
|
||||
case "info":
|
||||
{
|
||||
@@ -117,7 +118,7 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
key = findCharId(key);
|
||||
}
|
||||
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/punishment-info.htm");
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-info.htm");
|
||||
if (content != null)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
@@ -142,13 +143,13 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
|
||||
content = content.replaceAll("%player_name%", name);
|
||||
content = content.replaceAll("%punishments%", sb.toString());
|
||||
content = content.replaceAll("%affects%", Util.implode(PunishmentAffect.values(), ";"));
|
||||
content = content.replaceAll("%affects%", CommonUtil.implode(PunishmentAffect.values(), ";"));
|
||||
content = content.replaceAll("%affect_type%", affect.name());
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment-info.htm is missing");
|
||||
_log.warning(getClass().getSimpleName() + ": data/html/admin/punishment-info.htm is missing");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -173,11 +174,11 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
{
|
||||
target = activeChar.getTarget().getActingPlayer();
|
||||
}
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/punishment-player.htm");
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-player.htm");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.replaceAll("%player_name%", target.getName());
|
||||
content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%punishments%", CommonUtil.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%acc%", target.getAccountName());
|
||||
content = content.replaceAll("%char%", target.getName());
|
||||
content = content.replaceAll("%ip%", target.getIPAddress());
|
||||
@@ -185,7 +186,7 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment-player.htm is missing");
|
||||
_log.warning(getClass().getSimpleName() + ": data/html/admin/punishment-player.htm is missing");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -384,10 +385,14 @@ public class AdminPunishment implements IAdminCommandHandler
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String findCharId(String key)
|
||||
private static final String findCharId(String key)
|
||||
{
|
||||
final int charId = CharNameTable.getInstance().getIdByName(key);
|
||||
return charId > 0 ? Integer.toString(charId) : key;
|
||||
if (charId > 0) // Yeah its a char name!
|
||||
{
|
||||
return Integer.toString(charId);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,334 +1,394 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestTimer;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class AdminQuest implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_quest_reload",
|
||||
"admin_script_load",
|
||||
"admin_script_unload",
|
||||
"admin_show_quests",
|
||||
"admin_quest_info"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// syntax will either be:
|
||||
// //quest_reload <id>
|
||||
// //quest_reload <questName>
|
||||
// The questName MUST start with a non-numeric character for this to work,
|
||||
// regardless which of the two formats is used.
|
||||
// Example: //quest_reload orc_occupation_change_1
|
||||
// Example: //quest_reload chests
|
||||
// Example: //quest_reload SagasSuperclass
|
||||
// Example: //quest_reload 12
|
||||
if (command.startsWith("admin_quest_reload"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //quest_reload <questFolder>.<questSubFolders...>.questName> or //quest_reload <id>");
|
||||
}
|
||||
else
|
||||
{
|
||||
// try the first param as id
|
||||
try
|
||||
{
|
||||
if (QuestManager.getInstance().reload(Integer.parseInt(parts[1])))
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Failed");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
if (QuestManager.getInstance().reload(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// script load should NOT be used in place of reload. If a script is already loaded
|
||||
// successfully, quest_reload ought to be used. The script_load command should only
|
||||
// be used for scripts that failed to load altogether (eg. due to errors) or that
|
||||
// did not at all exist during server boot. Using script_load to re-load a previously
|
||||
// loaded script may cause unpredictable script flow, minor loss of data, and more.
|
||||
// This provides a way to load new scripts without having to reboot the server.
|
||||
else if (command.startsWith("admin_script_load"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
// activeChar.sendMessage("Example: //script_load <questFolder>/<questSubFolders...>/<filename>.<ext> ");
|
||||
activeChar.sendMessage("Example: //script_load quests/SagasSuperclass/__init__.py");
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, parts[1]);
|
||||
// Trying to reload by script name.
|
||||
if (!file.exists())
|
||||
{
|
||||
final Quest quest = QuestManager.getInstance().getQuest(parts[1]);
|
||||
if (quest != null)
|
||||
{
|
||||
file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, quest.getClass().getName().replaceAll("\\.", "/") + ".java");
|
||||
}
|
||||
}
|
||||
|
||||
// Reloading by full path
|
||||
if (file.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
|
||||
// This part should be called only when the script is successfully loaded.
|
||||
activeChar.sendMessage("Script Successfully Loaded.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1]);
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("File Not Found: " + parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_script_unload"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("Example: //script_unload questName/questId");
|
||||
}
|
||||
else
|
||||
{
|
||||
final Quest q = Util.isDigit(parts[1]) ? QuestManager.getInstance().getQuest(Integer.parseInt(parts[1])) : QuestManager.getInstance().getQuest(parts[1]);
|
||||
|
||||
if (q != null)
|
||||
{
|
||||
if (q.unload())
|
||||
{
|
||||
activeChar.sendMessage("Script Successfully Unloaded [" + q.getName() + "/" + q.getId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Failed unloading [" + q.getName() + "/" + q.getId() + "].");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The quest [" + parts[1] + "] was not found!.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_show_quests"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendMessage("Get a target first.");
|
||||
}
|
||||
else if (!activeChar.getTarget().isCharacter())
|
||||
{
|
||||
activeChar.sendMessage("Invalid Target.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Character character = (L2Character) activeChar.getTarget();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final Set<String> questNames = new TreeSet<>();
|
||||
for (EventType type : EventType.values())
|
||||
{
|
||||
for (AbstractEventListener listener : character.getListeners(type))
|
||||
{
|
||||
if (listener.getOwner() instanceof Quest)
|
||||
{
|
||||
final Quest quest = (Quest) listener.getOwner();
|
||||
if (questNames.contains(quest.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sb.append("<tr><td colspan=\"4\"><font color=\"LEVEL\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></font></td></tr>");
|
||||
questNames.add(quest.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%objid%", character.getObjectId());
|
||||
msg.replace("%questName%", "");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_quest_info "))
|
||||
{
|
||||
final String questName = command.substring("admin_quest_info ".length());
|
||||
final Quest quest = QuestManager.getInstance().getQuest(questName);
|
||||
String events = "", npcs = "", items = "", timers = "";
|
||||
int counter = 0;
|
||||
if (quest == null)
|
||||
{
|
||||
activeChar.sendMessage("Couldn't find quest or script with name " + questName + " !");
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<EventType> listenerTypes = new TreeSet<>();
|
||||
for (AbstractEventListener listener : quest.getListeners())
|
||||
{
|
||||
if (!listenerTypes.contains(listener.getType()))
|
||||
{
|
||||
events += ", " + listener.getType().name();
|
||||
listenerTypes.add(listener.getType());
|
||||
counter++;
|
||||
}
|
||||
if (counter > 10)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Set<Integer> npcIds = new TreeSet<>(quest.getRegisteredIds(ListenerRegisterType.NPC));
|
||||
for (int npcId : npcIds)
|
||||
{
|
||||
npcs += ", " + npcId;
|
||||
counter++;
|
||||
if (counter > 50)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
events = listenerTypes.size() + ": " + events.substring(2);
|
||||
}
|
||||
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
npcs = npcIds.size() + ": " + npcs.substring(2);
|
||||
}
|
||||
|
||||
if (quest.getRegisteredItemIds() != null)
|
||||
{
|
||||
for (int itemId : quest.getRegisteredItemIds())
|
||||
{
|
||||
items += ", " + itemId;
|
||||
counter++;
|
||||
if (counter > 20)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
items = quest.getRegisteredItemIds().length + ":" + items.substring(2);
|
||||
}
|
||||
|
||||
for (List<QuestTimer> list : quest.getQuestTimers().values())
|
||||
{
|
||||
for (QuestTimer timer : list)
|
||||
{
|
||||
timers += "<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">" + timer.getName() + ":</font> <font color=00FF00>Active: " + timer.getIsActive() + " Repeatable: " + timer.getIsRepeating() + " Player: " + timer.getPlayer() + " Npc: " + timer.getNpc() + "</font></td></tr></table></td></tr>";
|
||||
counter++;
|
||||
if (counter > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">ID:</font> <font color=00FF00>" + quest.getId() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Name:</font> <font color=00FF00>" + quest.getName() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Descr:</font> <font color=00FF00>" + quest.getDescr() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Path:</font> <font color=00FF00>" + quest.getClass().getName().substring(0, quest.getClass().getName().lastIndexOf('.')).replaceAll("\\.", "/") + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Events:</font> <font color=00FF00>" + events + "</font></td></tr></table></td></tr>");
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">NPCs:</font> <font color=00FF00>" + npcs + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!items.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Items:</font> <font color=00FF00>" + items + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!timers.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Timers:</font> <font color=00FF00></font></td></tr></table></td></tr>");
|
||||
sb.append(timers);
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%questName%", "<table><tr><td width=\"50\" align=\"left\"><a action=\"bypass -h admin_script_load " + quest.getName() + "\">Reload</a></td> <td width=\"150\" align=\"center\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></td> <td width=\"50\" align=\"right\"><a action=\"bypass -h admin_script_unload " + quest.getName() + "\">Unload</a></tr></td></table>");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.listeners.AbstractEventListener;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestTimer;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class AdminQuest implements IAdminCommandHandler
|
||||
{
|
||||
public static final Logger LOGGER = Logger.getLogger(AdminQuest.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_quest_reload",
|
||||
"admin_script_load",
|
||||
"admin_script_unload",
|
||||
"admin_script_dir",
|
||||
"admin_show_quests",
|
||||
"admin_quest_info"
|
||||
};
|
||||
|
||||
private static Quest findScript(String script)
|
||||
{
|
||||
if (Util.isDigit(script))
|
||||
{
|
||||
return QuestManager.getInstance().getQuest(Integer.parseInt(script));
|
||||
}
|
||||
return QuestManager.getInstance().getQuest(script);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_quest_reload"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // skip command token
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //quest_reload <questName> or <questId>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String script = st.nextToken();
|
||||
final Quest quest = findScript(script);
|
||||
if (quest == null)
|
||||
{
|
||||
activeChar.sendMessage("The script " + script + " couldn't be found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!quest.reload())
|
||||
{
|
||||
activeChar.sendMessage("Failed to reload " + script + "!");
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Script successful reloaded.");
|
||||
}
|
||||
else if (command.startsWith("admin_script_load"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // skip command token
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //script_load path/to/script.java");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String script = st.nextToken();
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeScript(Paths.get(script));
|
||||
activeChar.sendMessage("Script loaded seccessful!");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed to load script!");
|
||||
LOGGER.log(Level.WARNING, "Failed to load script " + script + "!", e);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_script_unload"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // skip command token
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //script_load path/to/script.java");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String script = st.nextToken();
|
||||
final Quest quest = findScript(script);
|
||||
if (quest == null)
|
||||
{
|
||||
activeChar.sendMessage("The script " + script + " couldn't be found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
quest.unload();
|
||||
activeChar.sendMessage("Script successful unloaded!");
|
||||
}
|
||||
else if (command.startsWith("admin_script_dir"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length == 1)
|
||||
{
|
||||
showDir(null, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
showDir(parts[1], activeChar);
|
||||
}
|
||||
|
||||
}
|
||||
else if (command.startsWith("admin_show_quests"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendMessage("Get a target first.");
|
||||
}
|
||||
else if (!activeChar.getTarget().isCharacter())
|
||||
{
|
||||
activeChar.sendMessage("Invalid Target.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Character character = (L2Character) activeChar.getTarget();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final Set<String> questNames = new TreeSet<>();
|
||||
for (EventType type : EventType.values())
|
||||
{
|
||||
for (AbstractEventListener listener : character.getListeners(type))
|
||||
{
|
||||
if (listener.getOwner() instanceof Quest)
|
||||
{
|
||||
final Quest quest = (Quest) listener.getOwner();
|
||||
if (!questNames.add(quest.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sb.append("<tr><td colspan=\"4\"><font color=\"LEVEL\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></font></td></tr>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%objid%", character.getObjectId());
|
||||
msg.replace("%questName%", "");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_quest_info "))
|
||||
{
|
||||
final String questName = command.substring("admin_quest_info ".length());
|
||||
final Quest quest = QuestManager.getInstance().getQuest(questName);
|
||||
String events = "", npcs = "", items = "", timers = "";
|
||||
int counter = 0;
|
||||
if (quest == null)
|
||||
{
|
||||
activeChar.sendMessage("Couldn't find quest or script with name " + questName + " !");
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<EventType> listenerTypes = new TreeSet<>();
|
||||
for (AbstractEventListener listener : quest.getListeners())
|
||||
{
|
||||
if (listenerTypes.add(listener.getType()))
|
||||
{
|
||||
events += ", " + listener.getType().name();
|
||||
counter++;
|
||||
}
|
||||
if (counter > 10)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Set<Integer> npcIds = new TreeSet<>(quest.getRegisteredIds(ListenerRegisterType.NPC));
|
||||
for (int npcId : npcIds)
|
||||
{
|
||||
npcs += ", " + npcId;
|
||||
counter++;
|
||||
if (counter > 50)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
events = listenerTypes.size() + ": " + events.substring(2);
|
||||
}
|
||||
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
npcs = npcIds.size() + ": " + npcs.substring(2);
|
||||
}
|
||||
|
||||
if (quest.getRegisteredItemIds() != null)
|
||||
{
|
||||
for (int itemId : quest.getRegisteredItemIds())
|
||||
{
|
||||
items += ", " + itemId;
|
||||
counter++;
|
||||
if (counter > 20)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
items = quest.getRegisteredItemIds().length + ":" + items.substring(2);
|
||||
}
|
||||
|
||||
for (List<QuestTimer> list : quest.getQuestTimers().values())
|
||||
{
|
||||
for (QuestTimer timer : list)
|
||||
{
|
||||
timers += "<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">" + timer.getName() + ":</font> <font color=00FF00>Active: " + timer.getIsActive() + " Repeatable: " + timer.getIsRepeating() + " Player: " + timer.getPlayer() + " Npc: " + timer.getNpc() + "</font></td></tr></table></td></tr>";
|
||||
counter++;
|
||||
if (counter > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">ID:</font> <font color=00FF00>" + quest.getId() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Name:</font> <font color=00FF00>" + quest.getName() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Path:</font> <font color=00FF00>" + quest.getPath() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Events:</font> <font color=00FF00>" + events + "</font></td></tr></table></td></tr>");
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">NPCs:</font> <font color=00FF00>" + npcs + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!items.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Items:</font> <font color=00FF00>" + items + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!timers.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Timers:</font> <font color=00FF00></font></td></tr></table></td></tr>");
|
||||
sb.append(timers);
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%questName%", "<table><tr><td width=\"50\" align=\"left\"><a action=\"bypass -h admin_script_load " + quest.getName() + "\">Reload</a></td> <td width=\"150\" align=\"center\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></td> <td width=\"50\" align=\"right\"><a action=\"bypass -h admin_script_unload " + quest.getName() + "\">Unload</a></td></tr></table>");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showDir(String dir, L2PcInstance activeChar)
|
||||
{
|
||||
String replace = null;
|
||||
File path;
|
||||
String currentPath = "/";
|
||||
if ((dir == null) || dir.trim().isEmpty() || dir.contains(".."))
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(200);
|
||||
path = ScriptEngineManager.SCRIPT_FOLDER.toFile();
|
||||
final String[] children = path.list();
|
||||
Arrays.sort(children);
|
||||
for (String c : children)
|
||||
{
|
||||
final File n = new File(path, c);
|
||||
if (n.isHidden() || n.getName().startsWith("."))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (n.isDirectory())
|
||||
{
|
||||
sb.append("<a action=\"bypass -h admin_script_dir " + c + "\">" + c + "</a><br1>");
|
||||
}
|
||||
else if (c.endsWith(".java") || c.endsWith(".py"))
|
||||
{
|
||||
sb.append("<a action=\"bypass -h admin_script_load " + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
|
||||
}
|
||||
}
|
||||
replace = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
path = new File(ScriptEngineManager.SCRIPT_FOLDER.toFile(), dir);
|
||||
if (!path.isDirectory())
|
||||
{
|
||||
activeChar.sendMessage("Wrong path.");
|
||||
return;
|
||||
}
|
||||
currentPath = dir;
|
||||
final boolean questReducedNames = currentPath.equalsIgnoreCase("quests");
|
||||
final StringBuilder sb = new StringBuilder(200);
|
||||
sb.append("<a action=\"bypass -h admin_script_dir " + getUpPath(currentPath) + "\">..</a><br1>");
|
||||
final String[] children = path.list();
|
||||
Arrays.sort(children);
|
||||
for (String c : children)
|
||||
{
|
||||
final File n = new File(path, c);
|
||||
if (n.isHidden() || n.getName().startsWith("."))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (n.isDirectory())
|
||||
{
|
||||
sb.append("<a action=\"bypass -h admin_script_dir " + currentPath + "/" + c + "\">" + (questReducedNames ? getQuestName(c) : c) + "</a><br1>");
|
||||
}
|
||||
else if (c.endsWith(".java") || c.endsWith(".py"))
|
||||
{
|
||||
sb.append("<a action=\"bypass -h admin_script_load " + currentPath + "/" + c + "\"><font color=\"LEVEL\">" + c + "</font></a><br1>");
|
||||
}
|
||||
}
|
||||
replace = sb.toString();
|
||||
if (questReducedNames)
|
||||
{
|
||||
currentPath += " (limited list - HTML too long)";
|
||||
}
|
||||
}
|
||||
|
||||
if (replace.length() > 17200)
|
||||
{
|
||||
replace = replace.substring(0, 17200); // packetlimit
|
||||
}
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/scriptdirectory.htm");
|
||||
html.replace("%path%", currentPath);
|
||||
html.replace("%list%", replace);
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private String getUpPath(String full)
|
||||
{
|
||||
final int index = full.lastIndexOf("/");
|
||||
if (index == -1)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return full.substring(0, index);
|
||||
}
|
||||
|
||||
private String getQuestName(String full)
|
||||
{
|
||||
return full.split("_")[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,301 +1,315 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.WallData;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminReload implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_reload"
|
||||
};
|
||||
|
||||
private static final String RELOAD_USAGE = "Usage: //reload <config|access|npc|quest [quest_id|quest_name]|walker|htm[l] [file|directory]|multisell|buylist|teleport|skill|item|door|effect|handler|enchant>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
if (actualCommand.equalsIgnoreCase("admin_reload"))
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "reload.htm");
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String type = st.nextToken();
|
||||
switch (type.toLowerCase())
|
||||
{
|
||||
case "config":
|
||||
{
|
||||
Config.load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Configs.");
|
||||
break;
|
||||
}
|
||||
case "access":
|
||||
{
|
||||
AdminData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Access.");
|
||||
break;
|
||||
}
|
||||
case "npc":
|
||||
{
|
||||
NpcData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Npcs.");
|
||||
break;
|
||||
}
|
||||
case "quest":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String value = st.nextToken();
|
||||
if (!Util.isDigit(value))
|
||||
{
|
||||
QuestManager.getInstance().reload(value);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest Name:" + value + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int questId = Integer.parseInt(value);
|
||||
QuestManager.getInstance().reload(questId);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest ID:" + questId + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
activeChar.sendMessage("All scripts have been reloaded.");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quests.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "walker":
|
||||
{
|
||||
WalkingManager.getInstance().load();
|
||||
activeChar.sendMessage("All walkers have been reloaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Walkers.");
|
||||
break;
|
||||
}
|
||||
case "htm":
|
||||
case "html":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String path = st.nextToken();
|
||||
final File file = new File(Config.DATAPACK_ROOT, "html/" + path);
|
||||
if (file.exists())
|
||||
{
|
||||
HtmCache.getInstance().reload(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htm File:" + file.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("File or Directory does not exist.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HtmCache.getInstance().reload();
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htms.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "multisell":
|
||||
{
|
||||
MultisellData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Multisells.");
|
||||
break;
|
||||
}
|
||||
case "buylist":
|
||||
{
|
||||
BuyListData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Buylists.");
|
||||
break;
|
||||
}
|
||||
case "teleport":
|
||||
{
|
||||
TeleportLocationTable.getInstance().reloadAll();
|
||||
TeleportersData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Teleports.");
|
||||
break;
|
||||
}
|
||||
case "skill":
|
||||
{
|
||||
SkillData.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Skills.");
|
||||
break;
|
||||
}
|
||||
case "item":
|
||||
{
|
||||
ItemTable.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Items.");
|
||||
break;
|
||||
}
|
||||
case "door":
|
||||
{
|
||||
DoorData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Doors.");
|
||||
break;
|
||||
}
|
||||
case "wall":
|
||||
{
|
||||
WallData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Walls.");
|
||||
break;
|
||||
}
|
||||
case "zone":
|
||||
{
|
||||
ZoneManager.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Zones.");
|
||||
break;
|
||||
}
|
||||
case "cw":
|
||||
{
|
||||
CursedWeaponsManager.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Cursed Weapons.");
|
||||
break;
|
||||
}
|
||||
case "crest":
|
||||
{
|
||||
CrestTable.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Crests.");
|
||||
break;
|
||||
}
|
||||
case "effect":
|
||||
{
|
||||
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/EffectMasterHandler.java");
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Effects.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
activeChar.sendMessage("There was an error while loading handlers.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "handler":
|
||||
{
|
||||
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/MasterHandler.java");
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Handlers.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
activeChar.sendMessage("There was an error while loading handlers.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enchant":
|
||||
{
|
||||
EnchantItemGroupsData.getInstance().load();
|
||||
EnchantItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item enchanting data.");
|
||||
break;
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
TransformData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded transform data.");
|
||||
break;
|
||||
}
|
||||
case "crystalizable":
|
||||
{
|
||||
ItemCrystalizationData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
|
||||
break;
|
||||
}
|
||||
case "primeshop":
|
||||
{
|
||||
PrimeShopData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded L2 Store data.");
|
||||
break;
|
||||
}
|
||||
case "ability":
|
||||
{
|
||||
AbilityPointsData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded ability points data.");
|
||||
break;
|
||||
}
|
||||
case "appearance":
|
||||
{
|
||||
AppearanceItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded appearance item data.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("WARNING: There are several known issues regarding this feature. Reloading server data during runtime is STRONGLY NOT RECOMMENDED for live servers, just for developing environments.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AppearanceItemData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ArmorSetsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.EnchantItemGroupsData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.FishingData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.ItemCrystalizationData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.OptionData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SayuneData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminReload implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(AdminReload.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_reload"
|
||||
};
|
||||
|
||||
private static final String RELOAD_USAGE = "Usage: //reload <config|access|npc|quest [quest_id|quest_name]|walker|htm[l] [file|directory]|multisell|buylist|teleport|skill|item|door|effect|handler|enchant|options|fishing>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
if (actualCommand.equalsIgnoreCase("admin_reload"))
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "reload.htm");
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String type = st.nextToken();
|
||||
switch (type.toLowerCase())
|
||||
{
|
||||
case "config":
|
||||
{
|
||||
Config.load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Configs.");
|
||||
break;
|
||||
}
|
||||
case "access":
|
||||
{
|
||||
AdminData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Access.");
|
||||
break;
|
||||
}
|
||||
case "npc":
|
||||
{
|
||||
NpcData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Npcs.");
|
||||
break;
|
||||
}
|
||||
case "quest":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String value = st.nextToken();
|
||||
if (!Util.isDigit(value))
|
||||
{
|
||||
QuestManager.getInstance().reload(value);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest Name:" + value + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int questId = Integer.parseInt(value);
|
||||
QuestManager.getInstance().reload(questId);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest ID:" + questId + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
activeChar.sendMessage("All scripts have been reloaded.");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quests.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "walker":
|
||||
{
|
||||
WalkingManager.getInstance().load();
|
||||
activeChar.sendMessage("All walkers have been reloaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Walkers.");
|
||||
break;
|
||||
}
|
||||
case "htm":
|
||||
case "html":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String path = st.nextToken();
|
||||
final File file = new File(Config.DATAPACK_ROOT, "data/html/" + path);
|
||||
if (file.exists())
|
||||
{
|
||||
HtmCache.getInstance().reload(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htm File:" + file.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("File or Directory does not exist.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HtmCache.getInstance().reload();
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htms.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "multisell":
|
||||
{
|
||||
MultisellData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Multisells.");
|
||||
break;
|
||||
}
|
||||
case "buylist":
|
||||
{
|
||||
BuyListData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Buylists.");
|
||||
break;
|
||||
}
|
||||
case "teleport":
|
||||
{
|
||||
TeleportLocationTable.getInstance().reloadAll();
|
||||
TeleportersData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Teleports.");
|
||||
break;
|
||||
}
|
||||
case "skill":
|
||||
{
|
||||
SkillData.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Skills.");
|
||||
break;
|
||||
}
|
||||
case "item":
|
||||
{
|
||||
ItemTable.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Items.");
|
||||
break;
|
||||
}
|
||||
case "door":
|
||||
{
|
||||
DoorData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Doors.");
|
||||
break;
|
||||
}
|
||||
case "zone":
|
||||
{
|
||||
ZoneManager.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Zones.");
|
||||
break;
|
||||
}
|
||||
case "cw":
|
||||
{
|
||||
CursedWeaponsManager.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Cursed Weapons.");
|
||||
break;
|
||||
}
|
||||
case "crest":
|
||||
{
|
||||
CrestTable.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Crests.");
|
||||
break;
|
||||
}
|
||||
case "effect":
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeEffectMasterHandler();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded effect master handler.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Failed executing effect master handler!", e);
|
||||
activeChar.sendMessage("Error reloading effect master handler!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "handler":
|
||||
{
|
||||
try
|
||||
{
|
||||
ScriptEngineManager.getInstance().executeMasterHandler();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded master handler.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "Failed executing master handler!", e);
|
||||
activeChar.sendMessage("Error reloading master handler!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enchant":
|
||||
{
|
||||
EnchantItemGroupsData.getInstance().load();
|
||||
EnchantItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item enchanting data.");
|
||||
break;
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
TransformData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded transform data.");
|
||||
break;
|
||||
}
|
||||
case "crystalizable":
|
||||
{
|
||||
ItemCrystalizationData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
|
||||
break;
|
||||
}
|
||||
case "ability":
|
||||
{
|
||||
AbilityPointsData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded ability points data.");
|
||||
break;
|
||||
}
|
||||
case "appearance":
|
||||
{
|
||||
AppearanceItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded appearance item data.");
|
||||
break;
|
||||
}
|
||||
case "sayune":
|
||||
{
|
||||
SayuneData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Sayune data.");
|
||||
break;
|
||||
}
|
||||
case "sets":
|
||||
{
|
||||
ArmorSetsData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Armor sets data.");
|
||||
break;
|
||||
}
|
||||
case "options":
|
||||
{
|
||||
OptionData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Options data.");
|
||||
break;
|
||||
}
|
||||
case "fishing":
|
||||
{
|
||||
FishingData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Fishing data.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("WARNING: There are several known issues regarding this feature. Reloading server data during runtime is STRONGLY NOT RECOMMENDED for live servers, just for developing environments.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +1,107 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.1.2.6.2.3 $ $Date: 2005/04/11 10:05:59 $
|
||||
*/
|
||||
public class AdminRepairChar implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRepairChar.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_restore",
|
||||
"admin_repair"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
handleRepair(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleRepair(String command)
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName = parts[1];
|
||||
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
try (PreparedStatement ps = con.prepareStatement(cmd))
|
||||
{
|
||||
ps.setString(1, playerName);
|
||||
ps.execute();
|
||||
}
|
||||
|
||||
final int objId = CharNameTable.getInstance().getIdByName(playerName);
|
||||
if (objId != 0)
|
||||
{
|
||||
// Delete player's shortcuts.
|
||||
try (PreparedStatement ps = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?"))
|
||||
{
|
||||
ps.setInt(1, objId);
|
||||
ps.execute();
|
||||
}
|
||||
// Move all items to the inventory.
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?"))
|
||||
{
|
||||
ps.setInt(1, objId);
|
||||
ps.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Could not repair char:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - delete = deletes target
|
||||
* @version $Revision: 1.1.2.6.2.3 $ $Date: 2005/04/11 10:05:59 $
|
||||
*/
|
||||
public class AdminRepairChar implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRepairChar.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_restore",
|
||||
"admin_repair"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
handleRepair(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleRepair(String command)
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if (parts.length != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(cmd);
|
||||
statement.setString(1, parts[1]);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
statement = con.prepareStatement("SELECT charId FROM characters where char_name=?");
|
||||
statement.setString(1, parts[1]);
|
||||
final ResultSet rset = statement.executeQuery();
|
||||
int objId = 0;
|
||||
if (rset.next())
|
||||
{
|
||||
objId = rset.getInt(1);
|
||||
}
|
||||
|
||||
rset.close();
|
||||
statement.close();
|
||||
|
||||
if (objId == 0)
|
||||
{
|
||||
con.close();
|
||||
return;
|
||||
}
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = con.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
// connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = con.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not repair char:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,195 +1,195 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - res = resurrects target L2Character
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminRes implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_res",
|
||||
"admin_res_monster"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_res "))
|
||||
{
|
||||
handleRes(activeChar, command.split(" ")[1]);
|
||||
}
|
||||
else if (command.equals("admin_res"))
|
||||
{
|
||||
handleRes(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_res_monster "))
|
||||
{
|
||||
handleNonPlayerRes(activeChar, command.split(" ")[1]);
|
||||
}
|
||||
else if (command.equals("admin_res_monster"))
|
||||
{
|
||||
handleNonPlayerRes(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleRes(L2PcInstance activeChar)
|
||||
{
|
||||
handleRes(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleRes(L2PcInstance activeChar, String resParam)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
|
||||
if (resParam != null)
|
||||
{
|
||||
// Check if a player name was specified as a param.
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(resParam);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, check if the param was a radius.
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(resParam);
|
||||
|
||||
for (L2PcInstance knownPlayer : activeChar.getKnownList().getKnownPlayersInRadius(radius))
|
||||
{
|
||||
doResurrect(knownPlayer);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Resurrected all players within a " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid player name or radius.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
|
||||
if (obj instanceof L2ControllableMobInstance)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") resurrected character " + obj.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar)
|
||||
{
|
||||
handleNonPlayerRes(activeChar, "");
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar, String radiusStr)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
|
||||
try
|
||||
{
|
||||
int radius = 0;
|
||||
|
||||
if (!radiusStr.isEmpty())
|
||||
{
|
||||
radius = Integer.parseInt(radiusStr);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
|
||||
{
|
||||
doResurrect(knownChar);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Resurrected all non-players within a " + radius + " unit radius.");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((obj instanceof L2PcInstance) || (obj instanceof L2ControllableMobInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
}
|
||||
|
||||
private void doResurrect(L2Character targetChar)
|
||||
{
|
||||
if (!targetChar.isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is a player, then restore the XP lost on death.
|
||||
if (targetChar instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) targetChar).restoreExp(100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecayTaskManager.getInstance().cancel(targetChar);
|
||||
}
|
||||
|
||||
targetChar.doRevive();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - res = resurrects target L2Character
|
||||
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminRes implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminRes.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_res",
|
||||
"admin_res_monster"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_res "))
|
||||
{
|
||||
handleRes(activeChar, command.split(" ")[1]);
|
||||
}
|
||||
else if (command.equals("admin_res"))
|
||||
{
|
||||
handleRes(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_res_monster "))
|
||||
{
|
||||
handleNonPlayerRes(activeChar, command.split(" ")[1]);
|
||||
}
|
||||
else if (command.equals("admin_res_monster"))
|
||||
{
|
||||
handleNonPlayerRes(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleRes(L2PcInstance activeChar)
|
||||
{
|
||||
handleRes(activeChar, null);
|
||||
}
|
||||
|
||||
private void handleRes(L2PcInstance activeChar, String resParam)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
|
||||
if (resParam != null)
|
||||
{
|
||||
// Check if a player name was specified as a param.
|
||||
final L2PcInstance plyr = L2World.getInstance().getPlayer(resParam);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, check if the param was a radius.
|
||||
try
|
||||
{
|
||||
final int radius = Integer.parseInt(resParam);
|
||||
|
||||
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, knownPlayer ->
|
||||
{
|
||||
doResurrect(knownPlayer);
|
||||
});
|
||||
|
||||
activeChar.sendMessage("Resurrected all players within a " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid player name or radius.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
|
||||
if (obj instanceof L2ControllableMobInstance)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.finer("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") resurrected character " + obj.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar)
|
||||
{
|
||||
handleNonPlayerRes(activeChar, "");
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar, String radiusStr)
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
|
||||
try
|
||||
{
|
||||
int radius = 0;
|
||||
|
||||
if (!radiusStr.isEmpty())
|
||||
{
|
||||
radius = Integer.parseInt(radiusStr);
|
||||
|
||||
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, knownChar ->
|
||||
{
|
||||
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
|
||||
{
|
||||
doResurrect(knownChar);
|
||||
}
|
||||
});
|
||||
|
||||
activeChar.sendMessage("Resurrected all non-players within a " + radius + " unit radius.");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((obj instanceof L2PcInstance) || (obj instanceof L2ControllableMobInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
}
|
||||
|
||||
private void doResurrect(L2Character targetChar)
|
||||
{
|
||||
if (!targetChar.isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is a player, then restore the XP lost on death.
|
||||
if (targetChar instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) targetChar).restoreExp(100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecayTaskManager.getInstance().cancel(targetChar);
|
||||
}
|
||||
|
||||
targetChar.doRevive();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,170 +1,151 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class AdminRide implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_ride_horse",
|
||||
"admin_ride_bike",
|
||||
"admin_ride_wyvern",
|
||||
"admin_ride_strider",
|
||||
"admin_ride_guardian",
|
||||
"admin_ride_lion",
|
||||
"admin_ride_wolf",
|
||||
"admin_unride",
|
||||
};
|
||||
private int _petRideId;
|
||||
|
||||
private static final int PURPLE_MANED_HORSE_TRANSFORMATION_ID = 106;
|
||||
private static final int LION_TRANSFORMATION_ID = 109;
|
||||
private static final int JET_BIKE_TRANSFORMATION_ID = 20001;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final L2PcInstance player = getRideTarget(activeChar);
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_ride"))
|
||||
{
|
||||
if (player.isMounted() || player.hasSummon())
|
||||
{
|
||||
activeChar.sendMessage("Target already have a summon.");
|
||||
return false;
|
||||
}
|
||||
if (command.startsWith("admin_ride_wyvern"))
|
||||
{
|
||||
_petRideId = 12621;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_strider"))
|
||||
{
|
||||
_petRideId = 12526;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_wolf"))
|
||||
{
|
||||
_petRideId = 16041;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_guardian"))
|
||||
{
|
||||
_petRideId = 16068;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_horse")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformData.getInstance().transformPlayer(PURPLE_MANED_HORSE_TRANSFORMATION_ID, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_lion")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformData.getInstance().transformPlayer(LION_TRANSFORMATION_ID, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_bike")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformData.getInstance().transformPlayer(JET_BIKE_TRANSFORMATION_ID, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Command '" + command + "' not recognized");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.mount(_petRideId, 0, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_unride"))
|
||||
{
|
||||
if (player.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
else if (player.getTransformationId() == LION_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
else if (player.getTransformationId() == JET_BIKE_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.dismount();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private L2PcInstance getRideTarget(L2PcInstance activeChar)
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
|
||||
if ((activeChar.getTarget() == null) || (activeChar.getTarget().getObjectId() == activeChar.getObjectId()) || !(activeChar.getTarget() instanceof L2PcInstance))
|
||||
{
|
||||
player = activeChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
player = (L2PcInstance) activeChar.getTarget();
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author
|
||||
*/
|
||||
public class AdminRide implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_ride_horse",
|
||||
"admin_ride_bike",
|
||||
"admin_ride_wyvern",
|
||||
"admin_ride_strider",
|
||||
"admin_unride_wyvern",
|
||||
"admin_unride_strider",
|
||||
"admin_unride",
|
||||
"admin_ride_wolf",
|
||||
"admin_unride_wolf",
|
||||
};
|
||||
private int _petRideId;
|
||||
|
||||
private static final int PURPLE_MANED_HORSE_TRANSFORMATION_ID = 106;
|
||||
|
||||
private static final int JET_BIKE_TRANSFORMATION_ID = 20001;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final L2PcInstance player = getRideTarget(activeChar);
|
||||
if (player == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_ride"))
|
||||
{
|
||||
if (player.isMounted() || player.hasSummon())
|
||||
{
|
||||
activeChar.sendMessage("Target already have a summon.");
|
||||
return false;
|
||||
}
|
||||
if (command.startsWith("admin_ride_wyvern"))
|
||||
{
|
||||
_petRideId = 12621;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_strider"))
|
||||
{
|
||||
_petRideId = 12526;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_wolf"))
|
||||
{
|
||||
_petRideId = 16041;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_horse")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.transform(PURPLE_MANED_HORSE_TRANSFORMATION_ID, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_bike")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.transform(JET_BIKE_TRANSFORMATION_ID, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Command '" + command + "' not recognized");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.mount(_petRideId, 0, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_unride"))
|
||||
{
|
||||
if (player.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
if (player.getTransformationId() == JET_BIKE_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
player.dismount();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private L2PcInstance getRideTarget(L2PcInstance activeChar)
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
|
||||
if ((activeChar.getTarget() == null) || (activeChar.getTarget().getObjectId() == activeChar.getObjectId()) || !(activeChar.getTarget() instanceof L2PcInstance))
|
||||
{
|
||||
player = activeChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
player = (L2PcInstance) activeChar.getTarget();
|
||||
}
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,150 +1,216 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminScan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_scan",
|
||||
"admin_deleteNpcByObjectId"
|
||||
};
|
||||
|
||||
private static final int DEFAULT_RADIUS = 500;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_scan":
|
||||
{
|
||||
int radius = DEFAULT_RADIUS;
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //scan [radius]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sendNpcList(activeChar, radius);
|
||||
break;
|
||||
}
|
||||
case "admin_deletenpcbyobjectid":
|
||||
{
|
||||
if (!st.hasMoreElements())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //deletenpcbyobjectid <object_id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final int objectId = Integer.parseInt(st.nextToken());
|
||||
|
||||
final L2Object target = L2World.getInstance().findObject(objectId);
|
||||
final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
|
||||
if (npc == null)
|
||||
{
|
||||
activeChar.sendMessage("NPC does not exist or object_id does not belong to an NPC");
|
||||
return false;
|
||||
}
|
||||
|
||||
npc.deleteMe();
|
||||
|
||||
final L2Spawn spawn = npc.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage(npc.getName() + " have been deleted.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("object_id must be a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sendNpcList(activeChar, DEFAULT_RADIUS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendNpcList(L2PcInstance activeChar, int radius)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/scan.htm");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (L2Character character : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (character instanceof L2Npc)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td width=\"54\">" + character.getId() + "</td>");
|
||||
sb.append("<td width=\"54\">" + character.getName() + "</td>");
|
||||
sb.append("<td width=\"54\">" + Math.round(activeChar.calculateDistance(character, false, false)) + "</td>");
|
||||
sb.append("<td width=\"54\"><a action=\"bypass -h admin_deleteNpcByObjectId " + character.getObjectId() + "\"><font color=\"LEVEL\">Delete</font></a></td>");
|
||||
sb.append("<td width=\"54\"><a action=\"bypass -h admin_move_to " + character.getX() + " " + character.getY() + " " + character.getZ() + "\"><font color=\"LEVEL\">Go to</font></a></td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
}
|
||||
html.replace("%data%", sb.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.html.PageBuilder;
|
||||
import com.l2jmobius.gameserver.model.html.PageResult;
|
||||
import com.l2jmobius.gameserver.model.html.formatters.BypassParserFormatter;
|
||||
import com.l2jmobius.gameserver.model.html.pagehandlers.NextPrevPageHandler;
|
||||
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.BypassBuilder;
|
||||
import com.l2jmobius.gameserver.util.BypassParser;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminScan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String SPACE = " ";
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_scan",
|
||||
"admin_deleteNpcByObjectId"
|
||||
};
|
||||
|
||||
private static final int DEFAULT_RADIUS = 1000;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_scan":
|
||||
{
|
||||
processBypass(activeChar, new BypassParser(command));
|
||||
break;
|
||||
}
|
||||
case "admin_deletenpcbyobjectid":
|
||||
{
|
||||
if (!st.hasMoreElements())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //deletenpcbyobjectid objectId=<object_id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final BypassParser parser = new BypassParser(command);
|
||||
try
|
||||
{
|
||||
final int objectId = parser.getInt("objectId", 0);
|
||||
if (objectId == 0)
|
||||
{
|
||||
activeChar.sendMessage("objectId is not set!");
|
||||
}
|
||||
|
||||
final L2Object target = L2World.getInstance().findObject(objectId);
|
||||
final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
|
||||
if (npc == null)
|
||||
{
|
||||
activeChar.sendMessage("NPC does not exist or object_id does not belong to an NPC");
|
||||
return false;
|
||||
}
|
||||
|
||||
npc.deleteMe();
|
||||
|
||||
final L2Spawn spawn = npc.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (DBSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
DBSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage(npc.getName() + " have been deleted.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("object_id must be a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
processBypass(activeChar, parser);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processBypass(L2PcInstance activeChar, BypassParser parser)
|
||||
{
|
||||
final int id = parser.getInt("id", 0);
|
||||
final String name = parser.getString("name", null);
|
||||
final int radius = parser.getInt("radius", parser.getInt("range", DEFAULT_RADIUS));
|
||||
final int page = parser.getInt("page", 0);
|
||||
|
||||
final Predicate<L2Npc> condition;
|
||||
if (id > 0)
|
||||
{
|
||||
condition = npc -> npc.getId() == id;
|
||||
}
|
||||
else if (name != null)
|
||||
{
|
||||
condition = npc -> npc.getName().toLowerCase().startsWith(name.toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
condition = npc -> true;
|
||||
}
|
||||
|
||||
sendNpcList(activeChar, radius, page, condition, parser);
|
||||
}
|
||||
|
||||
private BypassBuilder createBypassBuilder(BypassParser parser, String bypass)
|
||||
{
|
||||
final int id = parser.getInt("id", 0);
|
||||
final String name = parser.getString("name", null);
|
||||
final int radius = parser.getInt("radius", parser.getInt("range", DEFAULT_RADIUS));
|
||||
final BypassBuilder builder = new BypassBuilder(bypass);
|
||||
|
||||
if (id > 0)
|
||||
{
|
||||
builder.addParam("id", id);
|
||||
}
|
||||
else if (name != null)
|
||||
{
|
||||
builder.addParam("name", name);
|
||||
}
|
||||
|
||||
if (radius > DEFAULT_RADIUS)
|
||||
{
|
||||
builder.addParam("radius", radius);
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
private void sendNpcList(L2PcInstance activeChar, int radius, int page, Predicate<L2Npc> condition, BypassParser parser)
|
||||
{
|
||||
final BypassBuilder bypassParser = createBypassBuilder(parser, "bypass -h admin_scan");
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/scan.htm");
|
||||
|
||||
//@formatter:off
|
||||
final PageResult result = PageBuilder.newBuilder(L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, radius, condition), 15, bypassParser.toString())
|
||||
.currentPage(page)
|
||||
.pageHandler(NextPrevPageHandler.INSTANCE)
|
||||
.formatter(BypassParserFormatter.INSTANCE)
|
||||
.style(ButtonsStyle.INSTANCE)
|
||||
.bodyHandler((pages, character, sb) ->
|
||||
{
|
||||
final BypassBuilder builder = createBypassBuilder(parser, "bypass -h admin_deleteNpcByObjectId");
|
||||
final String npcName = character.getName();
|
||||
builder.addParam("page", page);
|
||||
builder.addParam("objectId", character.getObjectId());
|
||||
|
||||
sb.append("<tr>");
|
||||
sb.append("<td width=\"45\">").append(character.getId()).append("</td>");
|
||||
sb.append("<td><a action=\"bypass -h admin_move_to ").append(character.getX()).append(SPACE).append(character.getY()).append(SPACE).append(character.getZ()).append("\">").append(npcName.isEmpty() ? "No name NPC" : npcName).append("</a></td>");
|
||||
sb.append("<td width=\"60\">").append(Util.formatAdena(Math.round(activeChar.calculateDistance(character, false, false)))).append("</td>");
|
||||
sb.append("<td width=\"54\"><a action=\"").append(builder.toStringBuilder()).append("\"><font color=\"LEVEL\">Delete</font></a></td>");
|
||||
sb.append("</tr>");
|
||||
}).build();
|
||||
//@formatter:on
|
||||
|
||||
if (result.getPages() > 0)
|
||||
{
|
||||
html.replace("%pages%", "<center><table width=\"100%\" cellspacing=0><tr>" + result.getPagerTemplate() + "</tr></table></center>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%pages%", "");
|
||||
}
|
||||
|
||||
html.replace("%data%", result.getBodyTemplate().toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.l2jmobius.gameserver.GameServer;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
@@ -54,7 +55,7 @@ public class AdminServerInfo implements IAdminCommandHandler
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
final Runtime RunTime = Runtime.getRuntime();
|
||||
final int mb = 1024 * 1024;
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/serverinfo.htm"));
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/serverinfo.htm"));
|
||||
|
||||
html.replace("%os_name%", System.getProperty("os.name"));
|
||||
html.replace("%os_ver%", System.getProperty("os.version"));
|
||||
@@ -117,7 +118,7 @@ public class AdminServerInfo implements IAdminCommandHandler
|
||||
{
|
||||
case "ALL":
|
||||
{
|
||||
return L2World.getInstance().getAllPlayersCount();
|
||||
return L2World.getInstance().getPlayers().size();
|
||||
}
|
||||
case "OFF_TRADE":
|
||||
{
|
||||
@@ -136,7 +137,7 @@ public class AdminServerInfo implements IAdminCommandHandler
|
||||
case "GM":
|
||||
{
|
||||
int onlineGMcount = 0;
|
||||
for (L2PcInstance gm : L2World.getInstance().getAllGMs())
|
||||
for (L2PcInstance gm : AdminData.getInstance().getAllGms(true))
|
||||
{
|
||||
if ((gm != null) && gm.isOnline() && (gm.getClient() != null) && !gm.getClient().isDetached())
|
||||
{
|
||||
|
||||
@@ -1,98 +1,98 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.buylist.L2BuyList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.BuyList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBuySellList;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* <ul>
|
||||
* <li>gmshop = shows menu</li>
|
||||
* <li>buy id = shows shop with respective id</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class AdminShop implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminShop.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_buy",
|
||||
"admin_gmshop"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_buy"))
|
||||
{
|
||||
try
|
||||
{
|
||||
handleBuyRequest(activeChar, command.substring(10));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please specify buylist.");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_gmshop"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "gmshops.htm");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleBuyRequest(L2PcInstance activeChar, String command)
|
||||
{
|
||||
int val = -1;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("admin buylist failed:" + command);
|
||||
}
|
||||
|
||||
final L2BuyList buyList = BuyListData.getInstance().getBuyList(val);
|
||||
|
||||
if (buyList != null)
|
||||
{
|
||||
activeChar.sendPacket(new BuyList(buyList, activeChar.getAdena(), 0));
|
||||
activeChar.sendPacket(new ExBuySellList(activeChar, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("no buylist with id:" + val);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.buylist.L2BuyList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.BuyList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExBuySellList;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* <ul>
|
||||
* <li>gmshop = shows menu</li>
|
||||
* <li>buy id = shows shop with respective id</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class AdminShop implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminShop.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_buy",
|
||||
"admin_gmshop"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_buy"))
|
||||
{
|
||||
try
|
||||
{
|
||||
handleBuyRequest(activeChar, command.substring(10));
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please specify buylist.");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_gmshop"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "gmshops.htm");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleBuyRequest(L2PcInstance activeChar, String command)
|
||||
{
|
||||
int val = -1;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("admin buylist failed:" + command);
|
||||
}
|
||||
|
||||
final L2BuyList buyList = BuyListData.getInstance().getBuyList(val);
|
||||
|
||||
if (buyList != null)
|
||||
{
|
||||
activeChar.sendPacket(new BuyList(buyList, activeChar.getAdena(), 0));
|
||||
activeChar.sendPacket(new ExBuySellList(activeChar, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("no buylist with id:" + val);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,384 +1,387 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.quest.State;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowQuestMark;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.QuestList;
|
||||
|
||||
/**
|
||||
* TODO: Rework and cleanup.
|
||||
* @author Korvin, Zoey76
|
||||
*/
|
||||
public class AdminShowQuests implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminShowQuests.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_charquestmenu",
|
||||
"admin_setcharquest"
|
||||
};
|
||||
|
||||
private static final String[] _states =
|
||||
{
|
||||
"CREATED",
|
||||
"STARTED",
|
||||
"COMPLETED"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] cmdParams = command.split(" ");
|
||||
L2PcInstance target = null;
|
||||
L2Object targetObject = null;
|
||||
final String[] val = new String[4];
|
||||
val[0] = null;
|
||||
|
||||
if (cmdParams.length > 1)
|
||||
{
|
||||
target = L2World.getInstance().getPlayer(cmdParams[1]);
|
||||
if (cmdParams.length > 2)
|
||||
{
|
||||
if (cmdParams[2].equals("0"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Start";
|
||||
}
|
||||
if (cmdParams[2].equals("1"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Started";
|
||||
}
|
||||
if (cmdParams[2].equals("2"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Completed";
|
||||
}
|
||||
if (cmdParams[2].equals("3"))
|
||||
{
|
||||
val[0] = "full";
|
||||
}
|
||||
if (cmdParams[2].indexOf("_") != -1)
|
||||
{
|
||||
val[0] = "name";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
if ((cmdParams.length > 3) && cmdParams[3].equals("custom"))
|
||||
{
|
||||
val[0] = "custom";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject = activeChar.getTarget();
|
||||
|
||||
if ((targetObject != null) && targetObject.isPlayer())
|
||||
{
|
||||
target = targetObject.getActingPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_charquestmenu"))
|
||||
{
|
||||
if (val[0] != null)
|
||||
{
|
||||
showQuestMenu(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
showFirstQuestMenu(target, activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setcharquest"))
|
||||
{
|
||||
if (cmdParams.length >= 5)
|
||||
{
|
||||
val[0] = cmdParams[2];
|
||||
val[1] = cmdParams[3];
|
||||
val[2] = cmdParams[4];
|
||||
if (cmdParams.length == 6)
|
||||
{
|
||||
val[3] = cmdParams[5];
|
||||
}
|
||||
setQuestVar(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void showFirstQuestMenu(L2PcInstance target, L2PcInstance actor)
|
||||
{
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><body><table width=270><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>Player: " + target.getName() + "</center></td><td width=45><button value=\"Back\" action=\"bypass -h admin_admin6\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
final int ID = target.getObjectId();
|
||||
|
||||
replyMSG.append("Quest Menu for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")<br><center>");
|
||||
replyMSG.append("<table width=250><tr><td><button value=\"CREATED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 0\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"STARTED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 1\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"COMPLETED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 2\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><br><button value=\"All\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 3\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><br><br>Manual Edit by Quest number:<br></td></tr>");
|
||||
replyMSG.append("<tr><td><edit var=\"qn\" width=50 height=15><br><button value=\"Edit\" action=\"bypass -h admin_charquestmenu " + target.getName() + " $qn custom\" width=50 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table></center></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
actor.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
// TODO(Zoey76): Refactor this into smaller methods and separate database access logic from HTML creation.
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
final int ID = target.getObjectId();
|
||||
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><body>");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
switch (val[0])
|
||||
{
|
||||
case "full":
|
||||
{
|
||||
replyMSG.append("<table width=250><tr><td>Full Quest List for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")</td></tr>");
|
||||
req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' AND var='<state>' ORDER by name");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table></body></html>");
|
||||
break;
|
||||
}
|
||||
case "name":
|
||||
{
|
||||
final QuestState qs = target.getQuestState(val[1]);
|
||||
final String state = (qs != null) ? _states[qs.getState()] : "CREATED";
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + val[1] + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + val[1] + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
final String var_name = rs.getString(1);
|
||||
if (var_name.equals("<state>"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 1\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 0\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state DELETE\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
replyMSG.append("</center></body></html>");
|
||||
break;
|
||||
}
|
||||
case "var":
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quests with state: <font color=\"LEVEL\">" + val[1] + "</font><br>");
|
||||
replyMSG.append("<table width=250>");
|
||||
req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' and var='<state>' and value='" + val[1] + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table></body></html>");
|
||||
break;
|
||||
}
|
||||
case "custom":
|
||||
{
|
||||
boolean exqdb = true;
|
||||
boolean exqch = true;
|
||||
final int qnumber = Integer.parseInt(val[1]);
|
||||
String state = null;
|
||||
String qname = null;
|
||||
QuestState qs = null;
|
||||
|
||||
final Quest quest = QuestManager.getInstance().getQuest(qnumber);
|
||||
if (quest != null)
|
||||
{
|
||||
qname = quest.getName();
|
||||
qs = target.getQuestState(qname);
|
||||
}
|
||||
else
|
||||
{
|
||||
exqdb = false;
|
||||
}
|
||||
|
||||
if (qs != null)
|
||||
{
|
||||
state = _states[qs.getState()];
|
||||
}
|
||||
else
|
||||
{
|
||||
exqch = false;
|
||||
state = "N/A";
|
||||
}
|
||||
|
||||
if (exqdb)
|
||||
{
|
||||
if (exqch)
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + qname + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
final String var_name = rs.getString(1);
|
||||
if (var_name.equals("<state>"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 1\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 0\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state DELETE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
replyMSG.append("</center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center>Start this Quest for player:<br>");
|
||||
replyMSG.append("<button value=\"Create Quest\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CREATE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
|
||||
replyMSG.append("<font color=\"ee0000\">Only for Unrepeateble quests:</font><br>");
|
||||
replyMSG.append("<button value=\"Create & Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CC\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
|
||||
replyMSG.append("</center></body></html>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<center><font color=\"ee0000\">Quest with number </font><font color=\"LEVEL\">" + qnumber + "</font><font color=\"ee0000\"> doesn't exist!</font></center></body></html>");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
actor.sendPacket(adminReply);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
actor.sendMessage("There was an error.");
|
||||
_log.warning(AdminShowQuests.class.getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setQuestVar(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
QuestState qs = target.getQuestState(val[0]);
|
||||
final String[] outval = new String[3];
|
||||
|
||||
if ("state".equals(val[1]))
|
||||
{
|
||||
switch (val[2])
|
||||
{
|
||||
case "COMPLETED":
|
||||
{
|
||||
qs.exitQuest("1".equals(val[3]));
|
||||
break;
|
||||
}
|
||||
case "DELETE":
|
||||
{
|
||||
Quest.deleteQuestInDb(qs, true);
|
||||
qs.exitQuest(true);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
break;
|
||||
}
|
||||
case "CREATE":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.setState(State.STARTED);
|
||||
qs.set("cond", "1");
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
case "CC":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.exitQuest(false);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val[2].equals("delete"))
|
||||
{
|
||||
qs.unset(val[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qs.set(val[1], val[2]);
|
||||
}
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
}
|
||||
actor.sendMessage("");
|
||||
outval[0] = "name";
|
||||
outval[1] = val[0];
|
||||
showQuestMenu(target, actor, outval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.gameserver.enums.QuestType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.quest.Quest;
|
||||
import com.l2jmobius.gameserver.model.quest.QuestState;
|
||||
import com.l2jmobius.gameserver.model.quest.State;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowQuestMark;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.QuestList;
|
||||
|
||||
/**
|
||||
* TODO: Rework and cleanup.
|
||||
* @author Korvin, Zoey76
|
||||
*/
|
||||
public class AdminShowQuests implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminShowQuests.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_charquestmenu",
|
||||
"admin_setcharquest"
|
||||
};
|
||||
|
||||
private static final String[] _states =
|
||||
{
|
||||
"CREATED",
|
||||
"STARTED",
|
||||
"COMPLETED"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] cmdParams = command.split(" ");
|
||||
L2PcInstance target = null;
|
||||
L2Object targetObject = null;
|
||||
final String[] val = new String[4];
|
||||
val[0] = null;
|
||||
|
||||
if (cmdParams.length > 1)
|
||||
{
|
||||
target = L2World.getInstance().getPlayer(cmdParams[1]);
|
||||
if (cmdParams.length > 2)
|
||||
{
|
||||
if (cmdParams[2].equals("0"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Start";
|
||||
}
|
||||
if (cmdParams[2].equals("1"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Started";
|
||||
}
|
||||
if (cmdParams[2].equals("2"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Completed";
|
||||
}
|
||||
if (cmdParams[2].equals("3"))
|
||||
{
|
||||
val[0] = "full";
|
||||
}
|
||||
if (cmdParams[2].indexOf("_") != -1)
|
||||
{
|
||||
val[0] = "name";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
if (cmdParams.length > 3)
|
||||
{
|
||||
if (cmdParams[3].equals("custom"))
|
||||
{
|
||||
val[0] = "custom";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject = activeChar.getTarget();
|
||||
|
||||
if ((targetObject != null) && targetObject.isPlayer())
|
||||
{
|
||||
target = targetObject.getActingPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_charquestmenu"))
|
||||
{
|
||||
if (val[0] != null)
|
||||
{
|
||||
showQuestMenu(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
showFirstQuestMenu(target, activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setcharquest"))
|
||||
{
|
||||
if (cmdParams.length >= 5)
|
||||
{
|
||||
val[0] = cmdParams[2];
|
||||
val[1] = cmdParams[3];
|
||||
val[2] = cmdParams[4];
|
||||
if (cmdParams.length == 6)
|
||||
{
|
||||
val[3] = cmdParams[5];
|
||||
}
|
||||
setQuestVar(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void showFirstQuestMenu(L2PcInstance target, L2PcInstance actor)
|
||||
{
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><body><table width=270><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>Player: " + target.getName() + "</center></td><td width=45><button value=\"Back\" action=\"bypass -h admin_admin6\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
final int ID = target.getObjectId();
|
||||
|
||||
replyMSG.append("Quest Menu for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")<br><center>");
|
||||
replyMSG.append("<table width=250><tr><td><button value=\"CREATED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 0\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"STARTED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 1\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"COMPLETED\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 2\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><br><button value=\"All\" action=\"bypass -h admin_charquestmenu " + target.getName() + " 3\" width=85 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><br><br>Manual Edit by Quest number:<br></td></tr>");
|
||||
replyMSG.append("<tr><td><edit var=\"qn\" width=50 height=15><br><button value=\"Edit\" action=\"bypass -h admin_charquestmenu " + target.getName() + " $qn custom\" width=50 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table></center></body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
actor.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private static void showQuestMenu(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
final int ID = target.getObjectId();
|
||||
|
||||
final StringBuilder replyMSG = new StringBuilder("<html><body>");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
|
||||
switch (val[0])
|
||||
{
|
||||
case "full":
|
||||
{
|
||||
replyMSG.append("<table width=250><tr><td>Full Quest List for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")</td></tr>");
|
||||
req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' AND var='<state>' ORDER by name");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table></body></html>");
|
||||
break;
|
||||
}
|
||||
case "name":
|
||||
{
|
||||
final QuestState qs = target.getQuestState(val[1]);
|
||||
final String state = (qs != null) ? _states[qs.getState()] : "CREATED";
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + val[1] + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + val[1] + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
final String var_name = rs.getString(1);
|
||||
if (var_name.equals("<state>"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 1\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 0\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state DELETE\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
replyMSG.append("</center></body></html>");
|
||||
break;
|
||||
}
|
||||
case "var":
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quests with state: <font color=\"LEVEL\">" + val[1] + "</font><br>");
|
||||
replyMSG.append("<table width=250>");
|
||||
req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' and var='<state>' and value='" + val[1] + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table></body></html>");
|
||||
break;
|
||||
}
|
||||
case "custom":
|
||||
{
|
||||
boolean exqdb = true;
|
||||
boolean exqch = true;
|
||||
final int qnumber = Integer.parseInt(val[1]);
|
||||
String state = null;
|
||||
String qname = null;
|
||||
QuestState qs = null;
|
||||
|
||||
final Quest quest = QuestManager.getInstance().getQuest(qnumber);
|
||||
if (quest != null)
|
||||
{
|
||||
qname = quest.getName();
|
||||
qs = target.getQuestState(qname);
|
||||
}
|
||||
else
|
||||
{
|
||||
exqdb = false;
|
||||
}
|
||||
|
||||
if (qs != null)
|
||||
{
|
||||
state = _states[qs.getState()];
|
||||
}
|
||||
else
|
||||
{
|
||||
exqch = false;
|
||||
state = "N/A";
|
||||
}
|
||||
|
||||
if (exqdb)
|
||||
{
|
||||
if (exqch)
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + qname + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
final String var_name = rs.getString(1);
|
||||
if (var_name.equals("<state>"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
|
||||
replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 1\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
|
||||
replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 0\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state DELETE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
replyMSG.append("</center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center>Start this Quest for player:<br>");
|
||||
replyMSG.append("<button value=\"Create Quest\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CREATE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
|
||||
replyMSG.append("<font color=\"ee0000\">Only for Unrepeateble quests:</font><br>");
|
||||
replyMSG.append("<button value=\"Create & Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CC\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
|
||||
replyMSG.append("</center></body></html>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<center><font color=\"ee0000\">Quest with number </font><font color=\"LEVEL\">" + qnumber + "</font><font color=\"ee0000\"> doesn't exist!</font></center></body></html>");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
actor.sendPacket(adminReply);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
actor.sendMessage("There was an error.");
|
||||
_log.warning(AdminShowQuests.class.getSimpleName() + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setQuestVar(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
QuestState qs = target.getQuestState(val[0]);
|
||||
final String[] outval = new String[3];
|
||||
|
||||
if (val[1].equals("state"))
|
||||
{
|
||||
switch (val[2])
|
||||
{
|
||||
case "COMPLETED":
|
||||
{
|
||||
qs.exitQuest((val[3].equals("1")) ? QuestType.REPEATABLE : QuestType.ONE_TIME);
|
||||
break;
|
||||
}
|
||||
case "DELETE":
|
||||
{
|
||||
Quest.deleteQuestInDb(qs, true);
|
||||
qs.exitQuest(QuestType.REPEATABLE);
|
||||
target.sendPacket(new QuestList(target));
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
break;
|
||||
}
|
||||
case "CREATE":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.setState(State.STARTED);
|
||||
qs.set("cond", "1");
|
||||
target.sendPacket(new QuestList(target));
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
case "CC":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.exitQuest(QuestType.ONE_TIME);
|
||||
target.sendPacket(new QuestList(target));
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val[2].equals("delete"))
|
||||
{
|
||||
qs.unset(val[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qs.set(val[1], val[2]);
|
||||
}
|
||||
target.sendPacket(new QuestList(target));
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
}
|
||||
actor.sendMessage("");
|
||||
outval[0] = "name";
|
||||
outval[1] = val[0];
|
||||
showQuestMenu(target, actor, outval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,128 +1,126 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.Shutdown;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - server_shutdown [sec] = shows menu or shuts down server in sec seconds
|
||||
* @version $Revision: 1.5.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminShutdown implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminShutdown.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_server_shutdown",
|
||||
"admin_server_restart",
|
||||
"admin_server_abort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_server_shutdown"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(22);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.valueOf(val), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_shutdown <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_restart"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(21);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.parseInt(val), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_restart <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_abort"))
|
||||
{
|
||||
serverAbort(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void sendHtmlForm(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
final int t = GameTimeController.getInstance().getGameTime();
|
||||
final int h = t / 60;
|
||||
final int m = t % 60;
|
||||
final SimpleDateFormat format = new SimpleDateFormat("h:mm a");
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, h);
|
||||
cal.set(Calendar.MINUTE, m);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/shutdown.htm");
|
||||
adminReply.replace("%count%", String.valueOf(L2World.getInstance().getAllPlayersCount()));
|
||||
adminReply.replace("%used%", String.valueOf(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
|
||||
adminReply.replace("%time%", String.valueOf(format.format(cal.getTime())));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void serverShutdown(L2PcInstance activeChar, int seconds, boolean restart)
|
||||
{
|
||||
Shutdown.getInstance().startShutdown(activeChar, seconds, restart);
|
||||
}
|
||||
|
||||
private void serverAbort(L2PcInstance activeChar)
|
||||
{
|
||||
Shutdown.getInstance().abort(activeChar);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 java.util.Calendar;
|
||||
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.Shutdown;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - server_shutdown [sec] = shows menu or shuts down server in sec seconds
|
||||
*/
|
||||
public class AdminShutdown implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_server_shutdown",
|
||||
"admin_server_restart",
|
||||
"admin_server_abort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_server_shutdown"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(22);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.valueOf(val), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_shutdown <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_restart"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(21);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.parseInt(val), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_restart <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_abort"))
|
||||
{
|
||||
serverAbort(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void sendHtmlForm(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
final int t = GameTimeController.getInstance().getGameTime();
|
||||
final int h = t / 60;
|
||||
final int m = t % 60;
|
||||
final SimpleDateFormat format = new SimpleDateFormat("h:mm a");
|
||||
final Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, h);
|
||||
cal.set(Calendar.MINUTE, m);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/shutdown.htm");
|
||||
adminReply.replace("%count%", String.valueOf(L2World.getInstance().getPlayers().size()));
|
||||
adminReply.replace("%used%", String.valueOf(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
|
||||
adminReply.replace("%time%", String.valueOf(format.format(cal.getTime())));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void serverShutdown(L2PcInstance activeChar, int seconds, boolean restart)
|
||||
{
|
||||
Shutdown.getInstance().startShutdown(activeChar, seconds, restart);
|
||||
}
|
||||
|
||||
private void serverAbort(L2PcInstance activeChar)
|
||||
{
|
||||
Shutdown.getInstance().abort(activeChar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,514 +1,472 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.DayNightSpawnManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jmobius.gameserver.model.AutoSpawnHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.entity.Instance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
|
||||
* @version $Revision: 1.2.2.5.2.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminSpawn implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminSpawn.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_show_spawns",
|
||||
"admin_spawn",
|
||||
"admin_spawn_monster",
|
||||
"admin_spawn_index",
|
||||
"admin_unspawnall",
|
||||
"admin_respawnall",
|
||||
"admin_spawn_reload",
|
||||
"admin_npc_index",
|
||||
"admin_spawn_once",
|
||||
"admin_show_npcs",
|
||||
"admin_spawnnight",
|
||||
"admin_spawnday",
|
||||
"admin_instance_spawns",
|
||||
"admin_list_spawns",
|
||||
"admin_list_positions",
|
||||
"admin_spawn_debug_menu",
|
||||
"admin_spawn_debug_print",
|
||||
"admin_spawn_debug_print_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_show_spawns"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_debug_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_debug_print"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2Npc)
|
||||
{
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int type = Integer.parseInt(st.nextToken());
|
||||
printSpawn((L2Npc) target, type);
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_index"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int level = Integer.parseInt(st.nextToken());
|
||||
int from = 0;
|
||||
try
|
||||
{
|
||||
from = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
}
|
||||
showMonsters(activeChar, level, from);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_show_npcs"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "npcs.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_npc_index"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final String letter = st.nextToken();
|
||||
int from = 0;
|
||||
try
|
||||
{
|
||||
from = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
}
|
||||
showNpcs(activeChar, letter, from);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "npcs.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_instance_spawns"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int instance = Integer.parseInt(st.nextToken());
|
||||
if (instance >= 300000)
|
||||
{
|
||||
final StringBuilder html = StringUtil.startAppend(500 + 1000, "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>", "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>", "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>", "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
|
||||
int counter = 0;
|
||||
int skiped = 0;
|
||||
final Instance inst = InstanceManager.getInstance().getInstance(instance);
|
||||
if (inst != null)
|
||||
{
|
||||
for (L2Npc npc : inst.getNpcs())
|
||||
{
|
||||
if (!npc.isDead())
|
||||
{
|
||||
// Only 50 because of client html limitation
|
||||
if (counter < 50)
|
||||
{
|
||||
StringUtil.append(html, "<tr><td>" + npc.getName() + "</td><td>", "<a action=\"bypass -h admin_move_to " + npc.getX() + " " + npc.getY() + " " + npc.getZ() + "\">Go</a>", "</td></tr>");
|
||||
counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
skiped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
StringUtil.append(html, "<tr><td>Skipped:</td><td>" + String.valueOf(skiped) + "</td></tr></table></body></html>");
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage();
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Cannot find instance " + instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid instance number.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage //instance_spawns <instance_number>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unspawnall"))
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_NPC_SERVER_IS_NOT_OPERATING_AT_THIS_TIME));
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
DayNightSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_spawnday"))
|
||||
{
|
||||
DayNightSpawnManager.getInstance().spawnDayCreatures();
|
||||
}
|
||||
else if (command.startsWith("admin_spawnnight"))
|
||||
{
|
||||
DayNightSpawnManager.getInstance().spawnNightCreatures();
|
||||
}
|
||||
else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload"))
|
||||
{
|
||||
// make sure all spawns are deleted
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
DayNightSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
// now respawn all
|
||||
NpcData.getInstance().load();
|
||||
SpawnTable.getInstance().load();
|
||||
RaidBossSpawnManager.getInstance().load();
|
||||
AutoSpawnHandler.getInstance().reload();
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
final String cmd = st.nextToken();
|
||||
final String id = st.nextToken();
|
||||
int respawnTime = 60; // default is set to 60 seconds
|
||||
int mobCount = 1;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
mobCount = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
respawnTime = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
if (cmd.equalsIgnoreCase("admin_spawn_once"))
|
||||
{
|
||||
spawnMonster(activeChar, id, respawnTime, mobCount, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnMonster(activeChar, id, respawnTime, mobCount, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{ // Case of wrong or missing monster data
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_list_spawns") || command.startsWith("admin_list_positions"))
|
||||
{
|
||||
int npcId = 0;
|
||||
int teleportIndex = -1;
|
||||
try
|
||||
{ // admin_list_spawns x[xxxx] x[xx]
|
||||
final String[] params = command.split(" ");
|
||||
final Pattern pattern = Pattern.compile("[0-9]*");
|
||||
final Matcher regexp = pattern.matcher(params[1]);
|
||||
if (regexp.matches())
|
||||
{
|
||||
npcId = Integer.parseInt(params[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
params[1] = params[1].replace('_', ' ');
|
||||
npcId = NpcData.getInstance().getTemplateByName(params[1]).getId();
|
||||
}
|
||||
if (params.length > 2)
|
||||
{
|
||||
teleportIndex = Integer.parseInt(params[2]);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
|
||||
}
|
||||
if (command.startsWith("admin_list_positions"))
|
||||
{
|
||||
findNPCInstances(activeChar, npcId, teleportIndex, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
findNPCInstances(activeChar, npcId, teleportIndex, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the spawn of a NPC.
|
||||
* @param activeChar
|
||||
* @param npcId
|
||||
* @param teleportIndex
|
||||
* @param showposition
|
||||
*/
|
||||
private void findNPCInstances(L2PcInstance activeChar, int npcId, int teleportIndex, boolean showposition)
|
||||
{
|
||||
int index = 0;
|
||||
for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(npcId))
|
||||
{
|
||||
index++;
|
||||
final L2Npc npc = spawn.getLastSpawn();
|
||||
if (teleportIndex > -1)
|
||||
{
|
||||
if (teleportIndex == index)
|
||||
{
|
||||
if (showposition && (npc != null))
|
||||
{
|
||||
activeChar.teleToLocation(npc.getLocation(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.teleToLocation(spawn.getLocation(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (showposition && (npc != null))
|
||||
{
|
||||
activeChar.sendMessage(index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + npc.getX() + " " + npc.getY() + " " + npc.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + spawn.getX() + " " + spawn.getY() + " " + spawn.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
activeChar.sendMessage(getClass().getSimpleName() + ": No current spawns found.");
|
||||
}
|
||||
}
|
||||
|
||||
private void printSpawn(L2Npc target, int type)
|
||||
{
|
||||
final int i = target.getId();
|
||||
final int x = target.getSpawn().getX();
|
||||
final int y = target.getSpawn().getY();
|
||||
final int z = target.getSpawn().getZ();
|
||||
final int h = target.getSpawn().getHeading();
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
{
|
||||
_log.info("('',1," + i + "," + x + "," + y + "," + z + ",0,0," + h + ",60,0,0),");
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
_log.info("<spawn npcId=\"" + i + "\" x=\"" + x + "\" y=\"" + y + "\" z=\"" + z + "\" heading=\"" + h + "\" respawn=\"0\" />");
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
_log.info("{ " + i + ", " + x + ", " + y + ", " + z + ", " + h + " },");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMonster(L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount, boolean permanent)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
|
||||
L2NpcTemplate template;
|
||||
if (monsterId.matches("[0-9]*"))
|
||||
{
|
||||
// First parameter was an ID number
|
||||
template = NpcData.getInstance().getTemplate(Integer.parseInt(monsterId));
|
||||
}
|
||||
else
|
||||
{
|
||||
// First parameter wasn't just numbers so go by name not ID
|
||||
template = NpcData.getInstance().getTemplateByName(monsterId.replace('_', ' '));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final L2Spawn spawn = new L2Spawn(template);
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
{
|
||||
spawn.setCustom(true);
|
||||
}
|
||||
spawn.setX(target.getX());
|
||||
spawn.setY(target.getY());
|
||||
spawn.setZ(target.getZ());
|
||||
spawn.setAmount(mobCount);
|
||||
spawn.setHeading(activeChar.getHeading());
|
||||
spawn.setRespawnDelay(respawnTime);
|
||||
if (activeChar.getInstanceId() > 0)
|
||||
{
|
||||
spawn.setInstanceId(activeChar.getInstanceId());
|
||||
permanent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawn.setInstanceId(0);
|
||||
}
|
||||
// TODO add checks for GrandBossSpawnManager
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot spawn another instance of " + template.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (template.isType("L2RaidBoss"))
|
||||
{
|
||||
spawn.setRespawnMinDelay(43200);
|
||||
spawn.setRespawnMaxDelay(129600);
|
||||
RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template.getBaseHpMax(), template.getBaseMpMax(), permanent);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, permanent);
|
||||
spawn.init();
|
||||
}
|
||||
if (!permanent)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
}
|
||||
activeChar.sendMessage("Created " + template.getName() + " on " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMonsters(L2PcInstance activeChar, int level, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "<html><title>Spawn Monster:</title><body><p> Level : ", Integer.toString(level), "<br>Total Npc's : ", Integer.toString(mobsCount), "<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs.get(i).getId()), "\">", mobs.get(i).getName(), "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(tb, "<br><center><button value=\"Next\" action=\"bypass -h admin_spawn_index ", Integer.toString(level), " ", Integer.toString(i), "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(tb.toString()));
|
||||
}
|
||||
|
||||
private void showNpcs(L2PcInstance activeChar, String starting, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllNpcStartingWith(starting);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "<html><title>Spawn Monster:</title><body><p> There are ", Integer.toString(mobsCount), " Npcs whose name starts with ", starting, ":<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs.get(i).getId()), "\">", mobs.get(i).getName(), "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(tb, "<br><center><button value=\"Next\" action=\"bypass -h admin_npc_index ", starting, " ", Integer.toString(i), "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(tb.toString()));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jmobius.gameserver.datatables.SpawnTable;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.DBSpawnManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.L2Spawn;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jmobius.gameserver.model.instancezone.Instance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
|
||||
* @version $Revision: 1.2.2.5.2.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminSpawn implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminSpawn.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_show_spawns",
|
||||
"admin_spawn",
|
||||
"admin_spawn_monster",
|
||||
"admin_spawn_index",
|
||||
"admin_unspawnall",
|
||||
"admin_respawnall",
|
||||
"admin_spawn_reload",
|
||||
"admin_npc_index",
|
||||
"admin_spawn_once",
|
||||
"admin_show_npcs",
|
||||
"admin_instance_spawns",
|
||||
"admin_list_spawns",
|
||||
"admin_list_positions",
|
||||
"admin_spawn_debug_menu",
|
||||
"admin_spawn_debug_print",
|
||||
"admin_spawn_debug_print_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_show_spawns"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_debug_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_debug_print"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2Npc)
|
||||
{
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int type = Integer.parseInt(st.nextToken());
|
||||
printSpawn((L2Npc) target, type);
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_index"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int level = Integer.parseInt(st.nextToken());
|
||||
int from = 0;
|
||||
try
|
||||
{
|
||||
from = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
}
|
||||
showMonsters(activeChar, level, from);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_show_npcs"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "npcs.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_npc_index"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final String letter = st.nextToken();
|
||||
int from = 0;
|
||||
try
|
||||
{
|
||||
from = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
}
|
||||
showNpcs(activeChar, letter, from);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "npcs.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_instance_spawns"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
final int instance = Integer.parseInt(st.nextToken());
|
||||
if (instance >= 300000)
|
||||
{
|
||||
final StringBuilder html = new StringBuilder(1500);
|
||||
html.append("<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center><font color=\"LEVEL\">Spawns for " + instance + "</font></td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
|
||||
int counter = 0;
|
||||
int skiped = 0;
|
||||
final Instance inst = InstanceManager.getInstance().getInstance(instance);
|
||||
if (inst != null)
|
||||
{
|
||||
for (L2Npc npc : inst.getNpcs())
|
||||
{
|
||||
if (!npc.isDead())
|
||||
{
|
||||
// Only 50 because of client html limitation
|
||||
if (counter < 50)
|
||||
{
|
||||
html.append("<tr><td>" + npc.getName() + "</td><td><a action=\"bypass -h admin_move_to " + npc.getX() + " " + npc.getY() + " " + npc.getZ() + "\">Go</a></td></tr>");
|
||||
counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
skiped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
html.append("<tr><td>Skipped:</td><td>" + skiped + "</td></tr></table></body></html>");
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage(0, 1);
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Cannot find instance " + instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid instance number.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage //instance_spawns <instance_number>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unspawnall"))
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_NPC_SERVER_IS_NOT_OPERATING_AT_THIS_TIME));
|
||||
DBSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload"))
|
||||
{
|
||||
// make sure all spawns are deleted
|
||||
DBSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
// now respawn all
|
||||
NpcData.getInstance().load();
|
||||
SpawnTable.getInstance().load();
|
||||
DBSpawnManager.getInstance().load();
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
final String cmd = st.nextToken();
|
||||
final String id = st.nextToken();
|
||||
int respawnTime = 60;
|
||||
int mobCount = 1;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
mobCount = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
respawnTime = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
|
||||
spawnMonster(activeChar, id, respawnTime, mobCount, (!cmd.equalsIgnoreCase("admin_spawn_once")));
|
||||
}
|
||||
catch (Exception e)
|
||||
{ // Case of wrong or missing monster data
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_list_spawns") || command.startsWith("admin_list_positions"))
|
||||
{
|
||||
int npcId = 0;
|
||||
int teleportIndex = -1;
|
||||
try
|
||||
{ // admin_list_spawns x[xxxx] x[xx]
|
||||
final String[] params = command.split(" ");
|
||||
final Pattern pattern = Pattern.compile("[0-9]*");
|
||||
final Matcher regexp = pattern.matcher(params[1]);
|
||||
if (regexp.matches())
|
||||
{
|
||||
npcId = Integer.parseInt(params[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
params[1] = params[1].replace('_', ' ');
|
||||
npcId = NpcData.getInstance().getTemplateByName(params[1]).getId();
|
||||
}
|
||||
if (params.length > 2)
|
||||
{
|
||||
teleportIndex = Integer.parseInt(params[2]);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //list_spawns <npcId|npc_name> [tele_index]");
|
||||
}
|
||||
if (command.startsWith("admin_list_positions"))
|
||||
{
|
||||
findNPCInstances(activeChar, npcId, teleportIndex, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
findNPCInstances(activeChar, npcId, teleportIndex, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the spawn of a NPC.
|
||||
* @param activeChar
|
||||
* @param npcId
|
||||
* @param teleportIndex
|
||||
* @param showposition
|
||||
*/
|
||||
private void findNPCInstances(L2PcInstance activeChar, int npcId, int teleportIndex, boolean showposition)
|
||||
{
|
||||
int index = 0;
|
||||
for (L2Spawn spawn : SpawnTable.getInstance().getSpawns(npcId))
|
||||
{
|
||||
index++;
|
||||
final L2Npc npc = spawn.getLastSpawn();
|
||||
if (teleportIndex > -1)
|
||||
{
|
||||
if (teleportIndex == index)
|
||||
{
|
||||
if (showposition && (npc != null))
|
||||
{
|
||||
activeChar.teleToLocation(npc.getLocation(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.teleToLocation(spawn.getLocation(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (showposition && (npc != null))
|
||||
{
|
||||
activeChar.sendMessage(index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + npc.getX() + " " + npc.getY() + " " + npc.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(index + " - " + spawn.getTemplate().getName() + " (" + spawn + "): " + spawn.getX() + " " + spawn.getY() + " " + spawn.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
activeChar.sendMessage(getClass().getSimpleName() + ": No current spawns found.");
|
||||
}
|
||||
}
|
||||
|
||||
private void printSpawn(L2Npc target, int type)
|
||||
{
|
||||
final int i = target.getId();
|
||||
final int x = target.getSpawn().getX();
|
||||
final int y = target.getSpawn().getY();
|
||||
final int z = target.getSpawn().getZ();
|
||||
final int h = target.getSpawn().getHeading();
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
_log.info("('',1," + i + "," + x + "," + y + "," + z + ",0,0," + h + ",60,0,0),");
|
||||
break;
|
||||
case 1:
|
||||
_log.info("<spawn npcId=\"" + i + "\" x=\"" + x + "\" y=\"" + y + "\" z=\"" + z + "\" heading=\"" + h + "\" respawn=\"0\" />");
|
||||
break;
|
||||
case 2:
|
||||
_log.info("{ " + i + ", " + x + ", " + y + ", " + z + ", " + h + " },");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMonster(L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount, boolean permanent)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
|
||||
final L2NpcTemplate template1;
|
||||
if (monsterId.matches("[0-9]*"))
|
||||
{
|
||||
// First parameter was an ID number
|
||||
final int monsterTemplate = Integer.parseInt(monsterId);
|
||||
template1 = NpcData.getInstance().getTemplate(monsterTemplate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// First parameter wasn't just numbers so go by name not ID
|
||||
monsterId = monsterId.replace('_', ' ');
|
||||
template1 = NpcData.getInstance().getTemplateByName(monsterId);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final L2Spawn spawn = new L2Spawn(template1);
|
||||
spawn.setX(target.getX());
|
||||
spawn.setY(target.getY());
|
||||
spawn.setZ(target.getZ());
|
||||
spawn.setAmount(mobCount);
|
||||
spawn.setHeading(activeChar.getHeading());
|
||||
spawn.setRespawnDelay(respawnTime);
|
||||
if (activeChar.isInInstance())
|
||||
{
|
||||
spawn.setInstanceId(activeChar.getInstanceId());
|
||||
permanent = false;
|
||||
}
|
||||
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, permanent);
|
||||
spawn.init();
|
||||
|
||||
if (!permanent)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
}
|
||||
activeChar.sendMessage("Created " + template1.getName() + " on " + target.getObjectId());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMonsters(L2PcInstance activeChar, int level, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80));
|
||||
tb.append("<html><title>Spawn Monster:</title><body><p> Level : " + level + "<br>Total Npc's : " + mobsCount + "<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
tb.append("<a action=\"bypass -h admin_spawn_monster " + mobs.get(i).getId() + "\">" + mobs.get(i).getName() + "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.append("<br><center><button value=\"Next\" action=\"bypass -h admin_spawn_index " + level + " " + i + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, tb.toString()));
|
||||
}
|
||||
|
||||
private void showNpcs(L2PcInstance activeChar, String starting, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllNpcStartingWith(starting);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = new StringBuilder(500 + (mobsCount * 80));
|
||||
tb.append("<html><title>Spawn Monster:</title><body><p> There are " + mobsCount + " Npcs whose name starts with " + starting + ":<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
tb.append("<a action=\"bypass -h admin_spawn_monster " + mobs.get(i).getId() + "\">" + mobs.get(i).getName() + "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
tb.append("<br><center><button value=\"Next\" action=\"bypass -h admin_npc_index " + starting + " " + i + "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, tb.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,93 +1,95 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author poltomb
|
||||
*/
|
||||
public class AdminSummon implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminSummon.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_summon"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int id;
|
||||
int count = 1;
|
||||
final String[] data = command.split(" ");
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(data[1]);
|
||||
if (data.length > 2)
|
||||
{
|
||||
count = Integer.parseInt(data[2]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect format for command 'summon'");
|
||||
return false;
|
||||
}
|
||||
|
||||
String subCommand;
|
||||
if (id < 1000000)
|
||||
{
|
||||
subCommand = "admin_create_item";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
AdminCommandHandler.getInstance().getHandler(subCommand).useAdminCommand(subCommand + " " + id + " " + count, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
subCommand = "admin_spawn_once";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
|
||||
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
|
||||
id -= 1000000;
|
||||
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author poltomb
|
||||
*/
|
||||
public class AdminSummon implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminSummon.class.getName());
|
||||
|
||||
public static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_summon"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int id;
|
||||
int count = 1;
|
||||
final String[] data = command.split(" ");
|
||||
try
|
||||
{
|
||||
id = Integer.parseInt(data[1]);
|
||||
if (data.length > 2)
|
||||
{
|
||||
count = Integer.parseInt(data[2]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect format for command 'summon'");
|
||||
return false;
|
||||
}
|
||||
|
||||
String subCommand;
|
||||
if (id < 1000000)
|
||||
{
|
||||
subCommand = "admin_create_item";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
subCommand = "admin_spawn_once";
|
||||
if (!AdminData.getInstance().hasAccess(subCommand, activeChar.getAccessLevel()))
|
||||
{
|
||||
activeChar.sendMessage("You don't have the access right to use this command!");
|
||||
_log.warning("Character " + activeChar.getName() + " tryed to use admin command " + subCommand + ", but have no access to it!");
|
||||
return false;
|
||||
}
|
||||
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
|
||||
activeChar.sendMessage("This is only a temporary spawn. The mob(s) will NOT respawn.");
|
||||
id -= 1000000;
|
||||
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,70 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - target name = sets player with respective name as target
|
||||
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminTarget implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_target"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_target"))
|
||||
{
|
||||
handleTarget(command, activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleTarget(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(13);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player != null)
|
||||
{
|
||||
player.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Player " + targetName + " not found");
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please specify correct name.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - target name = sets player with respective name as target
|
||||
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:05:56 $
|
||||
*/
|
||||
public class AdminTarget implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_target"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_target"))
|
||||
{
|
||||
handleTarget(command, activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleTarget(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
final String targetName = command.substring(13);
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player != null)
|
||||
{
|
||||
player.onAction(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Player " + targetName + " not found");
|
||||
}
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please specify correct name.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +1,71 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - targetsay <message> = makes talk a L2Character
|
||||
* @author nonom
|
||||
*/
|
||||
public class AdminTargetSay implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_targetsay"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_targetsay"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2StaticObjectInstance) || !(obj instanceof L2Character))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String message = command.substring(16);
|
||||
final L2Character target = (L2Character) obj;
|
||||
target.broadcastPacket(new CreatureSay(target.getObjectId(), target.isPlayer() ? ChatType.GENERAL : ChatType.NPC_GENERAL, target.getName(), message));
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //targetsay <text>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.gameserver.enums.ChatType;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - targetsay <message> = makes talk a L2Character
|
||||
* @author nonom
|
||||
*/
|
||||
public class AdminTargetSay implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_targetsay"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_targetsay"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2StaticObjectInstance) || !(obj instanceof L2Character))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String message = command.substring(16);
|
||||
final L2Character target = (L2Character) obj;
|
||||
target.broadcastPacket(new CreatureSay(target.getObjectId(), target.isPlayer() ? ChatType.GENERAL : ChatType.NPC_GENERAL, target.getName(), message));
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //targetsay <text>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,128 +1,128 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.datatables.SkillData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class AdminTest implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_stats",
|
||||
"admin_skill_test",
|
||||
"admin_known"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_stats"))
|
||||
{
|
||||
for (String line : ThreadPoolManager.getInstance().getStats())
|
||||
{
|
||||
activeChar.sendMessage(line);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_skill_test"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
final int id = Integer.parseInt(st.nextToken());
|
||||
if (command.startsWith("admin_skill_test"))
|
||||
{
|
||||
adminTestSkill(activeChar, id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
adminTestSkill(activeChar, id, false);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //skill_test <ID>");
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //skill_test <ID>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_known on"))
|
||||
{
|
||||
Config.CHECK_KNOWN = true;
|
||||
}
|
||||
else if (command.equals("admin_known off"))
|
||||
{
|
||||
Config.CHECK_KNOWN = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param id
|
||||
* @param msu
|
||||
*/
|
||||
private void adminTestSkill(L2PcInstance activeChar, int id, boolean msu)
|
||||
{
|
||||
L2Character caster;
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (!(target instanceof L2Character))
|
||||
{
|
||||
caster = activeChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
caster = (L2Character) target;
|
||||
}
|
||||
|
||||
final Skill _skill = SkillData.getInstance().getSkill(id, 1);
|
||||
if (_skill != null)
|
||||
{
|
||||
caster.setTarget(activeChar);
|
||||
if (msu)
|
||||
{
|
||||
caster.broadcastPacket(new MagicSkillUse(caster, activeChar, id, 1, _skill.getHitTime(), _skill.getReuseDelay()));
|
||||
}
|
||||
else
|
||||
{
|
||||
caster.doCast(_skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.ThreadPoolManager;
|
||||
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
|
||||
|
||||
/**
|
||||
* @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
|
||||
*/
|
||||
public class AdminTest implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_stats",
|
||||
"admin_skill_test",
|
||||
"admin_known"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_stats"))
|
||||
{
|
||||
for (String line : ThreadPoolManager.getInstance().getStats())
|
||||
{
|
||||
activeChar.sendMessage(line);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_skill_test"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
final int id = Integer.parseInt(st.nextToken());
|
||||
if (command.startsWith("admin_skill_test"))
|
||||
{
|
||||
adminTestSkill(activeChar, id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
adminTestSkill(activeChar, id, false);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //skill_test <ID>");
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
activeChar.sendMessage("Command format is //skill_test <ID>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_known on"))
|
||||
{
|
||||
Config.CHECK_KNOWN = true;
|
||||
}
|
||||
else if (command.equals("admin_known off"))
|
||||
{
|
||||
Config.CHECK_KNOWN = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param id
|
||||
* @param msu
|
||||
*/
|
||||
private void adminTestSkill(L2PcInstance activeChar, int id, boolean msu)
|
||||
{
|
||||
L2Character caster;
|
||||
final L2Object target = activeChar.getTarget();
|
||||
if (!(target instanceof L2Character))
|
||||
{
|
||||
caster = activeChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
caster = (L2Character) target;
|
||||
}
|
||||
|
||||
final Skill _skill = SkillData.getInstance().getSkill(id, 1);
|
||||
if (_skill != null)
|
||||
{
|
||||
caster.setTarget(activeChar);
|
||||
if (msu)
|
||||
{
|
||||
caster.broadcastPacket(new MagicSkillUse(caster, activeChar, id, 1, _skill.getHitTime(), _skill.getReuseDelay()));
|
||||
}
|
||||
else
|
||||
{
|
||||
caster.doCast(_skill);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.L2Object;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTEventTeleporter;
|
||||
import com.l2jmobius.gameserver.model.entity.TvTManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class AdminTvTEvent implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_tvt_add",
|
||||
"admin_tvt_remove",
|
||||
"admin_tvt_advance"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_tvt_add"))
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You should select a player!");
|
||||
return true;
|
||||
}
|
||||
|
||||
add(activeChar, (L2PcInstance) target);
|
||||
}
|
||||
else if (command.equals("admin_tvt_remove"))
|
||||
{
|
||||
final L2Object target = activeChar.getTarget();
|
||||
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You should select a player!");
|
||||
return true;
|
||||
}
|
||||
|
||||
remove(activeChar, (L2PcInstance) target);
|
||||
}
|
||||
else if (command.equals("admin_tvt_advance"))
|
||||
{
|
||||
TvTManager.getInstance().skipDelay();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void add(L2PcInstance activeChar, L2PcInstance playerInstance)
|
||||
{
|
||||
if (playerInstance.isOnEvent())
|
||||
{
|
||||
activeChar.sendMessage("Player already participated in the event!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TvTEvent.addParticipant(playerInstance))
|
||||
{
|
||||
activeChar.sendMessage("Player instance could not be added, it seems to be null!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TvTEvent.isStarted())
|
||||
{
|
||||
new TvTEventTeleporter(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getObjectId()), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void remove(L2PcInstance activeChar, L2PcInstance playerInstance)
|
||||
{
|
||||
if (!TvTEvent.removeParticipant(playerInstance.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("Player is not part of the event!");
|
||||
return;
|
||||
}
|
||||
|
||||
new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.WallData;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.holders.WallHolder;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExServerPrimitive;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class AdminWall implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_showwalls"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.equals("admin_showwalls"))
|
||||
{
|
||||
final ExServerPrimitive packet = new ExServerPrimitive("wall_info", activeChar.getX(), activeChar.getY(), -16000);
|
||||
final List<WallHolder> allWalls = WallData.getInstance().getRegionWalls(activeChar.getX(), activeChar.getY());
|
||||
if (allWalls != null)
|
||||
{
|
||||
for (WallHolder wall : allWalls)
|
||||
{
|
||||
if ((Util.calculateDistance(activeChar.getX(), activeChar.getY(), activeChar.getZ(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMin(), false, false) < 3000) //
|
||||
|| (Util.calculateDistance(activeChar.getX(), activeChar.getY(), activeChar.getZ(), wall.getPoint1X(), wall.getPoint1Y(), wall.getZMin(), false, false) < 3000))
|
||||
{
|
||||
// top-bottom
|
||||
packet.addLine(Color.GREEN, wall.getPoint1X(), wall.getPoint1Y(), wall.getZMax(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMax());
|
||||
packet.addLine(Color.GREEN, wall.getPoint1X(), wall.getPoint1Y(), wall.getZMin(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMin());
|
||||
// left-right
|
||||
packet.addLine(Color.GREEN, wall.getPoint1X(), wall.getPoint1Y(), wall.getZMin(), wall.getPoint1X(), wall.getPoint1Y(), wall.getZMax());
|
||||
packet.addLine(Color.GREEN, wall.getPoint2X(), wall.getPoint2Y(), wall.getZMin(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMax());
|
||||
// diagonals
|
||||
packet.addLine(Color.GREEN, wall.getPoint1X(), wall.getPoint1Y(), wall.getZMin(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMax());
|
||||
packet.addLine(Color.GREEN, wall.getPoint1X(), wall.getPoint1Y(), wall.getZMax(), wall.getPoint2X(), wall.getPoint2Y(), wall.getZMin());
|
||||
}
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(packet);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,176 +1,178 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.L2WorldRegion;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.NpcSpawnTerritory;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Small typo fix by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_zone_check",
|
||||
"admin_zone_visual",
|
||||
"admin_zone_visual_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
// String val = "";
|
||||
// if (st.countTokens() >= 1) {val = st.nextToken();}
|
||||
|
||||
if (actualCommand.equalsIgnoreCase("admin_zone_check"))
|
||||
{
|
||||
showHtml(activeChar);
|
||||
activeChar.sendMessage("MapRegion: x:" + MapRegionManager.getInstance().getMapRegionX(activeChar.getX()) + " y:" + MapRegionManager.getInstance().getMapRegionY(activeChar.getY()) + " (" + MapRegionManager.getInstance().getMapRegionLocId(activeChar) + ")");
|
||||
getGeoRegionXY(activeChar);
|
||||
activeChar.sendMessage("Closest Town: " + MapRegionManager.getInstance().getClosestTownName(activeChar));
|
||||
|
||||
Location loc;
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CASTLE);
|
||||
activeChar.sendMessage("TeleToLocation (Castle): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CLANHALL);
|
||||
activeChar.sendMessage("TeleToLocation (ClanHall): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.SIEGEFLAG);
|
||||
activeChar.sendMessage("TeleToLocation (SiegeFlag): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
|
||||
activeChar.sendMessage("TeleToLocation (Town): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_zone_visual"))
|
||||
{
|
||||
final String next = st.nextToken();
|
||||
if (next.equalsIgnoreCase("all"))
|
||||
{
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getZones(activeChar))
|
||||
{
|
||||
zone.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
territory.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
showHtml(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ZoneManager.getInstance().getZoneById(Integer.parseInt(next)).visualizeZone(activeChar.getZ());
|
||||
}
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_zone_visual_clear"))
|
||||
{
|
||||
ZoneManager.getInstance().clearDebugItems();
|
||||
showHtml(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void showHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/zone.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setHtml(htmContent);
|
||||
adminReply.replace("%PEACE%", activeChar.isInsideZone(ZoneId.PEACE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%PVP%", activeChar.isInsideZone(ZoneId.PVP) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SIEGE%", activeChar.isInsideZone(ZoneId.SIEGE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%TOWN%", activeChar.isInsideZone(ZoneId.TOWN) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%CASTLE%", activeChar.isInsideZone(ZoneId.CASTLE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%FORT%", activeChar.isInsideZone(ZoneId.FORT) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%HQ%", activeChar.isInsideZone(ZoneId.HQ) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%CLANHALL%", activeChar.isInsideZone(ZoneId.CLAN_HALL) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%LAND%", activeChar.isInsideZone(ZoneId.LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOLAND%", activeChar.isInsideZone(ZoneId.NO_LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOSUMMON%", activeChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%WATER%", activeChar.isInsideZone(ZoneId.WATER) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%FISHING%", activeChar.isInsideZone(ZoneId.FISHING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SWAMP%", activeChar.isInsideZone(ZoneId.SWAMP) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%DANGER%", activeChar.isInsideZone(ZoneId.DANGER_AREA) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOSTORE%", activeChar.isInsideZone(ZoneId.NO_STORE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SCRIPT%", activeChar.isInsideZone(ZoneId.SCRIPT) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
final StringBuilder zones = new StringBuilder(100);
|
||||
final L2WorldRegion region = L2World.getInstance().getRegion(activeChar.getX(), activeChar.getY());
|
||||
for (L2ZoneType zone : region.getZones())
|
||||
{
|
||||
if (zone.isCharacterInZone(activeChar))
|
||||
{
|
||||
if (zone.getName() != null)
|
||||
{
|
||||
StringUtil.append(zones, zone.getName() + "<br1>");
|
||||
if (zone.getId() < 300000)
|
||||
{
|
||||
StringUtil.append(zones, "(", String.valueOf(zone.getId()), ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(zones, String.valueOf(zone.getId()));
|
||||
}
|
||||
StringUtil.append(zones, " ");
|
||||
}
|
||||
}
|
||||
for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
StringUtil.append(zones, territory.getName() + "<br1>");
|
||||
}
|
||||
adminReply.replace("%ZLIST%", zones.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private static void getGeoRegionXY(L2PcInstance activeChar)
|
||||
{
|
||||
final int worldX = activeChar.getX();
|
||||
final int worldY = activeChar.getY();
|
||||
final int geoX = (((worldX - -327680) >> 4) >> 11) + 10;
|
||||
final int geoY = (((worldY - -262144) >> 4) >> 11) + 10;
|
||||
activeChar.sendMessage("GeoRegion: " + geoX + "_" + geoY + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.util.StringTokenizer;
|
||||
|
||||
import com.l2jmobius.gameserver.cache.HtmCache;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.TeleportWhereType;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import com.l2jmobius.gameserver.model.zone.type.L2SpawnTerritory;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* Small typo fix by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_zone_check",
|
||||
"admin_zone_visual",
|
||||
"admin_zone_visual_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken(); // Get actual command
|
||||
|
||||
// String val = "";
|
||||
// if (st.countTokens() >= 1) {val = st.nextToken();}
|
||||
|
||||
if (actualCommand.equalsIgnoreCase("admin_zone_check"))
|
||||
{
|
||||
showHtml(activeChar);
|
||||
activeChar.sendMessage("MapRegion: x:" + MapRegionManager.getInstance().getMapRegionX(activeChar.getX()) + " y:" + MapRegionManager.getInstance().getMapRegionY(activeChar.getY()) + " (" + MapRegionManager.getInstance().getMapRegionLocId(activeChar) + ")");
|
||||
getGeoRegionXY(activeChar);
|
||||
activeChar.sendMessage("Closest Town: " + MapRegionManager.getInstance().getClosestTownName(activeChar));
|
||||
|
||||
Location loc;
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CASTLE);
|
||||
activeChar.sendMessage("TeleToLocation (Castle): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.CLANHALL);
|
||||
activeChar.sendMessage("TeleToLocation (ClanHall): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.SIEGEFLAG);
|
||||
activeChar.sendMessage("TeleToLocation (SiegeFlag): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionManager.getInstance().getTeleToLocation(activeChar, TeleportWhereType.TOWN);
|
||||
activeChar.sendMessage("TeleToLocation (Town): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_zone_visual"))
|
||||
{
|
||||
final String next = st.nextToken();
|
||||
if (next.equalsIgnoreCase("all"))
|
||||
{
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getZones(activeChar))
|
||||
{
|
||||
zone.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
for (L2SpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
territory.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
showHtml(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
final int zoneId = Integer.parseInt(next);
|
||||
ZoneManager.getInstance().getZoneById(zoneId).visualizeZone(activeChar.getZ());
|
||||
}
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_zone_visual_clear"))
|
||||
{
|
||||
ZoneManager.getInstance().clearDebugItems();
|
||||
showHtml(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void showHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final String htmContent = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/zone.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
|
||||
adminReply.setHtml(htmContent);
|
||||
adminReply.replace("%PEACE%", activeChar.isInsideZone(ZoneId.PEACE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%PVP%", activeChar.isInsideZone(ZoneId.PVP) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SIEGE%", activeChar.isInsideZone(ZoneId.SIEGE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%TOWN%", activeChar.isInsideZone(ZoneId.TOWN) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%CASTLE%", activeChar.isInsideZone(ZoneId.CASTLE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%FORT%", activeChar.isInsideZone(ZoneId.FORT) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%HQ%", activeChar.isInsideZone(ZoneId.HQ) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%CLANHALL%", activeChar.isInsideZone(ZoneId.CLAN_HALL) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%LAND%", activeChar.isInsideZone(ZoneId.LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOLAND%", activeChar.isInsideZone(ZoneId.NO_LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOSUMMON%", activeChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%WATER%", activeChar.isInsideZone(ZoneId.WATER) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%FISHING%", activeChar.isInsideZone(ZoneId.FISHING) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SWAMP%", activeChar.isInsideZone(ZoneId.SWAMP) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%DANGER%", activeChar.isInsideZone(ZoneId.DANGER_AREA) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%NOSTORE%", activeChar.isInsideZone(ZoneId.NO_STORE) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
adminReply.replace("%SCRIPT%", activeChar.isInsideZone(ZoneId.SCRIPT) ? "<font color=\"LEVEL\">YES</font>" : "NO");
|
||||
|
||||
final StringBuilder zones = new StringBuilder(100);
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getRegion(activeChar).getZones().values())
|
||||
{
|
||||
if (zone.isCharacterInZone(activeChar))
|
||||
{
|
||||
if (zone.getName() != null)
|
||||
{
|
||||
zones.append(zone.getName());
|
||||
zones.append("<br1>");
|
||||
if (zone.getId() < 300000)
|
||||
{
|
||||
zones.append("(");
|
||||
zones.append(zone.getId());
|
||||
zones.append(")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
zones.append(zone.getId());
|
||||
}
|
||||
zones.append(" ");
|
||||
}
|
||||
}
|
||||
for (L2SpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
zones.append(territory.getName());
|
||||
zones.append("<br1>");
|
||||
}
|
||||
adminReply.replace("%ZLIST%", zones.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private static void getGeoRegionXY(L2PcInstance activeChar)
|
||||
{
|
||||
final int worldX = activeChar.getX();
|
||||
final int worldY = activeChar.getY();
|
||||
final int geoX = (((worldX - -327680) >> 4) >> 11) + 10;
|
||||
final int geoY = (((worldY - -262144) >> 4) >> 11) + 10;
|
||||
activeChar.sendMessage("GeoRegion: " + geoX + "_" + geoY + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
660
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminZones.java
vendored
Normal file
660
trunk/dist/game/data/scripts/handlers/admincommandhandlers/AdminZones.java
vendored
Normal file
@@ -0,0 +1,660 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.awt.Color;
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.GeoData;
|
||||
import com.l2jmobius.gameserver.enums.PlayerAction;
|
||||
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jmobius.gameserver.model.Location;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.Priority;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterEvent;
|
||||
import com.l2jmobius.gameserver.model.events.annotations.RegisterType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerDlgAnswer;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerMoveRequest;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.html.PageBuilder;
|
||||
import com.l2jmobius.gameserver.model.html.PageResult;
|
||||
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jmobius.gameserver.model.zone.form.ZoneNPoly;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExServerPrimitive;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowTerritory;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
import ai.AbstractNpcAI;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AdminZones extends AbstractNpcAI implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminPathNode.class.getName());
|
||||
private final Map<Integer, ZoneNodeHolder> _zones = new ConcurrentHashMap<>();
|
||||
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"admin_zones",
|
||||
};
|
||||
|
||||
public AdminZones()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_zones":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
buildZonesEditorWindow(activeChar);
|
||||
return false;
|
||||
}
|
||||
final String subCmd = st.nextToken();
|
||||
switch (subCmd)
|
||||
{
|
||||
case "load":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
String name = "";
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
name += st.nextToken() + " ";
|
||||
}
|
||||
loadZone(activeChar, name.trim());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "create":
|
||||
{
|
||||
buildHtmlWindow(activeChar, 0);
|
||||
break;
|
||||
}
|
||||
case "setname":
|
||||
{
|
||||
String name = "";
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
name += st.nextToken() + " ";
|
||||
}
|
||||
if (!name.isEmpty())
|
||||
{
|
||||
name = name.substring(0, name.length() - 1);
|
||||
}
|
||||
setName(activeChar, name);
|
||||
break;
|
||||
}
|
||||
case "start":
|
||||
{
|
||||
enablePicking(activeChar);
|
||||
break;
|
||||
}
|
||||
case "finish":
|
||||
{
|
||||
disablePicking(activeChar);
|
||||
break;
|
||||
}
|
||||
case "setMinZ":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int minZ = Integer.parseInt(st.nextToken());
|
||||
setMinZ(activeChar, minZ);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "setMaxZ":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int maxZ = Integer.parseInt(st.nextToken());
|
||||
setMaxZ(activeChar, maxZ);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "show":
|
||||
{
|
||||
showPoints(activeChar);
|
||||
final ConfirmDlg dlg = new ConfirmDlg("When enable show territory you must restart client to remove it, are you sure about that?");
|
||||
dlg.addTime(15 * 1000);
|
||||
activeChar.sendPacket(dlg);
|
||||
activeChar.addAction(PlayerAction.ADMIN_SHOW_TERRITORY);
|
||||
break;
|
||||
}
|
||||
case "hide":
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if (holder != null)
|
||||
{
|
||||
final ExServerPrimitive exsp = new ExServerPrimitive("DebugPoint_" + activeChar.getObjectId(), activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
exsp.addPoint(Color.BLACK, 0, 0, 0);
|
||||
activeChar.sendPacket(exsp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "change":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing node index!");
|
||||
break;
|
||||
}
|
||||
final String indexToken = st.nextToken();
|
||||
if (!Util.isDigit(indexToken))
|
||||
{
|
||||
activeChar.sendMessage("Node index should be int!");
|
||||
break;
|
||||
}
|
||||
final int index = Integer.parseInt(indexToken);
|
||||
changePoint(activeChar, index);
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Missing node index!");
|
||||
break;
|
||||
}
|
||||
final String indexToken = st.nextToken();
|
||||
if (!Util.isDigit(indexToken))
|
||||
{
|
||||
activeChar.sendMessage("Node index should be int!");
|
||||
break;
|
||||
}
|
||||
final int index = Integer.parseInt(indexToken);
|
||||
deletePoint(activeChar, index);
|
||||
showPoints(activeChar);
|
||||
break;
|
||||
}
|
||||
case "clear":
|
||||
{
|
||||
_zones.remove(activeChar.getObjectId());
|
||||
break;
|
||||
}
|
||||
case "dump":
|
||||
{
|
||||
dumpPoints(activeChar);
|
||||
break;
|
||||
}
|
||||
case "list":
|
||||
{
|
||||
final int page = CommonUtil.parseNextInt(st, 0);
|
||||
buildHtmlWindow(activeChar, page);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
buildHtmlWindow(activeChar, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param minZ
|
||||
*/
|
||||
private void setMinZ(L2PcInstance activeChar, int minZ)
|
||||
{
|
||||
_zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder(activeChar)).setMinZ(minZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param maxZ
|
||||
*/
|
||||
private void setMaxZ(L2PcInstance activeChar, int maxZ)
|
||||
{
|
||||
_zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder(activeChar)).setMaxZ(maxZ);
|
||||
}
|
||||
|
||||
private void buildZonesEditorWindow(L2PcInstance activeChar)
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final List<L2ZoneType> zones = ZoneManager.getInstance().getZones(activeChar);
|
||||
for (L2ZoneType zone : zones)
|
||||
{
|
||||
if (zone.getZone() instanceof ZoneNPoly)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=200><a action=\"bypass -h admin_zones load " + zone.getName() + "\">" + zone.getName() + "</a></td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/zone_editor.htm");
|
||||
msg.replace("%zones%", sb.toString());
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param zoneName
|
||||
*/
|
||||
private void loadZone(L2PcInstance activeChar, String zoneName)
|
||||
{
|
||||
activeChar.sendMessage("Searching for zone: " + zoneName);
|
||||
final List<L2ZoneType> zones = ZoneManager.getInstance().getZones(activeChar);
|
||||
L2ZoneType zoneType = null;
|
||||
for (L2ZoneType zone : zones)
|
||||
{
|
||||
if (zone.getName().equalsIgnoreCase(zoneName))
|
||||
{
|
||||
zoneType = zone;
|
||||
activeChar.sendMessage("Zone found: " + zone.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((zoneType != null) && (zoneType.getZone() instanceof ZoneNPoly))
|
||||
{
|
||||
final ZoneNPoly zone = (ZoneNPoly) zoneType.getZone();
|
||||
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), val -> new ZoneNodeHolder(activeChar));
|
||||
holder.getNodes().clear();
|
||||
holder.setName(zoneType.getName());
|
||||
holder.setMinZ(zone.getLowZ());
|
||||
holder.setMaxZ(zone.getHighZ());
|
||||
for (int i = 0; i < zone.getX().length; i++)
|
||||
{
|
||||
final int x = zone.getX()[i];
|
||||
final int y = zone.getY()[i];
|
||||
holder.addNode(new Location(x, y, GeoData.getInstance().getSpawnHeight(x, y, Rnd.get(zone.getLowZ(), zone.getHighZ()))));
|
||||
}
|
||||
showPoints(activeChar);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param name
|
||||
*/
|
||||
private void setName(L2PcInstance activeChar, String name)
|
||||
{
|
||||
if (name.contains("<") || name.contains(">") || name.contains("&") || name.contains("\\") || name.contains("\"") || name.contains("$"))
|
||||
{
|
||||
activeChar.sendMessage("You cannot use symbols like: < > & \" $ \\");
|
||||
return;
|
||||
}
|
||||
_zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder(activeChar)).setName(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void enablePicking(L2PcInstance activeChar)
|
||||
{
|
||||
if (!activeChar.hasAction(PlayerAction.ADMIN_POINT_PICKING))
|
||||
{
|
||||
activeChar.addAction(PlayerAction.ADMIN_POINT_PICKING);
|
||||
activeChar.sendMessage("Point picking mode activated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Point picking mode is already activated!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void disablePicking(L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar.removeAction(PlayerAction.ADMIN_POINT_PICKING))
|
||||
{
|
||||
activeChar.sendMessage("Point picking mode deactivated!");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Point picking mode was not activated!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showPoints(L2PcInstance activeChar)
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if (holder != null)
|
||||
{
|
||||
if (holder.getNodes().size() < 3)
|
||||
{
|
||||
activeChar.sendMessage("In order to visualize this zone you must have at least 3 points.");
|
||||
return;
|
||||
}
|
||||
final ExServerPrimitive exsp = new ExServerPrimitive("DebugPoint_" + activeChar.getObjectId(), activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
final List<Location> list = holder.getNodes();
|
||||
for (int i = 1; i < list.size(); i++)
|
||||
{
|
||||
final Location prevLoc = list.get(i - 1);
|
||||
final Location nextLoc = list.get(i);
|
||||
if (holder.getMinZ() != 0)
|
||||
{
|
||||
exsp.addLine("Min Point " + i + " > " + (i + 1), Color.CYAN, true, prevLoc.getX(), prevLoc.getY(), holder.getMinZ(), nextLoc.getX(), nextLoc.getY(), holder.getMinZ());
|
||||
}
|
||||
exsp.addLine("Point " + i + " > " + (i + 1), Color.WHITE, true, prevLoc, nextLoc);
|
||||
if (holder.getMaxZ() != 0)
|
||||
{
|
||||
exsp.addLine("Max Point " + i + " > " + (i + 1), Color.RED, true, prevLoc.getX(), prevLoc.getY(), holder.getMaxZ(), nextLoc.getX(), nextLoc.getY(), holder.getMaxZ());
|
||||
}
|
||||
}
|
||||
final Location prevLoc = list.get(list.size() - 1);
|
||||
final Location nextLoc = list.get(0);
|
||||
if (holder.getMinZ() != 0)
|
||||
{
|
||||
exsp.addLine("Min Point " + list.size() + " > 1", Color.CYAN, true, prevLoc.getX(), prevLoc.getY(), holder.getMinZ(), nextLoc.getX(), nextLoc.getY(), holder.getMinZ());
|
||||
}
|
||||
exsp.addLine("Point " + list.size() + " > 1", Color.WHITE, true, prevLoc, nextLoc);
|
||||
if (holder.getMaxZ() != 0)
|
||||
{
|
||||
exsp.addLine("Max Point " + list.size() + " > 1", Color.RED, true, prevLoc.getX(), prevLoc.getY(), holder.getMaxZ(), nextLoc.getX(), nextLoc.getY(), holder.getMaxZ());
|
||||
}
|
||||
activeChar.sendPacket(exsp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param index
|
||||
*/
|
||||
private void changePoint(L2PcInstance activeChar, int index)
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if (holder != null)
|
||||
{
|
||||
final Location loc = holder.getNodes().get(index);
|
||||
if (loc != null)
|
||||
{
|
||||
enablePicking(activeChar);
|
||||
holder.setChangingLoc(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param index
|
||||
*/
|
||||
private void deletePoint(L2PcInstance activeChar, int index)
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if (holder != null)
|
||||
{
|
||||
final Location loc = holder.getNodes().get(index);
|
||||
if (loc != null)
|
||||
{
|
||||
holder.getNodes().remove(loc);
|
||||
activeChar.sendMessage("Node " + index + " has been removed!");
|
||||
if (holder.getNodes().isEmpty())
|
||||
{
|
||||
activeChar.sendMessage("Since node list is empty destroying session!");
|
||||
_zones.remove(activeChar.getObjectId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void dumpPoints(L2PcInstance activeChar)
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if ((holder != null) && !holder.getNodes().isEmpty())
|
||||
{
|
||||
if (holder.getName().isEmpty())
|
||||
{
|
||||
activeChar.sendMessage("Set name first!");
|
||||
return;
|
||||
}
|
||||
|
||||
final Location firstNode = holder.getNodes().get(0);
|
||||
final StringJoiner sj = new StringJoiner(Config.EOL);
|
||||
sj.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
||||
sj.add("<list enabled=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"../../data/xsd/zones.xsd\">");
|
||||
sj.add("\t<zone name=\"" + holder.getName() + "\" type=\"ScriptZone\" shape=\"NPoly\" minZ=\"" + (holder.getMinZ() != 0 ? holder.getMinZ() : firstNode.getZ() - 100) + "\" maxZ=\"" + (holder.getMaxZ() != 0 ? holder.getMaxZ() : firstNode.getZ() + 100) + "\">");
|
||||
for (Location loc : holder.getNodes())
|
||||
{
|
||||
sj.add("\t\t<node X=\"" + loc.getX() + "\" Y=\"" + loc.getY() + "\" />");
|
||||
}
|
||||
sj.add("\t</zone>");
|
||||
sj.add("</list>");
|
||||
sj.add(""); // new line at end of file
|
||||
try
|
||||
{
|
||||
File file = new File("log/points/" + activeChar.getAccountName() + "/" + holder.getName() + ".xml");
|
||||
if (file.exists())
|
||||
{
|
||||
int i = 0;
|
||||
while ((file = new File("log/points/" + activeChar.getAccountName() + "/" + holder.getName() + i + ".xml")).exists())
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (!file.getParentFile().isDirectory())
|
||||
{
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
Files.write(file.toPath(), sj.toString().getBytes(StandardCharsets.UTF_8));
|
||||
activeChar.sendMessage("Successfully written on: " + file.getAbsolutePath().replace(new File(".").getCanonicalFile().getAbsolutePath(), ""));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed writing the dump: " + e.getMessage());
|
||||
_log.log(Level.WARNING, "Failed writing point picking dump for " + activeChar.getName() + ":" + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_MOVE_REQUEST)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
@Priority(Integer.MAX_VALUE)
|
||||
public TerminateReturn onPlayerPointPicking(OnPlayerMoveRequest event)
|
||||
{
|
||||
final L2PcInstance activeChar = event.getActiveChar();
|
||||
if (activeChar.hasAction(PlayerAction.ADMIN_POINT_PICKING))
|
||||
{
|
||||
final Location newLocation = event.getLocation();
|
||||
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder(activeChar));
|
||||
final Location changeLog = holder.getChangingLoc();
|
||||
if (changeLog != null)
|
||||
{
|
||||
changeLog.setXYZ(newLocation);
|
||||
holder.setChangingLoc(null);
|
||||
activeChar.sendMessage("Location " + (holder.indexOf(changeLog) + 1) + " has been updated!");
|
||||
disablePicking(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
holder.addNode(newLocation);
|
||||
activeChar.sendMessage("Location " + (holder.indexOf(changeLog) + 1) + " has been added!");
|
||||
}
|
||||
// Auto visualization when nodes >= 3
|
||||
if (holder.getNodes().size() >= 3)
|
||||
{
|
||||
showPoints(activeChar);
|
||||
}
|
||||
buildHtmlWindow(activeChar, 0);
|
||||
|
||||
return new TerminateReturn(true, true, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@RegisterEvent(EventType.ON_PLAYER_DLG_ANSWER)
|
||||
@RegisterType(ListenerRegisterType.GLOBAL_PLAYERS)
|
||||
public void onPlayerDlgAnswer(OnPlayerDlgAnswer event)
|
||||
{
|
||||
final L2PcInstance activeChar = event.getActiveChar();
|
||||
if (activeChar.removeAction(PlayerAction.ADMIN_SHOW_TERRITORY) && (event.getAnswer() == 1))
|
||||
{
|
||||
final ZoneNodeHolder holder = _zones.get(activeChar.getObjectId());
|
||||
if (holder != null)
|
||||
{
|
||||
final List<Location> list = holder.getNodes();
|
||||
if (list.size() < 3)
|
||||
{
|
||||
activeChar.sendMessage("You must have at least 3 nodes to use this option!");
|
||||
return;
|
||||
}
|
||||
|
||||
final Location firstLoc = list.get(0);
|
||||
final int minZ = holder.getMinZ() != 0 ? holder.getMinZ() : firstLoc.getZ() - 100;
|
||||
final int maxZ = holder.getMaxZ() != 0 ? holder.getMaxZ() : firstLoc.getZ() + 100;
|
||||
final ExShowTerritory exst = new ExShowTerritory(minZ, maxZ);
|
||||
list.forEach(exst::addVertice);
|
||||
activeChar.sendPacket(exst);
|
||||
activeChar.sendMessage("In order to remove the debug you must restart your game client!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
|
||||
private void buildHtmlWindow(L2PcInstance activeChar, int page)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/zone_editor_create.htm");
|
||||
final ZoneNodeHolder holder = _zones.computeIfAbsent(activeChar.getObjectId(), key -> new ZoneNodeHolder(activeChar));
|
||||
final AtomicInteger position = new AtomicInteger(page * 20);
|
||||
|
||||
final PageResult result = PageBuilder.newBuilder(holder.getNodes(), 20, "bypass -h admin_zones list").currentPage(page).bodyHandler((pages, loc, sb) ->
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td fixwidth=5></td>");
|
||||
sb.append("<td fixwidth=20>" + position.getAndIncrement() + "</td>");
|
||||
sb.append("<td fixwidth=60>" + loc.getX() + "</td>");
|
||||
sb.append("<td fixwidth=60>" + loc.getY() + "</td>");
|
||||
sb.append("<td fixwidth=60>" + loc.getZ() + "</td>");
|
||||
sb.append("<td fixwidth=30><a action=\"bypass -h admin_zones change " + holder.indexOf(loc) + "\">[E]</a></td>");
|
||||
sb.append("<td fixwidth=30><a action=\"bypass -h admin_move_to " + loc.getX() + " " + loc.getY() + " " + loc.getZ() + "\">[T]</a></td>");
|
||||
sb.append("<td fixwidth=30><a action=\"bypass -h admin_zones delete " + holder.indexOf(loc) + "\">[D]</a></td>");
|
||||
sb.append("<td fixwidth=5></td>");
|
||||
sb.append("</tr>");
|
||||
}).build();
|
||||
|
||||
msg.replace("%name%", holder.getName());
|
||||
msg.replace("%minZ%", holder.getMinZ());
|
||||
msg.replace("%maxZ%", holder.getMaxZ());
|
||||
msg.replace("%pages%", result.getPagerTemplate());
|
||||
msg.replace("%nodes%", result.getBodyTemplate());
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
|
||||
protected class ZoneNodeHolder
|
||||
{
|
||||
private String _name = "";
|
||||
private Location _changingLoc = null;
|
||||
private int _minZ;
|
||||
private int _maxZ;
|
||||
private final List<Location> _nodes = new ArrayList<>();
|
||||
|
||||
public ZoneNodeHolder(L2PcInstance player)
|
||||
{
|
||||
_minZ = player.getZ() - 200;
|
||||
_maxZ = player.getZ() + 200;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void setChangingLoc(Location loc)
|
||||
{
|
||||
_changingLoc = loc;
|
||||
}
|
||||
|
||||
public Location getChangingLoc()
|
||||
{
|
||||
return _changingLoc;
|
||||
}
|
||||
|
||||
public void addNode(Location loc)
|
||||
{
|
||||
_nodes.add(loc);
|
||||
}
|
||||
|
||||
public List<Location> getNodes()
|
||||
{
|
||||
return _nodes;
|
||||
}
|
||||
|
||||
public int indexOf(Location loc)
|
||||
{
|
||||
return _nodes.indexOf(loc);
|
||||
}
|
||||
|
||||
public int getMinZ()
|
||||
{
|
||||
return _minZ;
|
||||
}
|
||||
|
||||
public int getMaxZ()
|
||||
{
|
||||
return _maxZ;
|
||||
}
|
||||
|
||||
public void setMinZ(int minZ)
|
||||
{
|
||||
_minZ = minZ;
|
||||
}
|
||||
|
||||
public void setMaxZ(int maxZ)
|
||||
{
|
||||
_maxZ = maxZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +1,66 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
|
||||
|
||||
public class Augment implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Augment"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (Integer.parseInt(command.substring(8, 9).trim()))
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
activeChar.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
activeChar.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowVariationCancelWindow;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExShowVariationMakeWindow;
|
||||
|
||||
public class Augment implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Augment"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (Integer.parseInt(command.substring(8, 9).trim()))
|
||||
{
|
||||
case 1:
|
||||
activeChar.sendPacket(ExShowVariationMakeWindow.STATIC_PACKET);
|
||||
return true;
|
||||
case 2:
|
||||
activeChar.sendPacket(ExShowVariationCancelWindow.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class Buy implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Buy"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
|
||||
if (st.countTokens() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
((L2MerchantInstance) target).showBuyWindow(activeChar, Integer.parseInt(st.nextToken()));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class Buy implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Buy"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
|
||||
if (st.countTokens() < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
((L2MerchantInstance) target).showBuyWindow(activeChar, Integer.parseInt(st.nextToken()));
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +1,68 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class BuyShadowItem implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"BuyShadowItem"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc) target).getObjectId());
|
||||
if (activeChar.getLevel() < 40)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item-lowlevel.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 40) && (activeChar.getLevel() < 46))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_d.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 46) && (activeChar.getLevel() < 52))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_c.htm");
|
||||
}
|
||||
else if (activeChar.getLevel() >= 52)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_b.htm");
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class BuyShadowItem implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"BuyShadowItem"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
|
||||
if (activeChar.getLevel() < 40)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item-lowlevel.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 40) && (activeChar.getLevel() < 46))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_d.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 46) && (activeChar.getLevel() < 52))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_c.htm");
|
||||
}
|
||||
else if (activeChar.getLevel() >= 52)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_b.htm");
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(target.getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,68 +1,69 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
|
||||
public class ChatLink implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Chat"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (Exception ioobe)
|
||||
{
|
||||
}
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
if ((val == 0) && npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar, val);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jmobius.gameserver.model.events.EventType;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
|
||||
public class ChatLink implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Chat"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (Exception ioobe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
if ((val == 0) && npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar, val);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,176 +1,126 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2ClanHallManagerInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2WarehouseInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseDepositList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
|
||||
|
||||
public class ClanWarehouse implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"withdrawc",
|
||||
"withdrawsortedc",
|
||||
"depositc"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2WarehouseInstance) && !(target instanceof L2ClanHallManagerInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.getClan() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.getClan().getLevel() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
|
||||
{
|
||||
if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/mods/WhSortedC.htm");
|
||||
msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
showWithdrawWindow(activeChar, null, (byte) 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedC
|
||||
{
|
||||
final String param[] = command.split(" ");
|
||||
|
||||
if (param.length > 2)
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.getOrder(param[2]));
|
||||
}
|
||||
else if (param.length > 1)
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositC
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
|
||||
activeChar.setInventoryBlockingStatus(true);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Source: L2WarehouseInstance.java; Player: " + activeChar.getName() + "; Command: showDepositWindowClan; Message: Showing items to deposit.");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void showWithdrawWindow(L2PcInstance player, WarehouseListType itemtype, byte sortorder)
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
if (!player.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return;
|
||||
}
|
||||
|
||||
player.setActiveWarehouse(player.getClan().getWarehouse());
|
||||
|
||||
if (player.getActiveWarehouse().getSize() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ItemInstance i : player.getActiveWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
|
||||
{
|
||||
player.getActiveWarehouse().destroyItem("L2ItemInstance", i, player, null);
|
||||
}
|
||||
}
|
||||
if (itemtype != null)
|
||||
{
|
||||
player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN, itemtype, sortorder));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Source: L2WarehouseInstance.java; Player: " + player.getName() + "; Command: showRetrieveWindowClan; Message: Showing stored items.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.ClanPrivilege;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2WarehouseInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseDepositList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
|
||||
|
||||
public class ClanWarehouse implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"withdrawc",
|
||||
"depositc"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
if (!(npc instanceof L2WarehouseInstance) && (npc.getClan() != null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getClan() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
else if (activeChar.getClan().getLevel() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
if (!activeChar.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
|
||||
|
||||
if (activeChar.getActiveWarehouse().getSize() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (L2ItemInstance i : activeChar.getActiveWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
|
||||
{
|
||||
activeChar.getActiveWarehouse().destroyItem("L2ItemInstance", i, activeChar, null);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.CLAN));
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // DepositC
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
|
||||
activeChar.setInventoryBlockingStatus(true);
|
||||
activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Gigi
|
||||
*/
|
||||
public class CrystalCavernsMovie implements IBypassHandler
|
||||
{
|
||||
// NPC
|
||||
private static final int FIOREN = 33044;
|
||||
// Others
|
||||
private static final int CRYSTAL_CAVERNS_MOVIE = 106;
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"CrystalCavernsMovie"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc() || (((L2NpcInstance) target).getId() != FIOREN))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.showQuestMovie(CRYSTAL_CAVERNS_MOVIE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +1,51 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
|
||||
|
||||
/**
|
||||
* @author Mathael
|
||||
*/
|
||||
public class Ensoul implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"ensoul"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ensoul.ExShowEnsoulWindow;
|
||||
|
||||
/**
|
||||
* @author St3eT
|
||||
*/
|
||||
public class EnsoulWindow implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"show_ensoul_window",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(ExShowEnsoulWindow.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
|
||||
public class EventEngine implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"event_participate",
|
||||
"event_unregister"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.equalsIgnoreCase("event_participate"))
|
||||
{
|
||||
L2Event.registerPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
else if (command.equalsIgnoreCase("event_unregister"))
|
||||
{
|
||||
L2Event.removeAndResetPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.entity.L2Event;
|
||||
|
||||
public class EventEngine implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"event_participate",
|
||||
"event_unregister"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.equalsIgnoreCase("event_participate"))
|
||||
{
|
||||
L2Event.registerPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
else if (command.equalsIgnoreCase("event_unregister"))
|
||||
{
|
||||
L2Event.removeAndResetPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +1,89 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcFreight;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PackageToList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Freight implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"package_withdraw",
|
||||
"package_deposit"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase(COMMANDS[0]))
|
||||
{
|
||||
final PcFreight freight = activeChar.getFreight();
|
||||
if (freight != null)
|
||||
{
|
||||
if (freight.getSize() > 0)
|
||||
{
|
||||
activeChar.setActiveWarehouse(freight);
|
||||
for (L2ItemInstance i : activeChar.getActiveWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
|
||||
{
|
||||
activeChar.getActiveWarehouse().destroyItem("L2ItemInstance", i, activeChar, null);
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.FREIGHT));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase(COMMANDS[1]))
|
||||
{
|
||||
if (activeChar.getAccountChars().size() < 1)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_CHARACTER_DOES_NOT_EXIST);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new PackageToList(activeChar.getAccountChars()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcFreight;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.PackageToList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.WareHouseWithdrawalList;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class Freight implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"package_withdraw",
|
||||
"package_deposit"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.equalsIgnoreCase(COMMANDS[0]))
|
||||
{
|
||||
final PcFreight freight = activeChar.getFreight();
|
||||
if (freight != null)
|
||||
{
|
||||
if (freight.getSize() > 0)
|
||||
{
|
||||
activeChar.setActiveWarehouse(freight);
|
||||
for (L2ItemInstance i : activeChar.getActiveWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
|
||||
{
|
||||
activeChar.getActiveWarehouse().destroyItem("L2ItemInstance", i, activeChar, null);
|
||||
}
|
||||
}
|
||||
activeChar.sendPacket(new WareHouseWithdrawalList(activeChar, WareHouseWithdrawalList.FREIGHT));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase(COMMANDS[1]))
|
||||
{
|
||||
if (activeChar.getAccountChars().size() < 1)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_CHARACTER_DOES_NOT_EXIST);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new PackageToList(activeChar.getAccountChars()));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuction;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExItemAuctionInfoPacket;
|
||||
|
||||
public class ItemAuctionLink implements IBypassHandler
|
||||
{
|
||||
private static final SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
|
||||
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"ItemAuction"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.ALT_ITEM_AUCTION_ENABLED)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
final ItemAuctionInstance au = ItemAuctionManager.getInstance().getManagerInstance(target.getId());
|
||||
if (au == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // bypass "ItemAuction"
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String cmd = st.nextToken();
|
||||
if ("show".equalsIgnoreCase(cmd))
|
||||
{
|
||||
if (!activeChar.getFloodProtectors().getItemAuction().tryPerformAction("RequestInfoItemAuction"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isItemAuctionPolling())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final ItemAuction currentAuction = au.getCurrentAuction();
|
||||
final ItemAuction nextAuction = au.getNextAuction();
|
||||
|
||||
if (currentAuction == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
|
||||
|
||||
if (nextAuction != null)
|
||||
{
|
||||
activeChar.sendMessage("The next auction will begin on the " + fmt.format(new Date(nextAuction.getStartingTime())) + ".");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExItemAuctionInfoPacket(false, currentAuction, nextAuction));
|
||||
}
|
||||
else if ("cancel".equalsIgnoreCase(cmd))
|
||||
{
|
||||
final ItemAuction[] auctions = au.getAuctionsByBidder(activeChar.getObjectId());
|
||||
boolean returned = false;
|
||||
for (ItemAuction auction : auctions)
|
||||
{
|
||||
if (auction.cancelBid(activeChar))
|
||||
{
|
||||
returned = true;
|
||||
}
|
||||
}
|
||||
if (!returned)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OFFERINGS_I_OWN_OR_I_MADE_A_BID_FOR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.instancemanager.ItemAuctionManager;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuction;
|
||||
import com.l2jmobius.gameserver.model.itemauction.ItemAuctionInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExItemAuctionInfoPacket;
|
||||
|
||||
public class ItemAuctionLink implements IBypassHandler
|
||||
{
|
||||
private static final SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
|
||||
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"ItemAuction"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Config.ALT_ITEM_AUCTION_ENABLED)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
|
||||
return true;
|
||||
}
|
||||
|
||||
final ItemAuctionInstance au = ItemAuctionManager.getInstance().getManagerInstance(target.getId());
|
||||
if (au == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // bypass "ItemAuction"
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final String cmd = st.nextToken();
|
||||
if ("show".equalsIgnoreCase(cmd))
|
||||
{
|
||||
if (!activeChar.getFloodProtectors().getItemAuction().tryPerformAction("RequestInfoItemAuction"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.isItemAuctionPolling())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final ItemAuction currentAuction = au.getCurrentAuction();
|
||||
final ItemAuction nextAuction = au.getNextAuction();
|
||||
|
||||
if (currentAuction == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_AN_AUCTION_PERIOD);
|
||||
|
||||
if (nextAuction != null)
|
||||
{
|
||||
activeChar.sendMessage("The next auction will begin on the " + fmt.format(new Date(nextAuction.getStartingTime())) + ".");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExItemAuctionInfoPacket(false, currentAuction, nextAuction));
|
||||
}
|
||||
else if ("cancel".equalsIgnoreCase(cmd))
|
||||
{
|
||||
final ItemAuction[] auctions = au.getAuctionsByBidder(activeChar.getObjectId());
|
||||
boolean returned = false;
|
||||
for (ItemAuction auction : auctions)
|
||||
{
|
||||
if (auction.cancelBid(activeChar))
|
||||
{
|
||||
returned = true;
|
||||
}
|
||||
}
|
||||
if (!returned)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THERE_ARE_NO_OFFERINGS_I_OWN_OR_I_MADE_A_BID_FOR);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class Link implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Link"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
final String htmlPath = command.substring(4).trim();
|
||||
if (htmlPath.isEmpty())
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent empty link html!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (htmlPath.contains(".."))
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent invalid link html: " + htmlPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String filename = "html/" + htmlPath;
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), filename);
|
||||
html.replace("%objectId%", String.valueOf(target != null ? target.getObjectId() : 0));
|
||||
activeChar.sendPacket(html);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class Link implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Link"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
final String htmlPath = command.substring(4).trim();
|
||||
if (htmlPath.isEmpty())
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent empty link html!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (htmlPath.contains(".."))
|
||||
{
|
||||
_log.warning("Player " + activeChar.getName() + " sent invalid link html: " + htmlPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String filename = "data/html/" + htmlPath;
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(target != null ? target.getObjectId() : 0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), filename);
|
||||
html.replace("%objectId%", String.valueOf(target != null ? target.getObjectId() : 0));
|
||||
activeChar.sendPacket(html);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,356 +1,348 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.games.Lottery;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class Loto implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Loto"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (IndexOutOfBoundsException ioobe)
|
||||
{
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
}
|
||||
if (val == 0)
|
||||
{
|
||||
// new loto ticket
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
activeChar.setLoto(i, 0);
|
||||
}
|
||||
}
|
||||
showLotoWindow(activeChar, (L2Npc) target, val);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a Loto window on client with the text of the L2NpcInstance.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Get the text of the selected HTML file in function of the npcId and of the page number</li>
|
||||
* <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance</li>
|
||||
* <li>Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet</li><BR>
|
||||
* @param player The L2PcInstance that talk with the L2NpcInstance
|
||||
* @param npc L2Npc loto instance
|
||||
* @param val The number of the page of the L2NpcInstance to display
|
||||
*/
|
||||
// 0 - first buy lottery ticket window
|
||||
// 1-20 - buttons
|
||||
// 21 - second buy lottery ticket window
|
||||
// 22 - selected ticket with 5 numbers
|
||||
// 23 - current lottery jackpot
|
||||
// 24 - Previous winning numbers/Prize claim
|
||||
// >24 - check lottery ticket by item object id
|
||||
private static void showLotoWindow(L2PcInstance player, L2Npc npc, int val)
|
||||
{
|
||||
final int npcId = npc.getTemplate().getId();
|
||||
String filename;
|
||||
SystemMessage sm;
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
|
||||
|
||||
if (val == 0) // 0 - first buy lottery ticket window
|
||||
{
|
||||
filename = npc.getHtmlPath(npcId, 1);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if ((val >= 1) && (val <= 21)) // 1-20 - buttons, 21 - second buy lottery ticket window
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
filename = npc.getHtmlPath(npcId, 5);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
int count = 0;
|
||||
int found = 0;
|
||||
// counting buttons and unsetting button if found
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == val)
|
||||
{
|
||||
// unsetting button
|
||||
player.setLoto(i, 0);
|
||||
found = 1;
|
||||
}
|
||||
else if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// if not rearched limit 5 and not unseted value
|
||||
if ((count < 5) && (found == 0) && (val <= 20))
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == 0)
|
||||
{
|
||||
player.setLoto(i, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setting pusshed buttons
|
||||
count = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
String button = String.valueOf(player.getLoto(i));
|
||||
if (player.getLoto(i) < 10)
|
||||
{
|
||||
button = "0" + button;
|
||||
}
|
||||
final String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
|
||||
final String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 5)
|
||||
{
|
||||
final String search = "0\">Return";
|
||||
final String replace = "22\">Your lucky numbers have been selected above.";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
}
|
||||
else if (val == 22) // 22 - selected ticket with 5 numbers
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
final long price = Config.ALT_LOTTERY_TICKET_PRICE;
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
int enchant = 0;
|
||||
int type2 = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getLoto(i) < 17)
|
||||
{
|
||||
enchant += Math.pow(2, player.getLoto(i) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
type2 += Math.pow(2, player.getLoto(i) - 17);
|
||||
}
|
||||
}
|
||||
if (player.getAdena() < price)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
if (!player.reduceAdena("Loto", price, npc, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Lottery.getInstance().increasePrize(price);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
|
||||
item.setCount(1);
|
||||
item.setCustomType1(lotonumber);
|
||||
item.setEnchantLevel(enchant);
|
||||
item.setCustomType2(type2);
|
||||
player.getInventory().addItem("Loto", item, player, npc);
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItem(item);
|
||||
final L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
|
||||
iu.addModifiedItem(adenaupdate);
|
||||
player.sendPacket(iu);
|
||||
|
||||
filename = npc.getHtmlPath(npcId, 6);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 23) // 23 - current lottery jackpot
|
||||
{
|
||||
filename = npc.getHtmlPath(npcId, 3);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 24) // 24 - Previous winning numbers/Prize claim
|
||||
{
|
||||
filename = npc.getHtmlPath(npcId, 4);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
String message = "";
|
||||
for (L2ItemInstance item : player.getInventory().getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((item.getId() == 4442) && (item.getCustomType1() < lotonumber))
|
||||
{
|
||||
message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
|
||||
final int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(), item.getCustomType2());
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
message += numbers[i] + " ";
|
||||
}
|
||||
final long[] check = Lottery.getInstance().checkTicket(item);
|
||||
if (check[0] > 0)
|
||||
{
|
||||
switch ((int) check[0])
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
message += "- 1st Prize";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
message += "- 2nd Prize";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
message += "- 3th Prize";
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
message += "- 4th Prize";
|
||||
break;
|
||||
}
|
||||
}
|
||||
message += " " + check[1] + "a.";
|
||||
}
|
||||
message += "</a><br>";
|
||||
}
|
||||
}
|
||||
if (message.isEmpty())
|
||||
{
|
||||
message += "There has been no winning lottery ticket.<br>";
|
||||
}
|
||||
html.replace("%result%", message);
|
||||
}
|
||||
else if (val == 25) // 25 - lottery instructions
|
||||
{
|
||||
filename = npc.getHtmlPath(npcId, 2);
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val > 25) // >25 - check lottery ticket by item object id
|
||||
{
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
final L2ItemInstance item = player.getInventory().getItemByObjectId(val);
|
||||
if ((item == null) || (item.getId() != 4442) || (item.getCustomType1() >= lotonumber))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final long[] check = Lottery.getInstance().checkTicket(item);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
final long adena = check[1];
|
||||
if (adena > 0)
|
||||
{
|
||||
player.addAdena("Loto", adena, npc, true);
|
||||
}
|
||||
player.destroyItem("Loto", item, npc, false);
|
||||
return;
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(npc.getObjectId()));
|
||||
html.replace("%race%", "" + Lottery.getInstance().getId());
|
||||
html.replace("%adena%", "" + Lottery.getInstance().getPrize());
|
||||
html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
|
||||
html.replace("%prize5%", "" + (Config.ALT_LOTTERY_5_NUMBER_RATE * 100));
|
||||
html.replace("%prize4%", "" + (Config.ALT_LOTTERY_4_NUMBER_RATE * 100));
|
||||
html.replace("%prize3%", "" + (Config.ALT_LOTTERY_3_NUMBER_RATE * 100));
|
||||
html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
|
||||
html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
|
||||
player.sendPacket(html);
|
||||
|
||||
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import com.l2jmobius.gameserver.instancemanager.games.Lottery;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class Loto implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Loto"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (IndexOutOfBoundsException ioobe)
|
||||
{
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
}
|
||||
if (val == 0)
|
||||
{
|
||||
// new loto ticket
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
activeChar.setLoto(i, 0);
|
||||
}
|
||||
}
|
||||
showLotoWindow(activeChar, (L2Npc) target, val);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a Loto window on client with the text of the L2NpcInstance.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Get the text of the selected HTML file in function of the npcId and of the page number</li>
|
||||
* <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance</li>
|
||||
* <li>Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet</li><BR>
|
||||
* @param player The L2PcInstance that talk with the L2NpcInstance
|
||||
* @param npc L2Npc loto instance
|
||||
* @param val The number of the page of the L2NpcInstance to display
|
||||
*/
|
||||
// 0 - first buy lottery ticket window
|
||||
// 1-20 - buttons
|
||||
// 21 - second buy lottery ticket window
|
||||
// 22 - selected ticket with 5 numbers
|
||||
// 23 - current lottery jackpot
|
||||
// 24 - Previous winning numbers/Prize claim
|
||||
// >24 - check lottery ticket by item object id
|
||||
public static final void showLotoWindow(L2PcInstance player, L2Npc npc, int val)
|
||||
{
|
||||
final int npcId = npc.getTemplate().getId();
|
||||
String filename;
|
||||
SystemMessage sm;
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
|
||||
|
||||
if (val == 0) // 0 - first buy lottery ticket window
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 1));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if ((val >= 1) && (val <= 21)) // 1-20 - buttons, 21 - second buy lottery ticket window
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
filename = (npc.getHtmlPath(npcId, 5));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
int count = 0;
|
||||
int found = 0;
|
||||
// counting buttons and unsetting button if found
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == val)
|
||||
{
|
||||
// unsetting button
|
||||
player.setLoto(i, 0);
|
||||
found = 1;
|
||||
}
|
||||
else if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
// if not rearched limit 5 and not unseted value
|
||||
if ((count < 5) && (found == 0) && (val <= 20))
|
||||
{
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == 0)
|
||||
{
|
||||
player.setLoto(i, val);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setting pusshed buttons
|
||||
count = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
String button = String.valueOf(player.getLoto(i));
|
||||
if (player.getLoto(i) < 10)
|
||||
{
|
||||
button = "0" + button;
|
||||
}
|
||||
final String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
|
||||
final String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 5)
|
||||
{
|
||||
final String search = "0\">Return";
|
||||
final String replace = "22\">Your lucky numbers have been selected above.";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
}
|
||||
else if (val == 22) // 22 - selected ticket with 5 numbers
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.LOTTERY_TICKETS_ARE_NOT_CURRENTLY_BEING_SOLD);
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
// tickets can't be sold
|
||||
player.sendPacket(SystemMessageId.TICKETS_FOR_THE_CURRENT_LOTTERY_ARE_NO_LONGER_AVAILABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
final long price = Config.ALT_LOTTERY_TICKET_PRICE;
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
int enchant = 0;
|
||||
int type2 = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getLoto(i) < 17)
|
||||
{
|
||||
enchant += Math.pow(2, player.getLoto(i) - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
type2 += Math.pow(2, player.getLoto(i) - 17);
|
||||
}
|
||||
}
|
||||
if (player.getAdena() < price)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
if (!player.reduceAdena("Loto", price, npc, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Lottery.getInstance().increasePrize(price);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
final L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
|
||||
item.setCount(1);
|
||||
item.setCustomType1(lotonumber);
|
||||
item.setEnchantLevel(enchant);
|
||||
item.setCustomType2(type2);
|
||||
player.getInventory().addItem("Loto", item, player, npc);
|
||||
|
||||
final InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItem(item);
|
||||
final L2ItemInstance adenaupdate = player.getInventory().getAdenaInstance();
|
||||
iu.addModifiedItem(adenaupdate);
|
||||
player.sendInventoryUpdate(iu);
|
||||
|
||||
filename = (npc.getHtmlPath(npcId, 6));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 23) // 23 - current lottery jackpot
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 3));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 24) // 24 - Previous winning numbers/Prize claim
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 4));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
String message = "";
|
||||
for (L2ItemInstance item : player.getInventory().getItems())
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((item.getId() == 4442) && (item.getCustomType1() < lotonumber))
|
||||
{
|
||||
message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
|
||||
final int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(), item.getCustomType2());
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
message += numbers[i] + " ";
|
||||
}
|
||||
final long[] check = Lottery.getInstance().checkTicket(item);
|
||||
if (check[0] > 0)
|
||||
{
|
||||
switch ((int) check[0])
|
||||
{
|
||||
case 1:
|
||||
message += "- 1st Prize";
|
||||
break;
|
||||
case 2:
|
||||
message += "- 2nd Prize";
|
||||
break;
|
||||
case 3:
|
||||
message += "- 3th Prize";
|
||||
break;
|
||||
case 4:
|
||||
message += "- 4th Prize";
|
||||
break;
|
||||
}
|
||||
message += " " + check[1] + "a.";
|
||||
}
|
||||
message += "</a><br>";
|
||||
}
|
||||
}
|
||||
if (message.isEmpty())
|
||||
{
|
||||
message += "There has been no winning lottery ticket.<br>";
|
||||
}
|
||||
html.replace("%result%", message);
|
||||
}
|
||||
else if (val == 25) // 25 - lottery instructions
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 2));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val > 25) // >25 - check lottery ticket by item object id
|
||||
{
|
||||
final int lotonumber = Lottery.getInstance().getId();
|
||||
final L2ItemInstance item = player.getInventory().getItemByObjectId(val);
|
||||
if ((item == null) || (item.getId() != 4442) || (item.getCustomType1() >= lotonumber))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final long[] check = Lottery.getInstance().checkTicket(item);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
final long adena = check[1];
|
||||
if (adena > 0)
|
||||
{
|
||||
player.addAdena("Loto", adena, npc, true);
|
||||
}
|
||||
player.destroyItem("Loto", item, npc, false);
|
||||
return;
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(npc.getObjectId()));
|
||||
html.replace("%race%", "" + Lottery.getInstance().getId());
|
||||
html.replace("%adena%", "" + Lottery.getInstance().getPrize());
|
||||
html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
|
||||
html.replace("%prize5%", "" + (Config.ALT_LOTTERY_5_NUMBER_RATE * 100));
|
||||
html.replace("%prize4%", "" + (Config.ALT_LOTTERY_4_NUMBER_RATE * 100));
|
||||
html.replace("%prize3%", "" + (Config.ALT_LOTTERY_3_NUMBER_RATE * 100));
|
||||
html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
|
||||
html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
|
||||
player.sendPacket(html);
|
||||
|
||||
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class Multisell implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"multisell",
|
||||
"exc_multisell"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int listId;
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(9).trim());
|
||||
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, false);
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // exc_multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(13).trim());
|
||||
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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.bypasshandlers;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.l2jmobius.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jmobius.gameserver.handler.IBypassHandler;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class Multisell implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"multisell",
|
||||
"exc_multisell"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int listId;
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(9).trim());
|
||||
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, false);
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // exc_multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(13).trim());
|
||||
MultisellData.getInstance().separateAndSend(listId, activeChar, (L2Npc) target, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user