Helios branch.

This commit is contained in:
MobiusDev
2017-01-20 09:19:54 +00:00
parent 34b1bd66b4
commit 37cff65ca0
20608 changed files with 3742400 additions and 0 deletions

View 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);
}
}

View 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.DailyMissionHandler;
import handlers.dailymissionhandlers.BossDailyMissionHandler;
import handlers.dailymissionhandlers.CeremonyOfChaosDailyMissionHandler;
import handlers.dailymissionhandlers.FishingDailyMissionHandler;
import handlers.dailymissionhandlers.LevelDailyMissionHandler;
import handlers.dailymissionhandlers.OlympiadDailyMissionHandler;
import handlers.dailymissionhandlers.QuestDailyMissionHandler;
import handlers.dailymissionhandlers.SiegeDailyMissionHandler;
/**
* @author UnAfraid
*/
public class DailyMissionMasterHandler
{
private static final Logger LOGGER = Logger.getLogger(DailyMissionMasterHandler.class.getName());
public static void main(String[] args)
{
DailyMissionHandler.getInstance().registerHandler("level", LevelDailyMissionHandler::new);
// DailyMissionHandler.getInstance().registerHandler("loginAllWeek", LoginAllWeekDailyMissionHandler::new);
// DailyMissionHandler.getInstance().registerHandler("loginAllMonth", LoginAllWeekDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("quest", QuestDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("olympiad", OlympiadDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("siege", SiegeDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("ceremonyofchaos", CeremonyOfChaosDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("boss", BossDailyMissionHandler::new);
DailyMissionHandler.getInstance().registerHandler("fishing", FishingDailyMissionHandler::new);
LOGGER.info(DailyMissionMasterHandler.class.getSimpleName() + ": Loaded " + DailyMissionHandler.getInstance().size() + " handlers.");
}
}

View File

@@ -0,0 +1,347 @@
/*
* 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("AttackAttributeAdd", AttackAttributeAdd::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("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("FlipBlock", FlipBlock::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("GiveXp", GiveXp::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("JewelSlot", JewelSlot::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("ReduceDamage", ReduceDamage::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("RewardItemOnExit", RewardItemOnExit::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("FlyAway", FlyAway::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.");
}
}

View File

@@ -0,0 +1,705 @@
/*
* 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.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.ActionHandler;
import com.l2jmobius.gameserver.handler.ActionShiftHandler;
import com.l2jmobius.gameserver.handler.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.AffectObjectHandler;
import com.l2jmobius.gameserver.handler.AffectScopeHandler;
import com.l2jmobius.gameserver.handler.BypassHandler;
import com.l2jmobius.gameserver.handler.ChatHandler;
import com.l2jmobius.gameserver.handler.CommunityBoardHandler;
import com.l2jmobius.gameserver.handler.IHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
import com.l2jmobius.gameserver.handler.PlayerActionHandler;
import com.l2jmobius.gameserver.handler.PunishmentHandler;
import com.l2jmobius.gameserver.handler.TargetHandler;
import com.l2jmobius.gameserver.handler.UserCommandHandler;
import com.l2jmobius.gameserver.handler.VoicedCommandHandler;
import handlers.actionhandlers.L2ArtefactInstanceAction;
import handlers.actionhandlers.L2DecoyAction;
import handlers.actionhandlers.L2DoorInstanceAction;
import handlers.actionhandlers.L2ItemInstanceAction;
import handlers.actionhandlers.L2NpcAction;
import handlers.actionhandlers.L2PcInstanceAction;
import handlers.actionhandlers.L2PetInstanceAction;
import handlers.actionhandlers.L2StaticObjectInstanceAction;
import handlers.actionhandlers.L2SummonAction;
import handlers.actionhandlers.L2TrapAction;
import handlers.actionshifthandlers.L2DoorInstanceActionShift;
import handlers.actionshifthandlers.L2ItemInstanceActionShift;
import handlers.actionshifthandlers.L2NpcActionShift;
import handlers.actionshifthandlers.L2PcInstanceActionShift;
import handlers.actionshifthandlers.L2StaticObjectInstanceActionShift;
import handlers.actionshifthandlers.L2SummonActionShift;
import handlers.admincommandhandlers.AdminAdmin;
import handlers.admincommandhandlers.AdminAnnouncements;
import handlers.admincommandhandlers.AdminBBS;
import handlers.admincommandhandlers.AdminBuffs;
import handlers.admincommandhandlers.AdminCamera;
import handlers.admincommandhandlers.AdminCastle;
import handlers.admincommandhandlers.AdminChangeAccessLevel;
import handlers.admincommandhandlers.AdminClan;
import handlers.admincommandhandlers.AdminClanHall;
import handlers.admincommandhandlers.AdminCreateItem;
import handlers.admincommandhandlers.AdminCursedWeapons;
import handlers.admincommandhandlers.AdminDebug;
import handlers.admincommandhandlers.AdminDelete;
import handlers.admincommandhandlers.AdminDisconnect;
import handlers.admincommandhandlers.AdminDoorControl;
import handlers.admincommandhandlers.AdminEditChar;
import handlers.admincommandhandlers.AdminEffects;
import handlers.admincommandhandlers.AdminElement;
import handlers.admincommandhandlers.AdminEnchant;
import handlers.admincommandhandlers.AdminEventEngine;
import handlers.admincommandhandlers.AdminEvents;
import handlers.admincommandhandlers.AdminExpSp;
import handlers.admincommandhandlers.AdminFightCalculator;
import handlers.admincommandhandlers.AdminFortSiege;
import handlers.admincommandhandlers.AdminGeodata;
import handlers.admincommandhandlers.AdminGm;
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminHwid;
import handlers.admincommandhandlers.AdminInstance;
import handlers.admincommandhandlers.AdminInstanceZone;
import handlers.admincommandhandlers.AdminInvul;
import handlers.admincommandhandlers.AdminKick;
import handlers.admincommandhandlers.AdminKill;
import handlers.admincommandhandlers.AdminLevel;
import handlers.admincommandhandlers.AdminLogin;
import handlers.admincommandhandlers.AdminManor;
import handlers.admincommandhandlers.AdminMenu;
import handlers.admincommandhandlers.AdminMessages;
import handlers.admincommandhandlers.AdminMobGroup;
import handlers.admincommandhandlers.AdminMonsterRace;
import handlers.admincommandhandlers.AdminOlympiad;
import handlers.admincommandhandlers.AdminPForge;
import handlers.admincommandhandlers.AdminPathNode;
import handlers.admincommandhandlers.AdminPcCafePoints;
import handlers.admincommandhandlers.AdminPcCondOverride;
import handlers.admincommandhandlers.AdminPetition;
import handlers.admincommandhandlers.AdminPledge;
import handlers.admincommandhandlers.AdminPolymorph;
import handlers.admincommandhandlers.AdminPremium;
import handlers.admincommandhandlers.AdminPrimePoints;
import handlers.admincommandhandlers.AdminPunishment;
import handlers.admincommandhandlers.AdminQuest;
import handlers.admincommandhandlers.AdminReload;
import handlers.admincommandhandlers.AdminRepairChar;
import handlers.admincommandhandlers.AdminRes;
import handlers.admincommandhandlers.AdminRide;
import handlers.admincommandhandlers.AdminScan;
import handlers.admincommandhandlers.AdminServerInfo;
import handlers.admincommandhandlers.AdminShop;
import handlers.admincommandhandlers.AdminShowQuests;
import handlers.admincommandhandlers.AdminShutdown;
import handlers.admincommandhandlers.AdminSkill;
import handlers.admincommandhandlers.AdminSpawn;
import handlers.admincommandhandlers.AdminSummon;
import handlers.admincommandhandlers.AdminTarget;
import handlers.admincommandhandlers.AdminTargetSay;
import handlers.admincommandhandlers.AdminTeleport;
import handlers.admincommandhandlers.AdminTest;
import handlers.admincommandhandlers.AdminUnblockIp;
import handlers.admincommandhandlers.AdminVitality;
import handlers.admincommandhandlers.AdminZone;
import handlers.admincommandhandlers.AdminZones;
import handlers.bypasshandlers.Augment;
import handlers.bypasshandlers.Buy;
import handlers.bypasshandlers.BuyShadowItem;
import handlers.bypasshandlers.ChatLink;
import handlers.bypasshandlers.ClanWarehouse;
import handlers.bypasshandlers.EnsoulWindow;
import handlers.bypasshandlers.EventEngine;
import handlers.bypasshandlers.Freight;
import handlers.bypasshandlers.ItemAuctionLink;
import handlers.bypasshandlers.Link;
import handlers.bypasshandlers.Multisell;
import handlers.bypasshandlers.NpcViewMod;
import handlers.bypasshandlers.Observation;
import handlers.bypasshandlers.PlayerHelp;
import handlers.bypasshandlers.PrivateWarehouse;
import handlers.bypasshandlers.QuestLink;
import handlers.bypasshandlers.ReleaseAttribute;
import handlers.bypasshandlers.SkillList;
import handlers.bypasshandlers.TerritoryStatus;
import handlers.bypasshandlers.TutorialClose;
import handlers.bypasshandlers.VoiceCommand;
import handlers.bypasshandlers.Wear;
import handlers.chathandlers.ChatAlliance;
import handlers.chathandlers.ChatClan;
import handlers.chathandlers.ChatGeneral;
import handlers.chathandlers.ChatHeroVoice;
import handlers.chathandlers.ChatParty;
import handlers.chathandlers.ChatPartyMatchRoom;
import handlers.chathandlers.ChatPartyRoomAll;
import handlers.chathandlers.ChatPartyRoomCommander;
import handlers.chathandlers.ChatPetition;
import handlers.chathandlers.ChatShout;
import handlers.chathandlers.ChatTrade;
import handlers.chathandlers.ChatWhisper;
import handlers.chathandlers.ChatWorld;
import handlers.communityboard.ClanBoard;
import handlers.communityboard.DropSearchBoard;
import handlers.communityboard.FavoriteBoard;
import handlers.communityboard.FriendsBoard;
import handlers.communityboard.HomeBoard;
import handlers.communityboard.HomepageBoard;
import handlers.communityboard.MailBoard;
import handlers.communityboard.MemoBoard;
import handlers.communityboard.RegionBoard;
import handlers.itemhandlers.Appearance;
import handlers.itemhandlers.BeastSoulShot;
import handlers.itemhandlers.BeastSpiritShot;
import handlers.itemhandlers.BlessedSpiritShot;
import handlers.itemhandlers.Book;
import handlers.itemhandlers.Bypass;
import handlers.itemhandlers.Calculator;
import handlers.itemhandlers.CharmOfCourage;
import handlers.itemhandlers.Elixir;
import handlers.itemhandlers.EnchantAttribute;
import handlers.itemhandlers.EnchantScrolls;
import handlers.itemhandlers.EventItem;
import handlers.itemhandlers.ExtractableItems;
import handlers.itemhandlers.FatedSupportBox;
import handlers.itemhandlers.FishShots;
import handlers.itemhandlers.Harvester;
import handlers.itemhandlers.ItemSkills;
import handlers.itemhandlers.ItemSkillsTemplate;
import handlers.itemhandlers.Maps;
import handlers.itemhandlers.MercTicket;
import handlers.itemhandlers.NicknameColor;
import handlers.itemhandlers.PetFood;
import handlers.itemhandlers.Recipes;
import handlers.itemhandlers.RollingDice;
import handlers.itemhandlers.Seed;
import handlers.itemhandlers.SoulShots;
import handlers.itemhandlers.SpecialXMas;
import handlers.itemhandlers.SpiritShot;
import handlers.itemhandlers.SummonItems;
import handlers.playeractions.AirshipAction;
import handlers.playeractions.BotReport;
import handlers.playeractions.InstanceZoneInfo;
import handlers.playeractions.PetAttack;
import handlers.playeractions.PetHold;
import handlers.playeractions.PetMove;
import handlers.playeractions.PetSkillUse;
import handlers.playeractions.PetStop;
import handlers.playeractions.PrivateStore;
import handlers.playeractions.Ride;
import handlers.playeractions.RunWalk;
import handlers.playeractions.ServitorAttack;
import handlers.playeractions.ServitorHold;
import handlers.playeractions.ServitorMode;
import handlers.playeractions.ServitorMove;
import handlers.playeractions.ServitorSkillUse;
import handlers.playeractions.ServitorStop;
import handlers.playeractions.SitStand;
import handlers.playeractions.SocialAction;
import handlers.playeractions.TacticalSignTarget;
import handlers.playeractions.TacticalSignUse;
import handlers.playeractions.TeleportBookmark;
import handlers.playeractions.UnsummonPet;
import handlers.playeractions.UnsummonServitor;
import handlers.punishmenthandlers.BanHandler;
import handlers.punishmenthandlers.ChatBanHandler;
import handlers.punishmenthandlers.JailHandler;
import handlers.targethandlers.AdvanceBase;
import handlers.targethandlers.Artillery;
import handlers.targethandlers.DoorTreasure;
import handlers.targethandlers.Enemy;
import handlers.targethandlers.EnemyNot;
import handlers.targethandlers.EnemyOnly;
import handlers.targethandlers.FortressFlagpole;
import handlers.targethandlers.Ground;
import handlers.targethandlers.HolyThing;
import handlers.targethandlers.Item;
import handlers.targethandlers.MyMentor;
import handlers.targethandlers.MyParty;
import handlers.targethandlers.None;
import handlers.targethandlers.NpcBody;
import handlers.targethandlers.Others;
import handlers.targethandlers.PcBody;
import handlers.targethandlers.Self;
import handlers.targethandlers.Summon;
import handlers.targethandlers.Target;
import handlers.targethandlers.WyvernTarget;
import handlers.targethandlers.affectobject.All;
import handlers.targethandlers.affectobject.Clan;
import handlers.targethandlers.affectobject.Friend;
import handlers.targethandlers.affectobject.FriendPc;
import handlers.targethandlers.affectobject.HiddenPlace;
import handlers.targethandlers.affectobject.Invisible;
import handlers.targethandlers.affectobject.NotFriend;
import handlers.targethandlers.affectobject.NotFriendPc;
import handlers.targethandlers.affectobject.ObjectDeadNpcBody;
import handlers.targethandlers.affectobject.UndeadRealEnemy;
import handlers.targethandlers.affectobject.WyvernObject;
import handlers.targethandlers.affectscope.BalakasScope;
import handlers.targethandlers.affectscope.DeadParty;
import handlers.targethandlers.affectscope.DeadPartyPledge;
import handlers.targethandlers.affectscope.DeadPledge;
import handlers.targethandlers.affectscope.DeadUnion;
import handlers.targethandlers.affectscope.Fan;
import handlers.targethandlers.affectscope.FanPB;
import handlers.targethandlers.affectscope.Party;
import handlers.targethandlers.affectscope.PartyPledge;
import handlers.targethandlers.affectscope.Pledge;
import handlers.targethandlers.affectscope.PointBlank;
import handlers.targethandlers.affectscope.Range;
import handlers.targethandlers.affectscope.RangeSortByHp;
import handlers.targethandlers.affectscope.RingRange;
import handlers.targethandlers.affectscope.Single;
import handlers.targethandlers.affectscope.Square;
import handlers.targethandlers.affectscope.SquarePB;
import handlers.targethandlers.affectscope.StaticObjectScope;
import handlers.targethandlers.affectscope.SummonExceptMaster;
import handlers.usercommandhandlers.ChannelDelete;
import handlers.usercommandhandlers.ChannelInfo;
import handlers.usercommandhandlers.ChannelLeave;
import handlers.usercommandhandlers.ClanPenalty;
import handlers.usercommandhandlers.ClanWarsList;
import handlers.usercommandhandlers.Dismount;
import handlers.usercommandhandlers.ExperienceGain;
import handlers.usercommandhandlers.InstanceZone;
import handlers.usercommandhandlers.Loc;
import handlers.usercommandhandlers.Mount;
import handlers.usercommandhandlers.MyBirthday;
import handlers.usercommandhandlers.OlympiadStat;
import handlers.usercommandhandlers.PartyInfo;
import handlers.usercommandhandlers.SiegeStatus;
import handlers.usercommandhandlers.Time;
import handlers.usercommandhandlers.Unstuck;
import handlers.voicedcommandhandlers.Banking;
import handlers.voicedcommandhandlers.ChangePassword;
import handlers.voicedcommandhandlers.ChatAdmin;
import handlers.voicedcommandhandlers.Debug;
import handlers.voicedcommandhandlers.Lang;
import handlers.voicedcommandhandlers.Premium;
import handlers.voicedcommandhandlers.StatsVCmd;
/**
* Master handler.
* @author UnAfraid
*/
public class MasterHandler
{
private static final Logger _log = Logger.getLogger(MasterHandler.class.getName());
private static final IHandler<?, ?>[] LOAD_INSTANCES =
{
ActionHandler.getInstance(),
ActionShiftHandler.getInstance(),
AdminCommandHandler.getInstance(),
BypassHandler.getInstance(),
ChatHandler.getInstance(),
CommunityBoardHandler.getInstance(),
ItemHandler.getInstance(),
PunishmentHandler.getInstance(),
UserCommandHandler.getInstance(),
VoicedCommandHandler.getInstance(),
TargetHandler.getInstance(),
AffectObjectHandler.getInstance(),
AffectScopeHandler.getInstance(),
PlayerActionHandler.getInstance()
};
private static final Class<?>[][] HANDLERS =
{
{
// Action Handlers
L2ArtefactInstanceAction.class,
L2DecoyAction.class,
L2DoorInstanceAction.class,
L2ItemInstanceAction.class,
L2NpcAction.class,
L2PcInstanceAction.class,
L2PetInstanceAction.class,
L2StaticObjectInstanceAction.class,
L2SummonAction.class,
L2TrapAction.class,
},
{
// Action Shift Handlers
L2DoorInstanceActionShift.class,
L2ItemInstanceActionShift.class,
L2NpcActionShift.class,
L2PcInstanceActionShift.class,
L2StaticObjectInstanceActionShift.class,
L2SummonActionShift.class,
},
{
// Admin Command Handlers
AdminAdmin.class,
AdminAnnouncements.class,
AdminBBS.class,
AdminBuffs.class,
AdminCamera.class,
AdminChangeAccessLevel.class,
AdminClan.class,
AdminClanHall.class,
AdminCastle.class,
AdminPcCondOverride.class,
AdminCreateItem.class,
AdminCursedWeapons.class,
AdminDebug.class,
AdminDelete.class,
AdminDisconnect.class,
AdminDoorControl.class,
AdminEditChar.class,
AdminEffects.class,
AdminElement.class,
AdminEnchant.class,
AdminEventEngine.class,
AdminEvents.class,
AdminExpSp.class,
AdminFightCalculator.class,
AdminFortSiege.class,
AdminGeodata.class,
AdminGm.class,
AdminGmChat.class,
AdminGraciaSeeds.class,
AdminGrandBoss.class,
AdminHeal.class,
AdminHtml.class,
AdminHwid.class,
AdminInstance.class,
AdminInstanceZone.class,
AdminInvul.class,
AdminKick.class,
AdminKill.class,
AdminLevel.class,
AdminLogin.class,
AdminManor.class,
AdminMenu.class,
AdminMessages.class,
AdminMobGroup.class,
AdminMonsterRace.class,
AdminOlympiad.class,
AdminPathNode.class,
AdminPcCafePoints.class,
AdminPetition.class,
AdminPForge.class,
AdminPledge.class,
AdminZones.class,
AdminPolymorph.class,
AdminPremium.class,
AdminPrimePoints.class,
AdminPunishment.class,
AdminQuest.class,
AdminReload.class,
AdminRepairChar.class,
AdminRes.class,
AdminRide.class,
AdminScan.class,
AdminServerInfo.class,
AdminShop.class,
AdminShowQuests.class,
AdminShutdown.class,
AdminSkill.class,
AdminSpawn.class,
AdminSummon.class,
AdminTarget.class,
AdminTargetSay.class,
AdminTeleport.class,
AdminTest.class,
AdminUnblockIp.class,
AdminVitality.class,
AdminZone.class,
},
{
// Bypass Handlers
Augment.class,
Buy.class,
BuyShadowItem.class,
ChatLink.class,
ClanWarehouse.class,
EnsoulWindow.class,
EventEngine.class,
Freight.class,
ItemAuctionLink.class,
Link.class,
Multisell.class,
NpcViewMod.class,
Observation.class,
QuestLink.class,
PlayerHelp.class,
PrivateWarehouse.class,
ReleaseAttribute.class,
SkillList.class,
TerritoryStatus.class,
TutorialClose.class,
VoiceCommand.class,
Wear.class,
},
{
// Chat Handlers
ChatGeneral.class,
ChatAlliance.class,
ChatClan.class,
ChatHeroVoice.class,
ChatParty.class,
ChatPartyMatchRoom.class,
ChatPartyRoomAll.class,
ChatPartyRoomCommander.class,
ChatPetition.class,
ChatShout.class,
ChatWhisper.class,
ChatTrade.class,
ChatWorld.class,
},
{
// Community Board
ClanBoard.class,
FavoriteBoard.class,
FriendsBoard.class,
HomeBoard.class,
HomepageBoard.class,
MailBoard.class,
MemoBoard.class,
RegionBoard.class,
DropSearchBoard.class,
},
{
// Item Handlers
Appearance.class,
BeastSoulShot.class,
BeastSpiritShot.class,
BlessedSpiritShot.class,
Book.class,
Bypass.class,
Calculator.class,
CharmOfCourage.class,
Elixir.class,
EnchantAttribute.class,
EnchantScrolls.class,
EventItem.class,
ExtractableItems.class,
FatedSupportBox.class,
FishShots.class,
Harvester.class,
ItemSkills.class,
ItemSkillsTemplate.class,
Maps.class,
MercTicket.class,
NicknameColor.class,
PetFood.class,
Recipes.class,
RollingDice.class,
Seed.class,
SoulShots.class,
SpecialXMas.class,
SpiritShot.class,
SummonItems.class,
},
{
// Punishment Handlers
BanHandler.class,
ChatBanHandler.class,
JailHandler.class,
},
{
// User Command Handlers
ClanPenalty.class,
ClanWarsList.class,
Dismount.class,
ExperienceGain.class,
Unstuck.class,
InstanceZone.class,
Loc.class,
Mount.class,
PartyInfo.class,
Time.class,
OlympiadStat.class,
ChannelLeave.class,
ChannelDelete.class,
ChannelInfo.class,
MyBirthday.class,
SiegeStatus.class,
},
{
// Voiced Command Handlers
StatsVCmd.class,
// TODO: Add configuration options for this voiced commands:
// CastleVCmd.class,
// SetVCmd.class,
Config.BANKING_SYSTEM_ENABLED ? Banking.class : null,
Config.L2JMOD_CHAT_ADMIN ? ChatAdmin.class : null,
Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW ? Lang.class : null,
Config.L2JMOD_DEBUG_VOICE_COMMAND ? Debug.class : null,
Config.L2JMOD_ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null,
Config.PREMIUM_SYSTEM_ENABLED ? Premium.class : null,
},
{
// Target Handlers
AdvanceBase.class,
Artillery.class,
DoorTreasure.class,
Enemy.class,
EnemyNot.class,
EnemyOnly.class,
FortressFlagpole.class,
Ground.class,
HolyThing.class,
Item.class,
MyMentor.class,
MyParty.class,
None.class,
NpcBody.class,
Others.class,
PcBody.class,
Self.class,
Summon.class,
Target.class,
WyvernTarget.class,
},
{
// Affect Objects
All.class,
Clan.class,
Friend.class,
FriendPc.class,
HiddenPlace.class,
Invisible.class,
NotFriend.class,
NotFriendPc.class,
ObjectDeadNpcBody.class,
UndeadRealEnemy.class,
WyvernObject.class,
},
{
// Affect Scopes
BalakasScope.class,
DeadParty.class,
DeadPartyPledge.class,
DeadPledge.class,
DeadUnion.class,
Fan.class,
FanPB.class,
Party.class,
PartyPledge.class,
Pledge.class,
PointBlank.class,
Range.class,
RangeSortByHp.class,
RingRange.class,
Single.class,
Square.class,
SquarePB.class,
StaticObjectScope.class,
SummonExceptMaster.class,
},
{
AirshipAction.class,
BotReport.class,
InstanceZoneInfo.class,
PetAttack.class,
PetHold.class,
PetMove.class,
PetSkillUse.class,
PetStop.class,
PrivateStore.class,
Ride.class,
RunWalk.class,
ServitorAttack.class,
ServitorHold.class,
ServitorMode.class,
ServitorMove.class,
ServitorSkillUse.class,
ServitorStop.class,
SitStand.class,
SocialAction.class,
TacticalSignTarget.class,
TacticalSignUse.class,
TeleportBookmark.class,
UnsummonPet.class,
UnsummonServitor.class
}
};
public static void main(String[] args)
{
_log.info("Loading Handlers...");
final Map<IHandler<?, ?>, Method> registerHandlerMethods = new HashMap<>();
for (IHandler<?, ?> loadInstance : LOAD_INSTANCES)
{
registerHandlerMethods.put(loadInstance, null);
for (Method method : loadInstance.getClass().getMethods())
{
if (method.getName().equals("registerHandler") && !method.isBridge())
{
registerHandlerMethods.put(loadInstance, method);
}
}
}
registerHandlerMethods.entrySet().stream().filter(e -> e.getValue() == null).forEach(e ->
{
_log.warning("Failed loading handlers of: " + e.getKey().getClass().getSimpleName() + " seems registerHandler function does not exist.");
});
for (Class<?> classes[] : HANDLERS)
{
for (Class<?> c : classes)
{
if (c == null)
{
continue; // Disabled handler
}
try
{
final Object handler = c.newInstance();
for (Entry<IHandler<?, ?>, Method> entry : registerHandlerMethods.entrySet())
{
if ((entry.getValue() != null) && entry.getValue().getParameterTypes()[0].isInstance(handler))
{
entry.getValue().invoke(entry.getKey(), handler);
}
}
}
catch (Exception e)
{
_log.log(Level.WARNING, "Failed loading handler: " + c.getSimpleName(), e);
continue;
}
}
}
for (IHandler<?, ?> loadInstance : LOAD_INSTANCES)
{
_log.info(loadInstance.getClass().getSimpleName() + ": Loaded " + loadInstance.size() + " Handlers");
}
_log.info("Handlers Loaded...");
}
}

View 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);
}
}

View File

@@ -0,0 +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.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.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class L2ArtefactInstanceAction implements IActionHandler
{
/**
* Manage actions when a player click on the L2ArtefactInstance.<BR>
* <BR>
* <B><U> Actions</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>Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client</li><BR>
* <BR>
* <B><U> Example of use </U> :</B><BR>
* <BR>
* <li>Client packet : Action, AttackRequest</li><BR>
* <BR>
*/
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
if (!((L2Npc) target).canTarget(activeChar))
{
return false;
}
if (activeChar.getTarget() != target)
{
activeChar.setTarget(target);
}
// Calculate the distance between the L2PcInstance and the L2NpcInstance
else if (interact && !((L2Npc) target).canInteract(activeChar))
{
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2ArtefactInstance;
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.enums.InstanceType;
import com.l2jmobius.gameserver.handler.IActionHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
public class L2DecoyAction implements IActionHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
// Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
{
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
return false;
}
activeChar.setTarget(target);
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2Decoy;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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.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.updateNotMoveUntil();
}
}
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2Npc;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,96 @@
/*
* 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.handler.IActionHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PetInstance;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.PetStatusShow;
public class L2PetInstanceAction implements IActionHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
// Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
{
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
return false;
}
final boolean isOwner = activeChar.getObjectId() == ((L2PetInstance) target).getOwner().getObjectId();
if (isOwner && (activeChar != ((L2PetInstance) target).getOwner()))
{
((L2PetInstance) target).updateRefOwner(activeChar);
}
if (activeChar.getTarget() != target)
{
// Set the target of the L2PcInstance activeChar
activeChar.setTarget(target);
}
else if (interact)
{
// Check if the pet is attackable (without a forced attack) and isn't dead
if (target.isAutoAttackable(activeChar) && !isOwner)
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
// Set the L2PcInstance Intention to AI_INTENTION_ATTACK
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
activeChar.onActionRequest();
}
}
else if (!((L2Character) target).isInsideRadius(activeChar, 150, false, false))
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
activeChar.onActionRequest();
}
}
else
{
if (isOwner)
{
activeChar.sendPacket(new PetStatusShow((L2PetInstance) target));
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSummonTalk((L2Summon) target), (L2Summon) target);
}
activeChar.updateNotMoveUntil();
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2PetInstance;
}
}

View File

@@ -0,0 +1,84 @@
/*
* 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;
}
}

View File

@@ -0,0 +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.actionhandlers;
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.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
import com.l2jmobius.gameserver.network.serverpackets.PetStatusShow;
public class L2SummonAction implements IActionHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
// Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
{
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
return false;
}
if ((activeChar == ((L2Summon) target).getOwner()) && (activeChar.getTarget() == target))
{
activeChar.sendPacket(new PetStatusShow((L2Summon) target));
activeChar.updateNotMoveUntil();
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerSummonTalk((L2Summon) target), (L2Summon) target);
}
else if (activeChar.getTarget() != target)
{
activeChar.setTarget(target);
}
else if (interact)
{
if (target.isAutoAttackable(activeChar))
{
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 (((L2Summon) target).isInsideRadius(activeChar, 150, false, false))
{
activeChar.updateNotMoveUntil();
}
else if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
}
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2Summon;
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.enums.InstanceType;
import com.l2jmobius.gameserver.handler.IActionHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.SystemMessageId;
public class L2TrapAction implements IActionHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
// Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
{
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
return false;
}
activeChar.setTarget(target);
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2TrapInstance;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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;
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;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,54 @@
/*
* 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.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class L2PcInstanceActionShift implements IActionShiftHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
if (activeChar.isGM())
{
// Check if the gm already target this l2pcinstance
if (activeChar.getTarget() != target)
{
// Set the target of the L2PcInstance activeChar
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_character_info");
if (ach != null)
{
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2PcInstance;
}
}

View File

@@ -0,0 +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;
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;
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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.AdminCommandHandler;
import com.l2jmobius.gameserver.handler.IActionShiftHandler;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
public class L2SummonActionShift implements IActionShiftHandler
{
@Override
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
{
if (activeChar.isGM())
{
if (activeChar.getTarget() != target)
{
// Set the target of the L2PcInstance activeChar
activeChar.setTarget(target);
}
final IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler("admin_summon_info");
if (ach != null)
{
ach.useAdminCommand("admin_summon_info", activeChar);
}
}
return true;
}
@Override
public InstanceType getInstanceType()
{
return InstanceType.L2Summon;
}
}

View File

@@ -0,0 +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_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);
}
}

View File

@@ -0,0 +1,507 @@
/*
* 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.cache.HtmCache;
import com.l2jmobius.gameserver.data.sql.impl.AnnouncementsTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.announce.Announcement;
import com.l2jmobius.gameserver.model.announce.AnnouncementType;
import com.l2jmobius.gameserver.model.announce.AutoAnnouncement;
import com.l2jmobius.gameserver.model.announce.IAnnouncement;
import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class AdminAnnouncements implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_announce",
"admin_announce_crit",
"admin_announce_screen",
"admin_announces",
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.hasMoreTokens() ? st.nextToken() : "";
switch (cmd)
{
case "admin_announce":
case "admin_announce_crit":
case "admin_announce_screen":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announce <text to announce here>");
return false;
}
String announce = st.nextToken();
while (st.hasMoreTokens())
{
announce += " " + st.nextToken();
}
if (cmd.equals("admin_announce_screen"))
{
Broadcast.toAllOnlinePlayersOnScreen(announce);
}
else
{
if (Config.GM_ANNOUNCER_NAME)
{
announce = announce + " [" + activeChar.getName() + "]";
}
Broadcast.toAllOnlinePlayers(announce, cmd.equals("admin_announce_crit"));
}
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
break;
}
case "admin_announces":
{
final String subCmd = st.hasMoreTokens() ? st.nextToken() : "";
switch (subCmd)
{
case "add":
{
if (!st.hasMoreTokens())
{
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/announces-add.htm");
Util.sendCBHtml(activeChar, content);
break;
}
final String annType = st.nextToken();
final AnnouncementType type = AnnouncementType.findByName(annType);
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annInitDelay = st.nextToken();
if (!Util.isDigit(annInitDelay))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final int initDelay = Integer.parseInt(annInitDelay) * 1000;
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annDelay = st.nextToken();
if (!Util.isDigit(annDelay))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final int delay = Integer.parseInt(annDelay) * 1000;
if ((delay < (10 * 1000)) && ((type == AnnouncementType.AUTO_NORMAL) || (type == AnnouncementType.AUTO_CRITICAL)))
{
activeChar.sendMessage("Delay cannot be less then 10 seconds!");
break;
}
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annRepeat = st.nextToken();
if (!Util.isDigit(annRepeat))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
int repeat = Integer.parseInt(annRepeat);
if (repeat == 0)
{
repeat = -1;
}
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
String content = st.nextToken();
while (st.hasMoreTokens())
{
content += " " + st.nextToken();
}
// ************************************
final IAnnouncement announce;
if ((type == AnnouncementType.AUTO_CRITICAL) || (type == AnnouncementType.AUTO_NORMAL))
{
announce = new AutoAnnouncement(type, content, activeChar.getName(), initDelay, delay, repeat);
}
else
{
announce = new Announcement(type, content, activeChar.getName());
}
AnnouncementsTable.getInstance().addAnnouncement(announce);
activeChar.sendMessage("Announcement has been successfully added!");
return useAdminCommand("admin_announces list", activeChar);
}
case "edit":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces edit <id>");
break;
}
final String annId = st.nextToken();
if (!Util.isDigit(annId))
{
activeChar.sendMessage("Syntax: //announces edit <id>");
break;
}
final int id = Integer.parseInt(annId);
final IAnnouncement announce = AnnouncementsTable.getInstance().getAnnounce(id);
if (announce == null)
{
activeChar.sendMessage("Announcement doesnt exists!");
break;
}
if (!st.hasMoreTokens())
{
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/announces-edit.htm");
final String announcementId = "" + announce.getId();
final String announcementType = announce.getType().name();
String announcementInital = "0";
String announcementDelay = "0";
String announcementRepeat = "0";
final String announcementAuthor = announce.getAuthor();
final String announcementContent = announce.getContent();
if (announce instanceof AutoAnnouncement)
{
final AutoAnnouncement autoAnnounce = (AutoAnnouncement) announce;
announcementInital = "" + (autoAnnounce.getInitial() / 1000);
announcementDelay = "" + (autoAnnounce.getDelay() / 1000);
announcementRepeat = "" + autoAnnounce.getRepeat();
}
content = content.replaceAll("%id%", announcementId);
content = content.replaceAll("%type%", announcementType);
content = content.replaceAll("%initial%", announcementInital);
content = content.replaceAll("%delay%", announcementDelay);
content = content.replaceAll("%repeat%", announcementRepeat);
content = content.replaceAll("%author%", announcementAuthor);
content = content.replaceAll("%content%", announcementContent);
Util.sendCBHtml(activeChar, content);
break;
}
final String annType = st.nextToken();
final AnnouncementType type = AnnouncementType.findByName(annType);
switch (announce.getType())
{
case AUTO_CRITICAL:
case AUTO_NORMAL:
{
switch (type)
{
case AUTO_CRITICAL:
case AUTO_NORMAL:
{
break;
}
default:
{
activeChar.sendMessage("Announce type can be changed only to AUTO_NORMAL or AUTO_CRITICAL!");
return false;
}
}
break;
}
case NORMAL:
case CRITICAL:
{
switch (type)
{
case NORMAL:
case CRITICAL:
{
break;
}
default:
{
activeChar.sendMessage("Announce type can be changed only to NORMAL or CRITICAL!");
return false;
}
}
break;
}
}
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annInitDelay = st.nextToken();
if (!Util.isDigit(annInitDelay))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final int initDelay = Integer.parseInt(annInitDelay);
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annDelay = st.nextToken();
if (!Util.isDigit(annDelay))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final int delay = Integer.parseInt(annDelay);
if ((delay < 10) && ((type == AnnouncementType.AUTO_NORMAL) || (type == AnnouncementType.AUTO_CRITICAL)))
{
activeChar.sendMessage("Delay cannot be less then 10 seconds!");
break;
}
// ************************************
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
final String annRepeat = st.nextToken();
if (!Util.isDigit(annRepeat))
{
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
break;
}
int repeat = Integer.parseInt(annRepeat);
if (repeat == 0)
{
repeat = -1;
}
// ************************************
String content = "";
if (st.hasMoreTokens())
{
content = st.nextToken();
while (st.hasMoreTokens())
{
content += " " + st.nextToken();
}
}
if (content.isEmpty())
{
content = announce.getContent();
}
// ************************************
announce.setType(type);
announce.setContent(content);
announce.setAuthor(activeChar.getName());
if (announce instanceof AutoAnnouncement)
{
final AutoAnnouncement autoAnnounce = (AutoAnnouncement) announce;
autoAnnounce.setInitial(initDelay * 1000);
autoAnnounce.setDelay(delay * 1000);
autoAnnounce.setRepeat(repeat);
}
announce.updateMe();
activeChar.sendMessage("Announcement has been successfully edited!");
return useAdminCommand("admin_announces list", activeChar);
}
case "remove":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces remove <announcement id>");
break;
}
final String token = st.nextToken();
if (!Util.isDigit(token))
{
activeChar.sendMessage("Syntax: //announces remove <announcement id>");
break;
}
final int id = Integer.parseInt(token);
if (AnnouncementsTable.getInstance().deleteAnnouncement(id))
{
activeChar.sendMessage("Announcement has been successfully removed!");
}
else
{
activeChar.sendMessage("Announcement doesnt exists!");
}
return useAdminCommand("admin_announces list", activeChar);
}
case "restart":
{
if (!st.hasMoreTokens())
{
for (IAnnouncement announce : AnnouncementsTable.getInstance().getAllAnnouncements())
{
if (announce instanceof AutoAnnouncement)
{
final AutoAnnouncement autoAnnounce = (AutoAnnouncement) announce;
autoAnnounce.restartMe();
}
}
activeChar.sendMessage("Auto announcements has been successfully restarted");
break;
}
final String token = st.nextToken();
if (!Util.isDigit(token))
{
activeChar.sendMessage("Syntax: //announces show <announcement id>");
break;
}
final int id = Integer.parseInt(token);
final IAnnouncement announce = AnnouncementsTable.getInstance().getAnnounce(id);
if (announce != null)
{
if (announce instanceof AutoAnnouncement)
{
final AutoAnnouncement autoAnnounce = (AutoAnnouncement) announce;
autoAnnounce.restartMe();
activeChar.sendMessage("Auto announcement has been successfully restarted");
}
else
{
activeChar.sendMessage("This option has effect only on auto announcements!");
}
}
else
{
activeChar.sendMessage("Announcement doesnt exists!");
}
break;
}
case "show":
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Syntax: //announces show <announcement id>");
break;
}
final String token = st.nextToken();
if (!Util.isDigit(token))
{
activeChar.sendMessage("Syntax: //announces show <announcement id>");
break;
}
final int id = Integer.parseInt(token);
final IAnnouncement announce = AnnouncementsTable.getInstance().getAnnounce(id);
if (announce != null)
{
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/announces-show.htm");
final String announcementId = "" + announce.getId();
final String announcementType = announce.getType().name();
String announcementInital = "0";
String announcementDelay = "0";
String announcementRepeat = "0";
final String announcementAuthor = announce.getAuthor();
final String announcementContent = announce.getContent();
if (announce instanceof AutoAnnouncement)
{
final AutoAnnouncement autoAnnounce = (AutoAnnouncement) announce;
announcementInital = "" + (autoAnnounce.getInitial() / 1000);
announcementDelay = "" + (autoAnnounce.getDelay() / 1000);
announcementRepeat = "" + autoAnnounce.getRepeat();
}
content = content.replaceAll("%id%", announcementId);
content = content.replaceAll("%type%", announcementType);
content = content.replaceAll("%initial%", announcementInital);
content = content.replaceAll("%delay%", announcementDelay);
content = content.replaceAll("%repeat%", announcementRepeat);
content = content.replaceAll("%author%", announcementAuthor);
content = content.replaceAll("%content%", announcementContent);
Util.sendCBHtml(activeChar, content);
break;
}
activeChar.sendMessage("Announcement doesnt exists!");
return useAdminCommand("admin_announces list", activeChar);
}
case "list":
{
int page = 0;
if (st.hasMoreTokens())
{
final String token = st.nextToken();
if (Util.isDigit(token))
{
page = Integer.valueOf(token);
}
}
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/announces-list.htm");
final PageResult result = PageBuilder.newBuilder(AnnouncementsTable.getInstance().getAllAnnouncements(), 8, "bypass admin_announces list").currentPage(page).bodyHandler((pages, announcement, sb) ->
{
sb.append("<tr>");
sb.append("<td width=5></td>");
sb.append("<td width=80>" + announcement.getId() + "</td>");
sb.append("<td width=100>" + announcement.getType() + "</td>");
sb.append("<td width=100>" + announcement.getAuthor() + "</td>");
if ((announcement.getType() == AnnouncementType.AUTO_NORMAL) || (announcement.getType() == AnnouncementType.AUTO_CRITICAL))
{
sb.append("<td width=60><button action=\"bypass -h admin_announces restart " + announcement.getId() + "\" value=\"Restart\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
}
else
{
sb.append("<td width=60><button action=\"\" value=\"\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
}
if (announcement.getType() == AnnouncementType.EVENT)
{
sb.append("<td width=60><button action=\"bypass -h admin_announces show " + announcement.getId() + "\" value=\"Show\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
sb.append("<td width=60></td>");
}
else
{
sb.append("<td width=60><button action=\"bypass -h admin_announces show " + announcement.getId() + "\" value=\"Show\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
sb.append("<td width=60><button action=\"bypass -h admin_announces edit " + announcement.getId() + "\" value=\"Edit\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
}
sb.append("<td width=60><button action=\"bypass -h admin_announces remove " + announcement.getId() + "\" value=\"Remove\" width=\"60\" height=\"21\" back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>");
sb.append("<td width=5></td>");
sb.append("</tr>");
}).build();
content = content.replaceAll("%pages%", result.getPagerTemplate().toString());
content = content.replaceAll("%announcements%", result.getBodyTemplate().toString());
Util.sendCBHtml(activeChar, content);
break;
}
}
}
}
return false;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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;
public class AdminBBS implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_bbs"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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 static final 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 + ", ";
}
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() + " (" + 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 + ")", "");
}
}
}
}

View File

@@ -0,0 +1,90 @@
/*
* 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.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.events.AbstractScript;
import com.l2jmobius.gameserver.network.SystemMessageId;
/**
* Camera commands.
* @author Zoey76
*/
public class AdminCamera implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_cam",
"admin_camex",
"admin_cam3"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if ((activeChar.getTarget() == null) || !activeChar.getTarget().isCharacter())
{
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
return false;
}
final L2Character target = (L2Character) activeChar.getTarget();
final String[] com = command.split(" ");
switch (com[0])
{
case "admin_cam":
{
if (com.length != 12)
{
activeChar.sendMessage("Usage: //cam force angle1 angle2 time range duration relYaw relPitch isWide relAngle");
return false;
}
AbstractScript.specialCamera(activeChar, target, Integer.parseInt(com[1]), Integer.parseInt(com[2]), Integer.parseInt(com[3]), Integer.parseInt(com[4]), Integer.parseInt(com[5]), Integer.parseInt(com[6]), Integer.parseInt(com[7]), Integer.parseInt(com[8]), Integer.parseInt(com[9]), Integer.parseInt(com[10]));
break;
}
case "admin_camex":
{
if (com.length != 10)
{
activeChar.sendMessage("Usage: //camex force angle1 angle2 time duration relYaw relPitch isWide relAngle");
return false;
}
AbstractScript.specialCameraEx(activeChar, target, Integer.parseInt(com[1]), Integer.parseInt(com[2]), Integer.parseInt(com[3]), Integer.parseInt(com[4]), Integer.parseInt(com[5]), Integer.parseInt(com[6]), Integer.parseInt(com[7]), Integer.parseInt(com[8]), Integer.parseInt(com[9]));
break;
}
case "admin_cam3":
{
if (com.length != 12)
{
activeChar.sendMessage("Usage: //cam3 force angle1 angle2 time range duration relYaw relPitch isWide relAngle unk");
return false;
}
AbstractScript.specialCamera3(activeChar, target, Integer.parseInt(com[1]), Integer.parseInt(com[2]), Integer.parseInt(com[3]), Integer.parseInt(com[4]), Integer.parseInt(com[5]), Integer.parseInt(com[6]), Integer.parseInt(com[7]), Integer.parseInt(com[8]), Integer.parseInt(com[9]), Integer.parseInt(com[10]), Integer.parseInt(com[11]));
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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())
{
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();
}
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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;
/**
* 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;
}
}

View File

@@ -0,0 +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.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;
public class AdminDebug implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_debug"
};
@Override
public final boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final String[] commandSplit = command.split(" ");
if (ADMIN_COMMANDS[0].equalsIgnoreCase(commandSplit[0]))
{
L2Object target;
if (commandSplit.length > 1)
{
target = L2World.getInstance().getPlayer(commandSplit[1].trim());
if (target == null)
{
activeChar.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
return true;
}
}
else
{
target = activeChar.getTarget();
}
if (target instanceof L2Character)
{
setDebug(activeChar, (L2Character) target);
}
else
{
setDebug(activeChar, activeChar);
}
}
return true;
}
@Override
public final String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
private final void setDebug(L2PcInstance activeChar, L2Character target)
{
if (target.isDebug())
{
target.setDebug(null);
activeChar.sendMessage("Stop debugging " + target.getName());
}
else
{
target.setDebug(activeChar);
activeChar.sendMessage("Start debugging " + target.getName());
}
}
}

View File

@@ -0,0 +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.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.");
}
}
}

View File

@@ -0,0 +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();
}
}
}

View File

@@ -0,0 +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.awt.Color;
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.L2World;
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.network.serverpackets.ExServerPrimitive;
/**
* This class handles following admin commands: - open1 = open coloseum door 24190001 - open2 = open coloseum door 24190002 - open3 = open coloseum door 24190003 - open4 = open coloseum door 24190004 - openall = open all coloseum door - close1 = close coloseum door 24190001 - close2 = close coloseum
* door 24190002 - close3 = close coloseum door 24190003 - close4 = close coloseum door 24190004 - closeall = close all coloseum door - open = open selected door - close = close selected door
* @version $Revision: 1.2.4.5 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminDoorControl implements IAdminCommandHandler
{
private static DoorData _doorTable = DoorData.getInstance();
private static final String[] ADMIN_COMMANDS =
{
"admin_open",
"admin_close",
"admin_openall",
"admin_closeall",
"admin_showdoors"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
try
{
if (command.startsWith("admin_open "))
{
final int doorId = Integer.parseInt(command.substring(11));
if (_doorTable.getDoor(doorId) != null)
{
_doorTable.getDoor(doorId).openMe();
}
else
{
for (Castle castle : CastleManager.getInstance().getCastles())
{
if (castle.getDoor(doorId) != null)
{
castle.getDoor(doorId).openMe();
}
}
}
}
else if (command.startsWith("admin_close "))
{
final int doorId = Integer.parseInt(command.substring(12));
if (_doorTable.getDoor(doorId) != null)
{
_doorTable.getDoor(doorId).closeMe();
}
else
{
for (Castle castle : CastleManager.getInstance().getCastles())
{
if (castle.getDoor(doorId) != null)
{
castle.getDoor(doorId).closeMe();
}
}
}
}
else if (command.equals("admin_closeall"))
{
for (L2DoorInstance door : _doorTable.getDoors())
{
door.closeMe();
}
for (Castle castle : CastleManager.getInstance().getCastles())
{
for (L2DoorInstance door : castle.getDoors())
{
door.closeMe();
}
}
}
else if (command.equals("admin_openall"))
{
for (L2DoorInstance door : _doorTable.getDoors())
{
door.openMe();
}
for (Castle castle : CastleManager.getInstance().getCastles())
{
for (L2DoorInstance door : castle.getDoors())
{
door.openMe();
}
}
}
else if (command.equals("admin_open"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2DoorInstance)
{
((L2DoorInstance) target).openMe();
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
else if (command.equals("admin_close"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2DoorInstance)
{
((L2DoorInstance) target).closeMe();
}
else
{
activeChar.sendMessage("Incorrect target.");
}
}
else if (command.equals("admin_showdoors"))
{
L2World.getInstance().forEachVisibleObject(activeChar, L2DoorInstance.class, door ->
{
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)
{
e.printStackTrace();
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,823 @@
/*
* 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.Arrays;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.SkillData;
import com.l2jmobius.gameserver.enums.Movie;
import com.l2jmobius.gameserver.enums.Team;
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.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2ChestInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.holders.MovieHolder;
import com.l2jmobius.gameserver.model.html.PageBuilder;
import com.l2jmobius.gameserver.model.html.PageResult;
import com.l2jmobius.gameserver.model.html.styles.ButtonsStyle;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.Earthquake;
import com.l2jmobius.gameserver.network.serverpackets.ExRedSky;
import com.l2jmobius.gameserver.network.serverpackets.IClientOutgoingPacket;
import com.l2jmobius.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.OnEventTrigger;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.network.serverpackets.SocialAction;
import com.l2jmobius.gameserver.network.serverpackets.SunRise;
import com.l2jmobius.gameserver.network.serverpackets.SunSet;
import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.Util;
/**
* This class handles following admin commands:
* <li>invis/invisible/vis/visible = makes yourself invisible or visible
* <li>earthquake = causes an earthquake of a given intensity and duration around you
* <li>bighead/shrinkhead = changes head size
* <li>gmspeed = temporary Super Haste effect.
* <li>para/unpara = paralyze/remove paralysis from target
* <li>para_all/unpara_all = same as para/unpara, affects the whole world.
* <li>polyself/unpolyself = makes you look as a specified mob.
* <li>changename = temporary change name
* <li>clearteams/setteam_close/setteam = team related commands
* <li>social = forces an L2Character instance to broadcast social action packets.
* <li>effect = forces an L2Character instance to broadcast MSU packets.
* <li>abnormal = force changes over an L2Character instance's abnormal state.
* <li>play_sound/play_sounds = Music broadcasting related commands
* <li>atmosphere = sky change related commands.
*/
public class AdminEffects implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_invis",
"admin_invisible",
"admin_setinvis",
"admin_vis",
"admin_visible",
"admin_invis_menu",
"admin_earthquake",
"admin_earthquake_menu",
"admin_bighead",
"admin_shrinkhead",
"admin_gmspeed",
"admin_gmspeed_menu",
"admin_unpara_all",
"admin_para_all",
"admin_unpara",
"admin_para",
"admin_unpara_all_menu",
"admin_para_all_menu",
"admin_unpara_menu",
"admin_para_menu",
"admin_polyself",
"admin_unpolyself",
"admin_polyself_menu",
"admin_unpolyself_menu",
"admin_clearteams",
"admin_setteam_close",
"admin_setteam",
"admin_social",
"admin_effect",
"admin_effect_menu",
"admin_ave_abnormal",
"admin_social_menu",
"admin_play_sounds",
"admin_play_sound",
"admin_atmosphere",
"admin_atmosphere_menu",
"admin_set_displayeffect",
"admin_set_displayeffect_menu",
"admin_event_trigger",
"admin_settargetable",
"admin_playmovie",
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken();
if (command.equals("admin_invis_menu"))
{
if (!activeChar.isInvisible())
{
activeChar.setInvisible(true);
activeChar.broadcastUserInfo();
activeChar.decayMe();
activeChar.spawnMe();
activeChar.startAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
activeChar.sendMessage("You are now invisible.");
}
else
{
activeChar.setInvisible(false);
activeChar.broadcastUserInfo();
activeChar.stopAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
activeChar.sendMessage("You are now visible.");
}
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
else if (command.startsWith("admin_invis"))
{
activeChar.setInvisible(true);
activeChar.broadcastUserInfo();
activeChar.decayMe();
activeChar.spawnMe();
activeChar.startAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
activeChar.sendMessage("You are now invisible.");
}
else if (command.startsWith("admin_vis"))
{
activeChar.setInvisible(false);
activeChar.broadcastUserInfo();
activeChar.stopAbnormalVisualEffect(AbnormalVisualEffect.STEALTH);
activeChar.sendMessage("You are now visible.");
}
else if (command.startsWith("admin_setinvis"))
{
if ((activeChar.getTarget() == null) || !activeChar.getTarget().isCharacter())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return false;
}
final L2Character target = (L2Character) activeChar.getTarget();
target.setInvisible(!target.isInvisible());
activeChar.sendMessage("You've made " + target.getName() + " " + (target.isInvisible() ? "invisible" : "visible") + ".");
if (target.isPlayer())
{
((L2PcInstance) target).broadcastUserInfo();
}
}
else if (command.startsWith("admin_earthquake"))
{
try
{
final String val1 = st.nextToken();
final int intensity = Integer.parseInt(val1);
final String val2 = st.nextToken();
final int duration = Integer.parseInt(val2);
final Earthquake eq = new Earthquake(activeChar.getX(), activeChar.getY(), activeChar.getZ(), intensity, duration);
activeChar.broadcastPacket(eq);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //earthquake <intensity> <duration>");
}
}
else if (command.startsWith("admin_atmosphere"))
{
try
{
final String type = st.nextToken();
final String state = st.nextToken();
final int duration = Integer.parseInt(st.nextToken());
adminAtmosphere(type, state, duration, activeChar);
}
catch (Exception ex)
{
activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
}
}
else if (command.equals("admin_play_sounds"))
{
AdminHtml.showAdminHtml(activeChar, "songs/songs.htm");
}
else if (command.startsWith("admin_play_sounds"))
{
try
{
AdminHtml.showAdminHtml(activeChar, "songs/songs" + command.substring(18) + ".htm");
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Usage: //play_sounds <pagenumber>");
}
}
else if (command.startsWith("admin_play_sound"))
{
try
{
playAdminSound(activeChar, command.substring(17));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Usage: //play_sound <soundname>");
}
}
else if (command.equals("admin_para_all"))
{
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
if (!player.isGM())
{
player.startAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
player.setBlockActions(true);
player.startParalyze();
player.broadcastInfo();
}
});
}
else if (command.equals("admin_unpara_all"))
{
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
player.stopAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
player.setBlockActions(false);
player.broadcastInfo();
});
}
else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
{
String type = "1";
try
{
type = st.nextToken();
}
catch (Exception e)
{
}
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
if (type.equals("1"))
{
player.startAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
}
else
{
player.startAbnormalVisualEffect(AbnormalVisualEffect.FLESH_STONE);
}
player.setBlockActions(true);
player.startParalyze();
player.broadcastInfo();
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("admin_unpara")) // || command.startsWith("admin_unpara_menu"))
{
String type = "1";
try
{
type = st.nextToken();
}
catch (Exception e)
{
}
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
if (type.equals("1"))
{
player.stopAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
}
else
{
player.stopAbnormalVisualEffect(AbnormalVisualEffect.FLESH_STONE);
}
player.setBlockActions(false);
player.broadcastInfo();
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("admin_bighead"))
{
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
player.startAbnormalVisualEffect(AbnormalVisualEffect.BIG_HEAD);
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("admin_shrinkhead"))
{
try
{
final L2Object target = activeChar.getTarget();
L2Character player = null;
if (target instanceof L2Character)
{
player = (L2Character) target;
player.stopAbnormalVisualEffect(AbnormalVisualEffect.BIG_HEAD);
}
}
catch (Exception e)
{
}
}
else if (command.startsWith("admin_gmspeed"))
{
try
{
final int val = Integer.parseInt(st.nextToken());
final boolean sendMessage = activeChar.isAffectedBySkill(7029);
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
if ((val >= 1) && (val <= 4))
{
int time = 0;
if (st.hasMoreTokens())
{
time = Integer.parseInt(st.nextToken());
}
final Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
gmSpeedSkill.applyEffects(activeChar, activeChar, true, time);
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //gmspeed <Effect level (0-4)> <Time in seconds>");
}
if (command.contains("_menu"))
{
command = "";
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
}
}
else if (command.startsWith("admin_polyself"))
{
try
{
final String id = st.nextToken();
activeChar.getPoly().setPolyInfo("npc", id);
activeChar.teleToLocation(activeChar.getLocation());
activeChar.broadcastUserInfo();
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //polyself <npcId>");
}
}
else if (command.startsWith("admin_unpolyself"))
{
activeChar.getPoly().setPolyInfo(null, "1");
activeChar.decayMe();
activeChar.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
activeChar.broadcastUserInfo();
}
else if (command.equals("admin_clearteams"))
{
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player ->
{
player.setTeam(Team.NONE);
player.broadcastUserInfo();
});
}
else if (command.startsWith("admin_setteam_close"))
{
try
{
final String val = st.nextToken();
int radius = 400;
if (st.hasMoreTokens())
{
radius = Integer.parseInt(st.nextToken());
}
final Team team = Team.valueOf(val.toUpperCase());
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2PcInstance.class, radius, player -> player.setTeam(team));
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //setteam_close <none|blue|red> [radius]");
}
}
else if (command.startsWith("admin_setteam"))
{
try
{
final Team team = Team.valueOf(st.nextToken().toUpperCase());
L2Character target = null;
if (activeChar.getTarget() instanceof L2Character)
{
target = (L2Character) activeChar.getTarget();
}
else
{
return false;
}
target.setTeam(team);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //setteam <none|blue|red>");
}
}
else if (command.startsWith("admin_social"))
{
try
{
String target = null;
L2Object obj = activeChar.getTarget();
if (st.countTokens() == 2)
{
final int social = Integer.parseInt(st.nextToken());
target = st.nextToken();
if (target != null)
{
final L2PcInstance player = L2World.getInstance().getPlayer(target);
if (player != null)
{
if (performSocial(social, player, activeChar))
{
activeChar.sendMessage(player.getName() + " was affected by your request.");
}
}
else
{
try
{
final int radius = Integer.parseInt(target);
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Object.class, radius, object -> performSocial(social, object, activeChar));
activeChar.sendMessage(radius + " units radius affected by your request.");
}
catch (NumberFormatException nbe)
{
activeChar.sendMessage("Incorrect parameter");
}
}
}
}
else if (st.countTokens() == 1)
{
final int social = Integer.parseInt(st.nextToken());
if (obj == null)
{
obj = activeChar;
}
if (performSocial(social, obj, activeChar))
{
activeChar.sendMessage(obj.getName() + " was affected by your request.");
}
else
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
}
}
else if (!command.contains("menu"))
{
activeChar.sendMessage("Usage: //social <social_id> [player_name|radius]");
}
}
catch (Exception e)
{
if (Config.DEBUG)
{
e.printStackTrace();
}
}
}
else if (command.startsWith("admin_ave_abnormal"))
{
String param1 = null;
if (st.countTokens() > 0)
{
param1 = st.nextToken();
}
if ((param1 != null) && !Util.isDigit(param1))
{
AbnormalVisualEffect ave;
try
{
ave = AbnormalVisualEffect.valueOf(param1);
}
catch (Exception e)
{
return false;
}
int radius = 0;
String param2 = null;
if (st.countTokens() == 1)
{
param2 = st.nextToken();
if (Util.isDigit(param2))
{
radius = Integer.parseInt(param2);
}
}
if (radius > 0)
{
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Object.class, radius, object -> performAbnormalVisualEffect(ave, object));
activeChar.sendMessage("Affected all characters in radius " + param2 + " by " + param1 + " abnormal visual effect.");
}
else
{
final L2Object obj = activeChar.getTarget() != null ? activeChar.getTarget() : activeChar;
if (performAbnormalVisualEffect(ave, obj))
{
activeChar.sendMessage(obj.getName() + " affected by " + param1 + " abnormal visual effect.");
}
else
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
}
}
}
else
{
int page = 0;
if (param1 != null)
{
try
{
page = Integer.parseInt(param1);
}
catch (NumberFormatException nfe)
{
activeChar.sendMessage("Incorrect page.");
}
}
final PageResult result = PageBuilder.newBuilder(AbnormalVisualEffect.values(), 100, "bypass -h admin_ave_abnormal").currentPage(page).style(ButtonsStyle.INSTANCE).bodyHandler((pages, ave, sb) ->
{
sb.append(String.format("<button action=\"bypass admin_ave_abnormal %s\" align=left icon=teleport>%s(%d)</button>", ave.name(), ave.name(), ave.getClientId()));
}).build();
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/ave_abnormal.htm");
if (result.getPages() > 0)
{
html.replace("%pages%", "<table width=280 cellspacing=0><tr>" + result.getPagerTemplate() + "</tr></table>");
}
else
{
html.replace("%pages%", "");
}
html.replace("%abnormals%", result.getBodyTemplate().toString());
activeChar.sendPacket(html);
activeChar.sendMessage("Usage: //" + command.replace("admin_", "") + " <AbnormalVisualEffect> [radius]");
return true;
}
}
else if (command.startsWith("admin_effect"))
{
try
{
L2Object obj = activeChar.getTarget();
int level = 1, hittime = 1;
final int skill = Integer.parseInt(st.nextToken());
if (st.hasMoreTokens())
{
level = Integer.parseInt(st.nextToken());
}
if (st.hasMoreTokens())
{
hittime = Integer.parseInt(st.nextToken());
}
if (obj == null)
{
obj = activeChar;
}
if (!(obj instanceof L2Character))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else
{
final L2Character target = (L2Character) obj;
target.broadcastPacket(new MagicSkillUse(target, activeChar, skill, level, hittime, 0));
activeChar.sendMessage(obj.getName() + " performs MSU " + skill + "/" + level + " by your request.");
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //effect skill [level | level hittime]");
}
}
else if (command.startsWith("admin_set_displayeffect"))
{
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2Npc))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return false;
}
final L2Npc npc = (L2Npc) target;
try
{
final String type = st.nextToken();
final int diplayeffect = Integer.parseInt(type);
npc.setDisplayEffect(diplayeffect);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //set_displayeffect <id>");
}
}
else if (command.startsWith("admin_playmovie"))
{
try
{
new MovieHolder(Arrays.asList(activeChar), Movie.findByClientId(Integer.parseInt(st.nextToken())));
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //playmovie <id>");
}
}
else if (command.startsWith("admin_event_trigger"))
{
try
{
final int triggerId = Integer.parseInt(st.nextToken());
final boolean enable = Boolean.parseBoolean(st.nextToken());
L2World.getInstance().forEachVisibleObject(activeChar, L2PcInstance.class, player -> player.sendPacket(new OnEventTrigger(triggerId, enable)));
activeChar.sendPacket(new OnEventTrigger(triggerId, enable));
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //event_trigger id [true | false]");
}
}
else if (command.startsWith("admin_settargetable"))
{
activeChar.setTargetable(!activeChar.isTargetable());
}
if (command.contains("menu"))
{
showMainPage(activeChar, command);
}
return true;
}
/**
* @param ave the abnormal visual effect
* @param target the target
* @return {@code true} if target's abnormal state was affected, {@code false} otherwise.
*/
private boolean performAbnormalVisualEffect(AbnormalVisualEffect ave, L2Object target)
{
if (target instanceof L2Character)
{
final L2Character character = (L2Character) target;
if (!character.hasAbnormalVisualEffect(ave))
{
character.startAbnormalVisualEffect(ave);
}
else
{
character.stopAbnormalVisualEffect(ave);
}
return true;
}
return false;
}
private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
{
try
{
if (target.isCharacter())
{
if (target instanceof L2ChestInstance)
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;
}
if ((target.isNpc()) && ((action < 1) || (action > 20)))
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;
}
if ((target.isPlayer()) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;
}
final L2Character character = (L2Character) target;
character.broadcastPacket(new SocialAction(character.getObjectId(), action));
}
else
{
return false;
}
}
catch (Exception e)
{
}
return true;
}
/**
* @param type - atmosphere type (signssky,sky)
* @param state - atmosphere state(night,day)
* @param duration
* @param activeChar
*/
private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
{
IClientOutgoingPacket packet = null;
if (type.equals("sky"))
{
if (state.equals("night"))
{
packet = SunSet.STATIC_PACKET;
}
else if (state.equals("day"))
{
packet = SunRise.STATIC_PACKET;
}
else if (state.equals("red"))
{
if (duration != 0)
{
packet = new ExRedSky(duration);
}
else
{
packet = new ExRedSky(10);
}
}
}
else
{
activeChar.sendMessage("Usage: //atmosphere <signsky dawn|dusk>|<sky day|night|red> <duration>");
}
if (packet != null)
{
Broadcast.toAllOnlinePlayers(packet);
}
}
private void playAdminSound(L2PcInstance activeChar, String sound)
{
final PlaySound _snd = new PlaySound(1, sound, 0, 0, 0, 0, 0);
activeChar.sendPacket(_snd);
activeChar.broadcastPacket(_snd);
activeChar.sendMessage("Playing " + sound + ".");
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
private void showMainPage(L2PcInstance activeChar, String command)
{
String filename = "effects_menu";
if (command.contains("social"))
{
filename = "social";
}
AdminHtml.showAdminHtml(activeChar, filename + ".htm");
}
}

View File

@@ -0,0 +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.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 + ".");
}
}
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,600 @@
/*
* 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.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.Rnd;
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;
import com.l2jmobius.gameserver.model.entity.L2Event;
import com.l2jmobius.gameserver.model.entity.L2Event.EventState;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PlaySound;
import com.l2jmobius.gameserver.util.Broadcast;
/**
* This class handles following admin commands: - admin = shows menu
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminEventEngine implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_event",
"admin_event_new",
"admin_event_choose",
"admin_event_store",
"admin_event_set",
"admin_event_change_teams_number",
"admin_event_announce",
"admin_event_panel",
"admin_event_control_begin",
"admin_event_control_teleport",
"admin_add",
"admin_event_see",
"admin_event_del",
"admin_delete_buffer",
"admin_event_control_sit",
"admin_event_name",
"admin_event_control_kill",
"admin_event_control_res",
"admin_event_control_poly",
"admin_event_control_unpoly",
"admin_event_control_transform",
"admin_event_control_untransform",
"admin_event_control_prize",
"admin_event_control_chatban",
"admin_event_control_kick",
"admin_event_control_finish"
};
private static String tempBuffer = "";
private static String tempName = "";
private static boolean npcsDeleted = false;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
StringTokenizer st = new StringTokenizer(command);
final String actualCommand = st.nextToken();
try
{
if (actualCommand.equals("admin_event"))
{
if (L2Event.eventState != EventState.OFF)
{
showEventControl(activeChar);
}
else
{
showMainPage(activeChar);
}
}
else if (actualCommand.equals("admin_event_new"))
{
showNewEventPage(activeChar);
}
else if (actualCommand.startsWith("admin_add"))
{
// There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
tempBuffer += command.substring(10);
showNewEventPage(activeChar);
}
else if (actualCommand.startsWith("admin_event_see"))
{
// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
final String eventName = command.substring(16);
try
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName)));
final BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
adminReply.setFile("en", "data/html/mods/EventEngine/Participation.htm");
adminReply.replace("%eventName%", eventName);
adminReply.replace("%eventCreator%", inbr.readLine());
adminReply.replace("%eventInfo%", inbr.readLine());
adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
activeChar.sendPacket(adminReply);
inbr.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
else if (actualCommand.startsWith("admin_event_del"))
{
// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
final String eventName = command.substring(16);
final File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
file.delete();
showMainPage(activeChar);
}
else if (actualCommand.startsWith("admin_event_name"))
{
// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
tempName += command.substring(17);
showNewEventPage(activeChar);
}
else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
{
tempBuffer = "";
showNewEventPage(activeChar);
}
else if (actualCommand.startsWith("admin_event_store"))
{
try
{
final FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
final PrintStream p = new PrintStream(file);
p.println(activeChar.getName());
p.println(tempBuffer);
file.close();
p.close();
}
catch (Exception e)
{
e.printStackTrace();
}
tempBuffer = "";
tempName = "";
showMainPage(activeChar);
}
else if (actualCommand.startsWith("admin_event_set"))
{
// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
L2Event._eventName = command.substring(16);
showEventParameters(activeChar, 2);
}
else if (actualCommand.startsWith("admin_event_change_teams_number"))
{
showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
}
else if (actualCommand.startsWith("admin_event_panel"))
{
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_announce"))
{
L2Event._npcId = Integer.parseInt(st.nextToken());
L2Event._teamsNumber = Integer.parseInt(st.nextToken());
String temp = " ";
String temp2 = "";
while (st.hasMoreElements())
{
temp += st.nextToken() + " ";
}
st = new StringTokenizer(temp, "-");
Integer i = 1;
while (st.hasMoreElements())
{
temp2 = st.nextToken();
if (!temp2.equals(" "))
{
L2Event._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
}
}
activeChar.sendMessage(L2Event.startEventParticipation());
Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");
final PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
activeChar.sendPacket(_snd);
activeChar.broadcastPacket(_snd);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final String replyMSG = "<html><title>[ L2J EVENT ENGINE ]</title><body><br><center>The event <font color=\"LEVEL\">" + L2Event._eventName + "</font> has been announced, now you can type //event_panel to see the event panel control</center><br></body></html>";
adminReply.setHtml(replyMSG);
activeChar.sendPacket(adminReply);
}
else if (actualCommand.startsWith("admin_event_control_begin"))
{
// Starts the event and sends a message of the result
activeChar.sendMessage(L2Event.startEvent());
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_finish"))
{
// Finishes the event and sends a message of the result
activeChar.sendMessage(L2Event.finishEvent());
}
else if (actualCommand.startsWith("admin_event_control_teleport"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
final int teamId = Integer.parseInt(st.nextToken());
for (L2PcInstance player : L2Event._teams.get(teamId))
{
player.setTitle(L2Event._teamNames.get(teamId));
player.teleToLocation(activeChar.getLocation(), true, activeChar.getInstanceWorld());
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_sit"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
// Integer.parseInt(st.nextToken()) == teamId
for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
{
if (player.getEventStatus() == null)
{
continue;
}
player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
if (player.getEventStatus().isSitForced())
{
player.sitDown();
}
else
{
player.standUp();
}
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_kill"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
{
player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_res"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
{
if ((player == null) || !player.isDead())
{
continue;
}
player.restoreExp(100.0);
player.doRevive();
player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
player.setCurrentCp(player.getMaxCp());
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_poly"))
{
final int teamId = Integer.parseInt(st.nextToken());
final String[] polyIds = new String[st.countTokens()];
int i = 0;
while (st.hasMoreElements()) // Every next ST should be a polymorph ID
{
polyIds[i++] = st.nextToken();
}
for (L2PcInstance player : L2Event._teams.get(teamId))
{
player.getPoly().setPolyInfo("npc", polyIds[Rnd.get(polyIds.length)]);
player.teleToLocation(player.getLocation(), true);
player.broadcastUserInfo();
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_unpoly"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
{
player.getPoly().setPolyInfo(null, "1");
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
player.broadcastUserInfo();
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_transform"))
{
final int teamId = Integer.parseInt(st.nextToken());
final int[] transIds = new int[st.countTokens()];
int i = 0;
while (st.hasMoreElements()) // Every next ST should be a transform ID
{
transIds[i++] = Integer.parseInt(st.nextToken());
}
for (L2PcInstance player : L2Event._teams.get(teamId))
{
final int transId = transIds[Rnd.get(transIds.length)];
if (!player.transform(transId, true))
{
AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_untransform"))
{
while (st.hasMoreElements()) // Every next ST should be a team number
{
for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
{
player.stopTransformation(true);
}
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_kick"))
{
if (st.hasMoreElements()) // If has next token, it should be player name.
{
while (st.hasMoreElements())
{
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
if (player != null)
{
L2Event.removeAndResetPlayer(player);
}
}
}
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
{
L2Event.removeAndResetPlayer((L2PcInstance) activeChar.getTarget());
}
showEventControl(activeChar);
}
else if (actualCommand.startsWith("admin_event_control_prize"))
{
final int[] teamIds = new int[st.countTokens() - 2];
int i = 0;
while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
{
teamIds[i++] = Integer.parseInt(st.nextToken());
}
final String[] n = st.nextToken().split("\\*");
final int itemId = Integer.parseInt(st.nextToken());
for (int teamId : teamIds)
{
rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
}
showEventControl(activeChar);
}
}
catch (Exception e)
{
e.printStackTrace();
AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
private String showStoredEvents()
{
final File dir = new File(Config.DATAPACK_ROOT, "/data/events");
if (dir.isFile())
{
return "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' is a file or is corrupted!</font><br>";
}
String note = "";
if (!dir.exists())
{
note = "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' does not exist!</font><br><font color=\"0099FF\">Trying to create it now...<br></font><br>";
if (dir.mkdirs())
{
note += "<font color=\"006600\">The directory '" + dir.getAbsolutePath() + "' has been created!</font><br>";
}
else
{
note += "<font color=\"FF0000\">The directory '" + dir.getAbsolutePath() + "' hasn't been created!</font><br>";
return note;
}
}
final String[] files = dir.list();
final StringBuilder result = new StringBuilder(files.length * 500);
result.append("<table>");
for (String fileName : files)
{
result.append("<tr><td align=center>");
result.append(fileName);
result.append(" </td></tr><tr><td><table cellspacing=0><tr><td><button value=\"Select Event\" action=\"bypass -h admin_event_set ");
result.append(fileName);
result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"View Event\" action=\"bypass -h admin_event_see ");
result.append(fileName);
result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Delete Event\" action=\"bypass -h admin_event_del ");
result.append(fileName);
result.append("\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></td></tr><tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td></tr>");
}
result.append("</table>");
return note + result;
}
public void showMainPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final String replyMSG = "<html><title>[ L2J EVENT ENGINE ]</title><body><br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=150 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><center><br><font color=LEVEL>Stored Events:</font><br></center>" + showStoredEvents() + "</body></html>";
adminReply.setHtml(replyMSG);
activeChar.sendPacket(adminReply);
}
public void showNewEventPage(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final StringBuilder replyMSG = new StringBuilder(512);
replyMSG.append("<html><title>[ L2J EVENT ENGINE ]</title><body><br><br><center><font color=LEVEL>Event name:</font><br>");
if (tempName.isEmpty())
{
replyMSG.append("You can also use //event_name text to insert a new title");
replyMSG.append("<center><multiedit var=\"name\" width=260 height=24> <button value=\"Set Event Name\" action=\"bypass -h admin_event_name $name\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
}
else
{
replyMSG.append(tempName);
}
replyMSG.append("<br><br><font color=LEVEL>Event description:</font><br></center>");
if (tempBuffer.isEmpty())
{
replyMSG.append("You can also use //add text to add text or //delete_buffer to remove the text.");
}
else
{
replyMSG.append(tempBuffer);
}
replyMSG.append("<center><multiedit var=\"txt\" width=270 height=100> <button value=\"Add text\" action=\"bypass -h admin_add $txt\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
replyMSG.append("<button value=\"Remove text\" action=\"bypass -h admin_delete_buffer\" width=120 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
if (!(tempName.isEmpty() && tempBuffer.isEmpty()))
{
replyMSG.append("<br><button value=\"Store Event Data\" action=\"bypass -h admin_event_store\" width=160 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
}
replyMSG.append("</center></body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
public void showEventParameters(L2PcInstance activeChar, int teamnumbers)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final StringBuilder sb = new StringBuilder();
sb.append("<html><body><title>[ L2J EVENT ENGINE ]</title><br><center> Current event: <font color=\"LEVEL\">");
sb.append(L2Event._eventName);
sb.append("</font></center><br>INFO: To start an event, you must first set the number of teams, then type their names in the boxes and finally type the NPC ID that will be the event manager (can be any existing npc) next to the \"Announce Event!\" button.<br><table width=100%>");
sb.append("<tr><td><button value=\"Announce Event!\" action=\"bypass -h admin_event_announce $event_npcid ");
sb.append(teamnumbers);
sb.append(" ");
for (int i = 1; (i - 1) < teamnumbers; i++) // Event announce params
{
sb.append("$event_teams_name");
sb.append(i);
sb.append(" - ");
}
sb.append("\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
sb.append("<td><edit var=\"event_npcid\" width=100 height=20></td></tr>");
sb.append("<tr><td><button value=\"Set number of teams\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=140 height=32 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
sb.append("<td><edit var=\"event_teams_number\" width=100 height=20></td></tr>");
sb.append("</table><br><center> <br><br>");
sb.append("<font color=\"LEVEL\">Teams' names:</font><br><table width=100% cellspacing=8>");
for (int i = 1; (i - 1) < teamnumbers; i++) // Team names params
{
sb.append("<tr><td align=center>Team #");
sb.append(i);
sb.append(" name:</td><td><edit var=\"event_teams_name");
sb.append(i);
sb.append("\" width=150 height=15></td></tr>");
}
sb.append("</table></body></html>");
adminReply.setHtml(sb.toString());
activeChar.sendPacket(adminReply);
}
private void showEventControl(L2PcInstance activeChar)
{
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final StringBuilder sb = new StringBuilder();
sb.append("<html><title>[ L2J EVENT ENGINE ]</title><body><br><center>Current event: <font color=\"LEVEL\">");
sb.append(L2Event._eventName);
sb.append("</font></center><br><table cellspacing=-1 width=280><tr><td align=center>Type the team ID(s) that will be affected by the commands. Commands with '*' work with only 1 team ID in the field, while '!' - none.</td></tr><tr><td align=center><edit var=\"team_number\" width=100 height=15></td></tr>");
sb.append("<tr><td>&nbsp;</td></tr><tr><td><table width=200>");
if (!npcsDeleted)
{
sb.append("<tr><td><button value=\"Start!\" action=\"bypass -h admin_event_control_begin\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Destroys all event npcs so no more people can't participate now on</font></td></tr>");
}
sb.append("<tr><td>&nbsp;</td></tr><tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Teleports the specified team to your position</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Sit/Stand\" action=\"bypass -h admin_event_control_sit $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Sits/Stands up the team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Kill\" action=\"bypass -h admin_event_control_kill $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Finish with the life of all the players in the selected team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"Resurrect\" action=\"bypass -h admin_event_control_res $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Resurrect Team's members</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Polymorph*\" action=\"bypass -h admin_event_control_poly $team_number $poly_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"poly_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Polymorphs the team into the NPC with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"UnPolymorph\" action=\"bypass -h admin_event_control_unpoly $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Unpolymorph the team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Transform*\" action=\"bypass -h admin_event_control_transform $team_number $transf_id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"transf_id\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Transforms the team into the transformation with the ID specified. Multiple IDs result in randomly chosen one for each player.</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"UnTransform\" action=\"bypass -h admin_event_control_untransform $team_number\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Untransforms the team</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><table><tr><td width=32>Num</td><td><edit var=\"n\" width=60 height=15></td></tr><tr><td>ID</td><td><edit var=\"id\" width=60 height=15></td></tr></table></td><td><font color=\"LEVEL\">Give the specified item id to every single member of the team, you can put 5*level, 5*kills or 5 in the number field for example</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><table cellspacing=-1><tr><td><button value=\"Kick Player\" action=\"bypass -h admin_event_control_kick $player_name\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td><edit var=\"player_name\" width=98 height=15></td></tr></table></td><td><font color=\"LEVEL\">Kicks the specified player(s) from the event. Blank field kicks target.</font></td></tr><tr><td>&nbsp;</td></tr><tr><td><button value=\"End!\" action=\"bypass -h admin_event_control_finish\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><font color=\"LEVEL\">Will finish the event teleporting back all the players</font></td></tr><tr><td>&nbsp;</td></tr></table></td></tr></table></body></html>");
adminReply.setHtml(sb.toString());
activeChar.sendPacket(adminReply);
}
private void rewardTeam(L2PcInstance activeChar, int team, int n, int id, String type)
{
int num = n;
for (L2PcInstance player : L2Event._teams.get(team))
{
if (type.equalsIgnoreCase("level"))
{
num = n * player.getLevel();
}
else if (type.equalsIgnoreCase("kills") && (player.getEventStatus() != null))
{
num = n * player.getEventStatus().getKills().size();
}
else
{
num = n;
}
player.addItem("Event", id, num, activeChar, true);
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
adminReply.setHtml("<html><body> CONGRATULATIONS! You should have been rewarded. </body></html>");
player.sendPacket(adminReply);
}
}
}

View File

@@ -0,0 +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;
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("<tr><td><font color=\"LEVEL\">" + event.getName() + ":</font></td><br><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></tr>");
}
}
html.replace("%LIST%", cList.toString());
activeChar.sendPacket(html);
}
}

View File

@@ -0,0 +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
{
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;
}
}

View File

@@ -0,0 +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.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();
}
}
}

View File

@@ -0,0 +1,188 @@
/*
* 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;
}
}

View File

@@ -0,0 +1,149 @@
/*
* 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.GeoData;
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.SystemMessage;
import com.l2jmobius.gameserver.util.GeoUtils;
/**
* @author -Nemesiss-, HorridoJoho
*/
public class AdminGeodata implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_geo_pos",
"admin_geo_spawn_pos",
"admin_geo_can_move",
"admin_geo_can_see",
"admin_geogrid",
"admin_geomap"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command, " ");
final String actualCommand = st.nextToken();
switch (actualCommand.toLowerCase())
{
case "admin_geo_pos":
{
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoData.getInstance().getGeoX(worldX);
final int geoY = GeoData.getInstance().getGeoY(worldY);
if (GeoData.getInstance().hasGeoPos(geoX, geoY))
{
activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ));
}
else
{
activeChar.sendMessage("There is no geodata at this position.");
}
break;
}
case "admin_geo_spawn_pos":
{
final int worldX = activeChar.getX();
final int worldY = activeChar.getY();
final int worldZ = activeChar.getZ();
final int geoX = GeoData.getInstance().getGeoX(worldX);
final int geoY = GeoData.getInstance().getGeoY(worldY);
if (GeoData.getInstance().hasGeoPos(geoX, geoY))
{
activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ));
}
else
{
activeChar.sendMessage("There is no geodata at this position.");
}
break;
}
case "admin_geo_can_move":
{
final L2Object target = activeChar.getTarget();
if (target != null)
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.sendMessage("Can move beeline.");
}
else
{
activeChar.sendMessage("Can not move beeline!");
}
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "admin_geo_can_see":
{
final L2Object target = activeChar.getTarget();
if (target != null)
{
if (GeoData.getInstance().canSeeTarget(activeChar, target))
{
activeChar.sendMessage("Can see target.");
}
else
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_SEE_TARGET));
}
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
break;
}
case "admin_geogrid":
{
GeoUtils.debugGrid(activeChar);
break;
}
case "admin_geomap":
{
final int x = ((activeChar.getX() - L2World.MAP_MIN_X) >> 15) + L2World.TILE_X_MIN;
final int y = ((activeChar.getY() - L2World.MAP_MIN_Y) >> 15) + L2World.TILE_Y_MIN;
activeChar.sendMessage("GeoMap: " + x + "_" + y + " (" + ((x - L2World.TILE_ZERO_COORD_X) * L2World.TILE_SIZE) + "," + ((y - L2World.TILE_ZERO_COORD_Y) * L2World.TILE_SIZE) + " to " + ((((x - L2World.TILE_ZERO_COORD_X) * L2World.TILE_SIZE) + L2World.TILE_SIZE) - 1) + "," + ((((y - L2World.TILE_ZERO_COORD_Y) * L2World.TILE_SIZE) + L2World.TILE_SIZE) - 1) + ")");
break;
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View 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.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;
}
}

View File

@@ -0,0 +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);
final CreatureSay cs = new CreatureSay(0, ChatType.ALLIANCE, activeChar.getName(), text);
AdminData.getInstance().broadcastToGMs(cs);
}
catch (StringIndexOutOfBoundsException e)
{
// Who cares?
}
}
}

View File

@@ -0,0 +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
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;
}
}

View File

@@ -0,0 +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.bosses.Antharas.Antharas;
import ai.bosses.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;
}
}

View 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.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);
}
}
}

View File

@@ -0,0 +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 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;
}
}

View File

@@ -0,0 +1,65 @@
/*
* 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.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Mobius
*/
public class AdminHwid implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_hwid",
"admin_hwinfo"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer() || (activeChar.getTarget().getActingPlayer().getClient() == null) || (activeChar.getTarget().getActingPlayer().getClient().getHardwareInfo() == null))
{
return true;
}
final L2PcInstance target = activeChar.getTarget().getActingPlayer();
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/charhwinfo.htm"));
html.replace("%name%", target.getName());
html.replace("%macAddress%", target.getClient().getHardwareInfo().getMacAddress());
html.replace("%windowsPlatformId%", target.getClient().getHardwareInfo().getWindowsPlatformId());
html.replace("%windowsMajorVersion%", target.getClient().getHardwareInfo().getWindowsMajorVersion());
html.replace("%windowsMinorVersion%", target.getClient().getHardwareInfo().getWindowsMinorVersion());
html.replace("%windowsBuildNumber%", target.getClient().getHardwareInfo().getWindowsBuildNumber());
html.replace("%cpuName%", target.getClient().getHardwareInfo().getCpuName());
html.replace("%cpuSpeed%", target.getClient().getHardwareInfo().getCpuSpeed());
html.replace("%cpuCoreCount%", target.getClient().getHardwareInfo().getCpuCoreCount());
html.replace("%vgaName%", target.getClient().getHardwareInfo().getVgaName());
html.replace("%vgaDriverVersion%", target.getClient().getHardwareInfo().getVgaDriverVersion());
activeChar.sendPacket(html);
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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;
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);
}
}

View File

@@ -0,0 +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.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);
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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"))
{
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;
}
}

View File

@@ -0,0 +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.loginserverpackets.game.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;
}
}

View File

@@ -0,0 +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;
/**
* @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"
};
}
}

View File

@@ -0,0 +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
{
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");
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +1,631 @@
/*
* 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.NpcData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.MobGroup;
import com.l2jmobius.gameserver.model.MobGroupTable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
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.Broadcast;
/**
* @author littlecrow Admin commands handler for controllable mobs
*/
public class AdminMobGroup implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_mobmenu",
"admin_mobgroup_list",
"admin_mobgroup_create",
"admin_mobgroup_remove",
"admin_mobgroup_delete",
"admin_mobgroup_spawn",
"admin_mobgroup_unspawn",
"admin_mobgroup_kill",
"admin_mobgroup_idle",
"admin_mobgroup_attack",
"admin_mobgroup_rnd",
"admin_mobgroup_return",
"admin_mobgroup_follow",
"admin_mobgroup_casting",
"admin_mobgroup_nomove",
"admin_mobgroup_attackgrp",
"admin_mobgroup_invul"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_mobmenu"))
{
showMainPage(activeChar, command);
return true;
}
else if (command.equals("admin_mobgroup_list"))
{
showGroupList(activeChar);
}
else if (command.startsWith("admin_mobgroup_create"))
{
createGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_delete") || command.startsWith("admin_mobgroup_remove"))
{
removeGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_spawn"))
{
spawnGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_unspawn"))
{
unspawnGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_kill"))
{
killGroup(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_attackgrp"))
{
attackGrp(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_attack"))
{
if (activeChar.getTarget() instanceof L2Character)
{
final L2Character target = (L2Character) activeChar.getTarget();
attack(command, activeChar, target);
}
}
else if (command.startsWith("admin_mobgroup_rnd"))
{
setNormal(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_idle"))
{
idle(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_return"))
{
returnToChar(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_follow"))
{
follow(command, activeChar, activeChar);
}
else if (command.startsWith("admin_mobgroup_casting"))
{
setCasting(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_nomove"))
{
noMove(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_invul"))
{
invul(command, activeChar);
}
else if (command.startsWith("admin_mobgroup_teleport"))
{
teleportGroup(command, activeChar);
}
showMainPage(activeChar, command);
return true;
}
/**
* @param activeChar
* @param command
*/
private void showMainPage(L2PcInstance activeChar, String command)
{
final String filename = "mobgroup.htm";
AdminHtml.showAdminHtml(activeChar, filename);
}
private void returnToChar(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.returnGroup(activeChar);
}
private void idle(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setIdleMode();
}
private void setNormal(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setAttackRandom();
}
private void attack(String command, L2PcInstance activeChar, L2Character target)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setAttackTarget(target);
}
private void follow(String command, L2PcInstance activeChar, L2Character target)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect command arguments.");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setFollowMode(target);
}
private void createGroup(String command, L2PcInstance activeChar)
{
int groupId;
int templateId;
int mobCount;
try
{
final String[] cmdParams = command.split(" ");
groupId = Integer.parseInt(cmdParams[1]);
templateId = Integer.parseInt(cmdParams[2]);
mobCount = Integer.parseInt(cmdParams[3]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_create <group> <npcid> <count>");
return;
}
if (MobGroupTable.getInstance().getGroup(groupId) != null)
{
activeChar.sendMessage("Mob group " + groupId + " already exists.");
return;
}
final L2NpcTemplate template = NpcData.getInstance().getTemplate(templateId);
if (template == null)
{
activeChar.sendMessage("Invalid NPC ID specified.");
return;
}
final MobGroup group = new MobGroup(groupId, template, mobCount);
MobGroupTable.getInstance().addGroup(groupId, group);
activeChar.sendMessage("Mob group " + groupId + " created.");
}
private void removeGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_remove <groupId>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.unspawnGroup();
if (MobGroupTable.getInstance().removeGroup(groupId))
{
activeChar.sendMessage("Mob group " + groupId + " unspawned and removed.");
}
}
private void spawnGroup(String command, L2PcInstance activeChar)
{
int groupId;
boolean topos = false;
int posx = 0;
int posy = 0;
int posz = 0;
try
{
final String[] cmdParams = command.split(" ");
groupId = Integer.parseInt(cmdParams[1]);
try
{ // we try to get a position
posx = Integer.parseInt(cmdParams[2]);
posy = Integer.parseInt(cmdParams[3]);
posz = Integer.parseInt(cmdParams[4]);
topos = true;
}
catch (Exception e)
{
// no position given
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_spawn <group> [ x y z ]");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
if (topos)
{
group.spawnGroup(posx, posy, posz);
}
else
{
group.spawnGroup(activeChar);
}
activeChar.sendMessage("Mob group " + groupId + " spawned.");
}
private void unspawnGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_unspawn <groupId>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.unspawnGroup();
activeChar.sendMessage("Mob group " + groupId + " unspawned.");
}
private void killGroup(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_kill <groupId>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
doAnimation(activeChar);
group.killGroup(activeChar);
}
private void setCasting(String command, L2PcInstance activeChar)
{
int groupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_casting <groupId>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.setCastMode();
}
private void noMove(String command, L2PcInstance activeChar)
{
int groupId;
String enabled;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
enabled = command.split(" ")[2];
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_nomove <groupId> <on|off>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
if (enabled.equalsIgnoreCase("on") || enabled.equalsIgnoreCase("true"))
{
group.setNoMoveMode(true);
}
else if (enabled.equalsIgnoreCase("off") || enabled.equalsIgnoreCase("false"))
{
group.setNoMoveMode(false);
}
else
{
activeChar.sendMessage("Incorrect command arguments.");
}
}
private void doAnimation(L2PcInstance activeChar)
{
Broadcast.toSelfAndKnownPlayersInRadius(activeChar, new MagicSkillUse(activeChar, 1008, 1, 4000, 0), 1500);
activeChar.sendPacket(new SetupGauge(activeChar.getObjectId(), 0, 4000));
}
private void attackGrp(String command, L2PcInstance activeChar)
{
int groupId;
int othGroupId;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
othGroupId = Integer.parseInt(command.split(" ")[2]);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_attackgrp <groupId> <TargetGroupId>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
final MobGroup othGroup = MobGroupTable.getInstance().getGroup(othGroupId);
if (othGroup == null)
{
activeChar.sendMessage("Incorrect target group.");
return;
}
group.setAttackGroup(othGroup);
}
private void invul(String command, L2PcInstance activeChar)
{
int groupId;
String enabled;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
enabled = command.split(" ")[2];
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_invul <groupId> <on|off>");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
if (enabled.equalsIgnoreCase("on") || enabled.equalsIgnoreCase("true"))
{
group.setInvul(true);
}
else if (enabled.equalsIgnoreCase("off") || enabled.equalsIgnoreCase("false"))
{
group.setInvul(false);
}
else
{
activeChar.sendMessage("Incorrect command arguments.");
}
}
private void teleportGroup(String command, L2PcInstance activeChar)
{
int groupId;
String targetPlayerStr = null;
L2PcInstance targetPlayer = null;
try
{
groupId = Integer.parseInt(command.split(" ")[1]);
targetPlayerStr = command.split(" ")[2];
if (targetPlayerStr != null)
{
targetPlayer = L2World.getInstance().getPlayer(targetPlayerStr);
}
if (targetPlayer == null)
{
targetPlayer = activeChar;
}
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //mobgroup_teleport <groupId> [playerName]");
return;
}
final MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
if (group == null)
{
activeChar.sendMessage("Invalid group specified.");
return;
}
group.teleportGroup(activeChar);
}
private void showGroupList(L2PcInstance activeChar)
{
final MobGroup[] mobGroupList = MobGroupTable.getInstance().getGroups();
activeChar.sendMessage("======= <Mob Groups> =======");
for (MobGroup mobGroup : mobGroupList)
{
activeChar.sendMessage(mobGroup.getGroupId() + ": " + mobGroup.getActiveMobCount() + " alive out of " + mobGroup.getMaxMobCount() + " of NPC ID " + mobGroup.getTemplate().getId() + " (" + mobGroup.getStatus() + ")");
}
activeChar.sendPacket(SystemMessageId.EMPTY3);
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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 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;
}
}
}

View 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;
}
}

View File

@@ -0,0 +1,624 @@
/*
* 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.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.LinkedList;
import java.util.StringTokenizer;
import com.l2jmobius.gameserver.cache.HtmCache;
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.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2BoatInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.AdminForgePacket;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* This class handles commands for gm to forge packets
* @author Maktakien, HorridoJoho
*/
public final class AdminPForge implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_forge",
"admin_forge_values",
"admin_forge_send"
};
private String[] getOpCodes(StringTokenizer st)
{
Collection<String> opCodes = null;
while (st.hasMoreTokens())
{
final String token = st.nextToken();
if (";".equals(token))
{
break;
}
if (opCodes == null)
{
opCodes = new LinkedList<>();
}
opCodes.add(token);
}
if (opCodes == null)
{
return null;
}
return opCodes.toArray(new String[opCodes.size()]);
}
private boolean validateOpCodes(String[] opCodes)
{
if ((opCodes == null) || (opCodes.length == 0) || (opCodes.length > 3))
{
return false;
}
for (int i = 0; i < opCodes.length; ++i)
{
final String opCode = opCodes[i];
long opCodeLong;
try
{
opCodeLong = Long.decode(opCode);
}
catch (Exception e)
{
if (i > 0)
{
return true;
}
return false;
}
if (opCodeLong < 0)
{
return false;
}
if ((i == 0) && (opCodeLong > 255))
{
return false;
}
else if ((i == 1) && (opCodeLong > 65535))
{
return false;
}
else if ((i == 2) && (opCodeLong > 4294967295L))
{
return false;
}
}
return true;
}
private boolean validateFormat(String format)
{
for (int chIdx = 0; chIdx < format.length(); ++chIdx)
{
switch (format.charAt(chIdx))
{
case 'b':
case 'B':
case 'x':
case 'X':
// array
break;
case 'c':
case 'C':
// byte
break;
case 'h':
case 'H':
// word
break;
case 'd':
case 'D':
// dword
break;
case 'q':
case 'Q':
// qword
break;
case 'f':
case 'F':
// double
break;
case 's':
case 'S':
// string
break;
default:
return false;
}
}
return true;
}
private boolean validateMethod(String method)
{
switch (method)
{
case "sc":
case "sb":
case "cs":
return true;
}
return false;
}
private void showValuesUsage(L2PcInstance activeChar)
{
activeChar.sendMessage("Usage: //forge_values opcode1[ opcode2[ opcode3]] ;[ format]");
showMainPage(activeChar);
}
private void showSendUsage(L2PcInstance activeChar, String[] opCodes, String format)
{
activeChar.sendMessage("Usage: //forge_send sc|sb|cs opcode1[;opcode2[;opcode3]][ format value1 ... valueN] ");
if (opCodes == null)
{
showMainPage(activeChar);
}
else
{
showValuesPage(activeChar, opCodes, format);
}
}
private void showMainPage(L2PcInstance activeChar)
{
AdminHtml.showAdminHtml(activeChar, "pforge/main.htm");
}
private void showValuesPage(L2PcInstance activeChar, String[] opCodes, String format)
{
String sendBypass = null;
String valuesHtml = HtmCache.getInstance().getHtmForce(activeChar.getHtmlPrefix(), "data/html/admin/pforge/values.htm");
if (opCodes.length == 3)
{
valuesHtml = valuesHtml.replace("%opformat%", "chd");
sendBypass = opCodes[0] + ";" + opCodes[1] + ";" + opCodes[2];
}
else if (opCodes.length == 2)
{
valuesHtml = valuesHtml.replace("%opformat%", "ch");
sendBypass = opCodes[0] + ";" + opCodes[1];
}
else
{
valuesHtml = valuesHtml.replace("%opformat%", "c");
sendBypass = opCodes[0];
}
valuesHtml = valuesHtml.replace("%opcodes%", sendBypass);
String editorsHtml = "";
if (format == null)
{
valuesHtml = valuesHtml.replace("%format%", "");
editorsHtml = "";
}
else
{
valuesHtml = valuesHtml.replace("%format%", format);
sendBypass += " " + format;
final String editorTemplate = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/pforge/inc/editor.htm");
if (editorTemplate != null)
{
final StringBuilder singleCharSequence = new StringBuilder(1);
singleCharSequence.append(' ');
for (int chIdx = 0; chIdx < format.length(); ++chIdx)
{
final char ch = format.charAt(chIdx);
singleCharSequence.setCharAt(0, ch);
editorsHtml += editorTemplate.replace("%format%", singleCharSequence).replace("%editor_index%", String.valueOf(chIdx));
sendBypass += " $v" + chIdx;
}
}
else
{
editorsHtml = "";
}
}
valuesHtml = valuesHtml.replace("%editors%", editorsHtml);
valuesHtml = valuesHtml.replace("%send_bypass%", sendBypass);
activeChar.sendPacket(new NpcHtmlMessage(0, 1, valuesHtml));
}
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_forge"))
{
showMainPage(activeChar);
}
else if (command.startsWith("admin_forge_values "))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // skip command token
if (!st.hasMoreTokens())
{
showValuesUsage(activeChar);
return false;
}
final String[] opCodes = getOpCodes(st);
if (!validateOpCodes(opCodes))
{
activeChar.sendMessage("Invalid op codes!");
showValuesUsage(activeChar);
return false;
}
String format = null;
if (st.hasMoreTokens())
{
format = st.nextToken();
if (!validateFormat(format))
{
activeChar.sendMessage("Format invalid!");
showValuesUsage(activeChar);
return false;
}
}
showValuesPage(activeChar, opCodes, format);
}
catch (Exception e)
{
e.printStackTrace();
showValuesUsage(activeChar);
return false;
}
}
else if (command.startsWith("admin_forge_send "))
{
try
{
final StringTokenizer st = new StringTokenizer(command);
st.nextToken(); // skip command token
if (!st.hasMoreTokens())
{
showSendUsage(activeChar, null, null);
return false;
}
final String method = st.nextToken();
if (!validateMethod(method))
{
activeChar.sendMessage("Invalid method!");
showSendUsage(activeChar, null, null);
return false;
}
final String[] opCodes = st.nextToken().split(";");
if (!validateOpCodes(opCodes))
{
activeChar.sendMessage("Invalid op codes!");
showSendUsage(activeChar, null, null);
return false;
}
String format = null;
if (st.hasMoreTokens())
{
format = st.nextToken();
if (!validateFormat(format))
{
activeChar.sendMessage("Format invalid!");
showSendUsage(activeChar, null, null);
return false;
}
}
AdminForgePacket afp = null;
ByteBuffer bb = null;
for (int i = 0; i < opCodes.length; ++i)
{
char type;
if (i == 0)
{
type = 'c';
}
else if (i == 1)
{
type = 'h';
}
else
{
type = 'd';
}
if (method.equals("sc") || method.equals("sb"))
{
if (afp == null)
{
afp = new AdminForgePacket();
}
afp.addPart((byte) type, opCodes[i]);
}
else
{
if (bb == null)
{
bb = ByteBuffer.allocate(32767);
}
write((byte) type, opCodes[i], bb);
}
}
if (format != null)
{
for (int i = 0; i < format.length(); ++i)
{
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Not enough values!");
showSendUsage(activeChar, null, null);
return false;
}
L2Object target = null;
L2BoatInstance boat = null;
String value = st.nextToken();
switch (value)
{
case "$oid":
value = String.valueOf(activeChar.getObjectId());
break;
case "$boid":
boat = activeChar.getBoat();
if (boat != null)
{
value = String.valueOf(boat.getObjectId());
}
else
{
value = "0";
}
break;
case "$title":
value = activeChar.getTitle();
break;
case "$name":
value = activeChar.getName();
break;
case "$x":
value = String.valueOf(activeChar.getX());
break;
case "$y":
value = String.valueOf(activeChar.getY());
break;
case "$z":
value = String.valueOf(activeChar.getZ());
break;
case "$heading":
value = String.valueOf(activeChar.getHeading());
break;
case "$toid":
value = String.valueOf(activeChar.getTargetId());
break;
case "$tboid":
target = activeChar.getTarget();
if ((target != null) && (target instanceof L2Playable))
{
boat = target.getActingPlayer().getBoat();
if (boat != null)
{
value = String.valueOf(boat.getObjectId());
}
else
{
value = "0";
}
}
break;
case "$ttitle":
target = activeChar.getTarget();
if ((target != null) && (target instanceof L2Character))
{
value = ((L2Character) target).getTitle();
}
else
{
value = "";
}
break;
case "$tname":
target = activeChar.getTarget();
if (target != null)
{
value = target.getName();
}
else
{
value = "";
}
break;
case "$tx":
target = activeChar.getTarget();
if (target != null)
{
value = String.valueOf(target.getX());
}
else
{
value = "0";
}
break;
case "$ty":
target = activeChar.getTarget();
if (target != null)
{
value = String.valueOf(target.getY());
}
else
{
value = "0";
}
break;
case "$tz":
target = activeChar.getTarget();
if (target != null)
{
value = String.valueOf(target.getZ());
}
else
{
value = "0";
}
break;
case "$theading":
target = activeChar.getTarget();
if (target != null)
{
value = String.valueOf(target.getHeading());
}
else
{
value = "0";
}
break;
}
if (method.equals("sc") || method.equals("sb"))
{
if (afp != null)
{
afp.addPart((byte) format.charAt(i), value);
}
}
else
{
write((byte) format.charAt(i), value, bb);
}
}
}
if (method.equals("sc"))
{
activeChar.sendPacket(afp);
}
else if (method.equals("sb"))
{
activeChar.broadcastPacket(afp);
}
else if (bb != null)
{
// TODO: Implement me!
// @formatter:off
/*bb.flip();
L2GameClientPacket p = (L2GameClientPacket) GameServer.gameServer.getL2GamePacketHandler().handlePacket(bb, activeChar.getClient());
if (p != null)
{
p.setBuffers(bb, activeChar.getClient(), new NioNetStringBuffer(2000));
if (p.read())
{
ThreadPoolManager.getInstance().executePacket(p);
}
}*/
// @formatter:on
throw new UnsupportedOperationException("Not implemented yet!");
}
showValuesPage(activeChar, opCodes, format);
}
catch (Exception e)
{
e.printStackTrace();
showSendUsage(activeChar, null, null);
return false;
}
}
return true;
}
private boolean write(byte b, String string, ByteBuffer buf)
{
if ((b == 'C') || (b == 'c'))
{
buf.put(Byte.decode(string));
return true;
}
else if ((b == 'D') || (b == 'd'))
{
buf.putInt(Integer.decode(string));
return true;
}
else if ((b == 'H') || (b == 'h'))
{
buf.putShort(Short.decode(string));
return true;
}
else if ((b == 'F') || (b == 'f'))
{
buf.putDouble(Double.parseDouble(string));
return true;
}
else if ((b == 'S') || (b == 's'))
{
final int len = string.length();
for (int i = 0; i < len; i++)
{
buf.putChar(string.charAt(i));
}
buf.putChar('\000');
return true;
}
else if ((b == 'B') || (b == 'b') || (b == 'X') || (b == 'x'))
{
buf.put(new BigInteger(string).toByteArray());
return true;
}
else if ((b == 'Q') || (b == 'q'))
{
buf.putLong(Long.decode(string));
return true;
}
return false;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,205 @@
/*
* 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.
*/
public final class AdminPcCafePoints implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_pccafepoints",
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command, " ");
final String actualCommand = st.nextToken();
if (actualCommand.equals("admin_pccafepoints"))
{
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_CAFE_MAX_POINTS)
{
showMenuHtml(activeChar);
activeChar.sendMessage("You cannot set more than " + Config.PC_CAFE_MAX_POINTS + " PC points!");
return false;
}
if (value < 0)
{
value = 0;
}
target.setPcCafePoints(value);
target.sendMessage("Admin set your PC Cafe point(s) to " + value + "!");
activeChar.sendMessage("You set " + value + " PC Cafe point(s) to player " + target.getName());
target.sendPacket(new ExPCCafePointInfo(value, value, 1));
break;
}
case "increase":
{
if (target.getPcCafePoints() == Config.PC_CAFE_MAX_POINTS)
{
showMenuHtml(activeChar);
activeChar.sendMessage(target.getName() + " already have max count of PC points!");
return false;
}
int pcCafeCount = Math.min(target.getPcCafePoints() + value, Config.PC_CAFE_MAX_POINTS);
if (pcCafeCount < 0)
{
pcCafeCount = Config.PC_CAFE_MAX_POINTS;
}
target.setPcCafePoints(pcCafeCount);
target.sendMessage("Admin increased your PC Cafe point(s) by " + value + "!");
activeChar.sendMessage("You increased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 1));
break;
}
case "decrease":
{
if (target.getPcCafePoints() == 0)
{
showMenuHtml(activeChar);
activeChar.sendMessage(target.getName() + " already have min count of PC points!");
return false;
}
final int pcCafeCount = Math.max(target.getPcCafePoints() - value, 0);
target.setPcCafePoints(pcCafeCount);
target.sendMessage("Admin decreased your PC Cafe point(s) by " + value + "!");
activeChar.sendMessage("You decreased PC Cafe point(s) of " + target.getName() + " by " + value);
target.sendPacket(new ExPCCafePointInfo(pcCafeCount, value, 1));
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 PC Cafe 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 PC Cafe 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.getPcCafePoints() == Integer.MAX_VALUE)
{
continue;
}
int pcCafeCount = Math.min(temp.getPcCafePoints() + value, Integer.MAX_VALUE);
if (pcCafeCount < 0)
{
pcCafeCount = Integer.MAX_VALUE;
}
temp.setPcCafePoints(pcCafeCount);
temp.sendMessage("Admin increased your PC Cafe point(s) by " + value + "!");
temp.sendPacket(new ExPCCafePointInfo(pcCafeCount, 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, 1);
final L2PcInstance target = getTarget(activeChar);
final int points = target.getPcCafePoints();
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/pccafe.htm"));
html.replace("%points%", Util.formatAdena(points));
html.replace("%targetName%", target.getName());
activeChar.sendPacket(html);
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +1,131 @@
/*
* 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.PcCondOverride;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.util.Util;
/**
* 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",
"admin_set_exception",
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command);
if (st.hasMoreTokens())
{
switch (st.nextToken())
// command
{
case "admin_exceptions":
{
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/cond_override.htm");
final StringBuilder sb = new StringBuilder();
for (PcCondOverride ex : PcCondOverride.values())
{
sb.append("<tr><td fixwidth=\"180\">" + ex.getDescription() + ":</td><td><a action=\"bypass -h admin_set_exception " + ex.ordinal() + "\">" + (activeChar.canOverrideCond(ex) ? "Disable" : "Enable") + "</a></td></tr>");
}
msg.replace("%cond_table%", sb.toString());
activeChar.sendPacket(msg);
break;
}
case "admin_set_exception":
{
if (st.hasMoreTokens())
{
final String token = st.nextToken();
if (Util.isDigit(token))
{
final PcCondOverride ex = PcCondOverride.getCondOverride(Integer.valueOf(token));
if (ex != null)
{
if (activeChar.canOverrideCond(ex))
{
activeChar.removeOverridedCond(ex);
activeChar.sendMessage("You've disabled " + ex.getDescription());
}
else
{
activeChar.addOverrideCond(ex);
activeChar.sendMessage("You've enabled " + ex.getDescription());
}
}
}
else
{
switch (token)
{
case "enable_all":
{
for (PcCondOverride ex : PcCondOverride.values())
{
if (!activeChar.canOverrideCond(ex))
{
activeChar.addOverrideCond(ex);
}
}
activeChar.sendMessage("All condition exceptions have been enabled.");
break;
}
case "disable_all":
{
for (PcCondOverride ex : PcCondOverride.values())
{
if (activeChar.canOverrideCond(ex))
{
activeChar.removeOverridedCond(ex);
}
}
activeChar.sendMessage("All condition exceptions have been disabled.");
break;
}
}
}
useAdminCommand(COMMANDS[0], activeChar);
}
break;
}
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return COMMANDS;
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +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("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");
}
}

View File

@@ -0,0 +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.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);
}
}
}

View File

@@ -0,0 +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.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.cache.HtmCache;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.PremiumManager;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author Mobius
*/
public class AdminPremium implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_premium_menu",
"admin_premium_add1",
"admin_premium_add2",
"admin_premium_add3",
"admin_premium_info",
"admin_premium_remove"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_premium_menu"))
{
AdminHtml.showAdminHtml(activeChar, "premium_menu.htm");
}
else if (command.startsWith("admin_premium_add1"))
{
try
{
addPremiumStatus(activeChar, 1, command.substring(19));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Please enter a valid account name.");
}
}
else if (command.startsWith("admin_premium_add2"))
{
try
{
addPremiumStatus(activeChar, 2, command.substring(19));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Please enter a valid account name.");
}
}
else if (command.startsWith("admin_premium_add3"))
{
try
{
addPremiumStatus(activeChar, 3, command.substring(19));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Please enter a valid account name.");
}
}
else if (command.startsWith("admin_premium_info"))
{
try
{
viewPremiumInfo(activeChar, command.substring(19));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Please enter a valid account name.");
}
}
else if (command.startsWith("admin_premium_remove"))
{
try
{
removePremium(activeChar, command.substring(21));
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Please enter a valid account name.");
}
}
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;
}
private void addPremiumStatus(L2PcInstance admin, int months, String accountName)
{
if (!Config.PREMIUM_SYSTEM_ENABLED)
{
admin.sendMessage("Premium system is disabled.");
return;
}
// TODO: Add check if account exists XD
PremiumManager.getInstance().addPremiumTime(accountName, months * 30, TimeUnit.DAYS);
admin.sendMessage("Account " + accountName + " will now have premium status until " + new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumExpiration(accountName)) + ".");
}
private void viewPremiumInfo(L2PcInstance admin, String accountName)
{
if (!Config.PREMIUM_SYSTEM_ENABLED)
{
admin.sendMessage("Premium system is disabled.");
return;
}
if (PremiumManager.getInstance().getPremiumExpiration(accountName) > 0)
{
admin.sendMessage("Account " + accountName + " has premium status until " + new SimpleDateFormat("dd.MM.yyyy HH:mm").format(PremiumManager.getInstance().getPremiumExpiration(accountName)) + ".");
}
else
{
admin.sendMessage("Account " + accountName + " has no premium status.");
}
}
private void removePremium(L2PcInstance admin, String accountName)
{
if (!Config.PREMIUM_SYSTEM_ENABLED)
{
admin.sendMessage("Premium system is disabled.");
return;
}
if (PremiumManager.getInstance().getPremiumExpiration(accountName) > 0)
{
PremiumManager.getInstance().removePremiumStatus(accountName);
admin.sendMessage("Account " + accountName + " has no longer premium status.");
}
else
{
admin.sendMessage("Account " + accountName + " has no premium status.");
}
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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 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;
}
}

View File

@@ -0,0 +1,403 @@
/*
* 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.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.StringTokenizer;
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;
import com.l2jmobius.gameserver.instancemanager.PunishmentManager;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.punishment.PunishmentAffect;
import com.l2jmobius.gameserver.model.punishment.PunishmentTask;
import com.l2jmobius.gameserver.model.punishment.PunishmentType;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.util.GMAudit;
import com.l2jmobius.gameserver.util.Util;
/**
* @author UnAfraid
*/
public class AdminPunishment implements IAdminCommandHandler
{
private static final Logger _log = Logger.getLogger(AdminPunishment.class.getName());
private static final String[] ADMIN_COMMANDS =
{
"admin_punishment",
"admin_punishment_add",
"admin_punishment_remove",
"admin_ban_acc",
"admin_unban_acc",
"admin_ban_chat",
"admin_unban_chat",
"admin_ban_char",
"admin_unban_char",
"admin_jail",
"admin_unjail"
};
private static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
final StringTokenizer st = new StringTokenizer(command, " ");
if (!st.hasMoreTokens())
{
return false;
}
final String cmd = st.nextToken();
switch (cmd)
{
case "admin_punishment":
{
if (!st.hasMoreTokens())
{
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment.htm");
if (content != null)
{
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.warning(getClass().getSimpleName() + ": data/html/admin/punishment.htm is missing");
}
}
else
{
final String subcmd = st.nextToken();
switch (subcmd)
{
case "info":
{
String key = st.hasMoreTokens() ? st.nextToken() : null;
final String af = st.hasMoreTokens() ? st.nextToken() : null;
final String name = key;
if ((key == null) || (af == null))
{
activeChar.sendMessage("Not enough data specified!");
break;
}
final PunishmentAffect affect = PunishmentAffect.getByName(af);
if (affect == null)
{
activeChar.sendMessage("Incorrect value specified for affect type!");
break;
}
// Swap the name of the character with it's id.
if (affect == PunishmentAffect.CHARACTER)
{
key = findCharId(key);
}
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-info.htm");
if (content != null)
{
final StringBuilder sb = new StringBuilder();
for (PunishmentType type : PunishmentType.values())
{
if (PunishmentManager.getInstance().hasPunishment(key, affect, type))
{
final long expiration = PunishmentManager.getInstance().getPunishmentExpiration(key, affect, type);
String expire = "never";
if (expiration > 0)
{
// Synchronize date formatter since its not thread safe.
synchronized (DATE_FORMATTER)
{
expire = DATE_FORMATTER.format(new Date(expiration));
}
}
sb.append("<tr><td><font color=\"LEVEL\">" + type + "</font></td><td>" + expire + "</td><td><a action=\"bypass -h admin_punishment_remove " + name + " " + affect + " " + type + "\">Remove</a></td></tr>");
}
}
content = content.replaceAll("%player_name%", name);
content = content.replaceAll("%punishments%", sb.toString());
content = content.replaceAll("%affects%", CommonUtil.implode(PunishmentAffect.values(), ";"));
content = content.replaceAll("%affect_type%", affect.name());
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
}
else
{
_log.warning(getClass().getSimpleName() + ": data/html/admin/punishment-info.htm is missing");
}
break;
}
case "player":
{
L2PcInstance target = null;
if (st.hasMoreTokens())
{
final String playerName = st.nextToken();
if (playerName.isEmpty() && ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()))
{
return useAdminCommand("admin_punishment", activeChar);
}
target = L2World.getInstance().getPlayer(playerName);
}
if ((target == null) && ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()))
{
activeChar.sendMessage("You must target player!");
break;
}
if (target == null)
{
target = activeChar.getTarget().getActingPlayer();
}
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%", CommonUtil.implode(PunishmentType.values(), ";"));
content = content.replaceAll("%acc%", target.getAccountName());
content = content.replaceAll("%char%", target.getName());
content = content.replaceAll("%ip%", target.getIPAddress());
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
}
else
{
_log.warning(getClass().getSimpleName() + ": data/html/admin/punishment-player.htm is missing");
}
break;
}
}
}
break;
}
case "admin_punishment_add":
{
// Add new punishment
String key = st.hasMoreTokens() ? st.nextToken() : null;
final String af = st.hasMoreTokens() ? st.nextToken() : null;
final String t = st.hasMoreTokens() ? st.nextToken() : null;
final String exp = st.hasMoreTokens() ? st.nextToken() : null;
String reason = st.hasMoreTokens() ? st.nextToken() : null;
// Let's grab the other part of the reason if there is..
if (reason != null)
{
while (st.hasMoreTokens())
{
reason += " " + st.nextToken();
}
if (!reason.isEmpty())
{
reason = reason.replaceAll("\\$", "\\\\\\$");
reason = reason.replaceAll("\r\n", "<br1>");
reason = reason.replace("<", "&lt;");
reason = reason.replace(">", "&gt;");
}
}
final String name = key;
if ((key == null) || (af == null) || (t == null) || (exp == null) || (reason == null))
{
activeChar.sendMessage("Please fill all the fields!");
break;
}
if (!Util.isDigit(exp) && !exp.equals("-1"))
{
activeChar.sendMessage("Incorrect value specified for expiration time!");
break;
}
long expirationTime = Integer.parseInt(exp);
if (expirationTime > 0)
{
expirationTime = System.currentTimeMillis() + (expirationTime * 60 * 1000);
}
final PunishmentAffect affect = PunishmentAffect.getByName(af);
final PunishmentType type = PunishmentType.getByName(t);
if ((affect == null) || (type == null))
{
activeChar.sendMessage("Incorrect value specified for affect/punishment type!");
break;
}
// Swap the name of the character with it's id.
if (affect == PunishmentAffect.CHARACTER)
{
key = findCharId(key);
}
else if (affect == PunishmentAffect.IP)
{
try
{
final InetAddress addr = InetAddress.getByName(key);
if (addr.isLoopbackAddress())
{
throw new UnknownHostException("You cannot ban any local address!");
}
else if (Config.GAME_SERVER_HOSTS.contains(addr.getHostAddress()))
{
throw new UnknownHostException("You cannot ban your gameserver's address!");
}
}
catch (UnknownHostException e)
{
activeChar.sendMessage("You've entered an incorrect IP address!");
activeChar.sendMessage(e.getMessage());
break;
}
}
// Check if we already put the same punishment on that guy ^^
if (PunishmentManager.getInstance().hasPunishment(key, affect, type))
{
activeChar.sendMessage("Target is already affected by that punishment.");
break;
}
// Punish him!
PunishmentManager.getInstance().startPunishment(new PunishmentTask(key, affect, type, expirationTime, reason, activeChar.getName()));
activeChar.sendMessage("Punishment " + type.name() + " have been applied to: " + affect + " " + name + "!");
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, affect.name(), name);
return useAdminCommand("admin_punishment info " + name + " " + affect.name(), activeChar);
}
case "admin_punishment_remove":
{
// Remove punishment.
String key = st.hasMoreTokens() ? st.nextToken() : null;
final String af = st.hasMoreTokens() ? st.nextToken() : null;
final String t = st.hasMoreTokens() ? st.nextToken() : null;
final String name = key;
if ((key == null) || (af == null) || (t == null))
{
activeChar.sendMessage("Not enough data specified!");
break;
}
final PunishmentAffect affect = PunishmentAffect.getByName(af);
final PunishmentType type = PunishmentType.getByName(t);
if ((affect == null) || (type == null))
{
activeChar.sendMessage("Incorrect value specified for affect/punishment type!");
break;
}
// Swap the name of the character with it's id.
if (affect == PunishmentAffect.CHARACTER)
{
key = findCharId(key);
}
if (!PunishmentManager.getInstance().hasPunishment(key, affect, type))
{
activeChar.sendMessage("Target is not affected by that punishment!");
break;
}
PunishmentManager.getInstance().stopPunishment(key, affect, type);
activeChar.sendMessage("Punishment " + type.name() + " have been stopped to: " + affect + " " + name + "!");
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, affect.name(), name);
return useAdminCommand("admin_punishment info " + name + " " + affect.name(), activeChar);
}
case "admin_ban_char":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.BAN, 0, "Banned by admin"), activeChar);
}
}
case "admin_unban_char":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.BAN), activeChar);
}
}
case "admin_ban_acc":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.ACCOUNT, PunishmentType.BAN, 0, "Banned by admin"), activeChar);
}
}
case "admin_unban_acc":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.ACCOUNT, PunishmentType.BAN), activeChar);
}
}
case "admin_ban_chat":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, 0, "Chat banned by admin"), activeChar);
}
}
case "admin_unban_chat":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN), activeChar);
}
}
case "admin_jail":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.JAIL, 0, "Jailed by admin"), activeChar);
}
}
case "admin_unjail":
{
if (st.hasMoreTokens())
{
return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.JAIL), activeChar);
}
}
}
return true;
}
private static String findCharId(String key)
{
final int charId = CharNameTable.getInstance().getIdByName(key);
if (charId > 0) // Yeah its a char name!
{
return Integer.toString(charId);
}
return key;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +1,322 @@
/*
* 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.PrimeShopData;
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 "primeshop":
{
PrimeShopData.getInstance().load();
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Prime Shop 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;
}
}

View File

@@ -0,0 +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.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);
}
}
}

View File

@@ -0,0 +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);
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();
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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 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;
}
}

View File

@@ -0,0 +1,171 @@
/*
* 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.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import com.l2jmobius.Config;
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;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* @author St3eT
*/
public class AdminServerInfo implements IAdminCommandHandler
{
private static final SimpleDateFormat fmt = new SimpleDateFormat("hh:mm a");
private static final String[] ADMIN_COMMANDS =
{
"admin_serverinfo"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_serverinfo"))
{
final NpcHtmlMessage html = new NpcHtmlMessage();
final Runtime RunTime = Runtime.getRuntime();
final int mb = 1024 * 1024;
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"));
html.replace("%slots%", getPlayersCount("ALL") + "/" + Config.MAXIMUM_ONLINE_USERS);
html.replace("%gameTime%", GameTimeController.getInstance().getGameHour() + ":" + GameTimeController.getInstance().getGameMinute());
html.replace("%dayNight%", GameTimeController.getInstance().isNight() ? "Night" : "Day");
html.replace("%geodata%", Config.PATHFINDING > 0 ? "Enabled" : "Disabled");
html.replace("%serverTime%", fmt.format(new Date(System.currentTimeMillis())));
html.replace("%serverUpTime%", getServerUpTime());
html.replace("%onlineAll%", getPlayersCount("ALL"));
html.replace("%offlineTrade%", getPlayersCount("OFF_TRADE"));
html.replace("%onlineGM%", getPlayersCount("GM"));
html.replace("%onlineReal%", getPlayersCount("ALL_REAL"));
html.replace("%usedMem%", (RunTime.maxMemory() / mb) - (((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb));
html.replace("%freeMem%", ((RunTime.maxMemory() - RunTime.totalMemory()) + RunTime.freeMemory()) / mb);
html.replace("%totalMem%", Runtime.getRuntime().maxMemory() / 1048576);
html.replace("%theardInfoGen%", buildTheardInfo("GENERAL"));
html.replace("%theardInfoEff%", buildTheardInfo("EFFECTS"));
html.replace("%theardInfoAi%", buildTheardInfo("AI"));
html.replace("%theardInfoEvent%", buildTheardInfo("EVENT"));
html.replace("%theardInfoPack%", buildTheardInfo("PACKETS"));
html.replace("%theardInfoIOPack%", buildTheardInfo("IOPACKETS"));
html.replace("%theardInfoGenTask%", buildTheardInfo("GENERAL_TASKS"));
html.replace("%theardInfoEvnTask%", buildTheardInfo("EVENT_TASKS"));
activeChar.sendPacket(html);
}
return true;
}
private String getServerUpTime()
{
long time = System.currentTimeMillis() - GameServer.dateTimeServerStarted.getTimeInMillis();
final long days = TimeUnit.MILLISECONDS.toDays(time);
time -= TimeUnit.DAYS.toMillis(days);
final long hours = TimeUnit.MILLISECONDS.toHours(time);
time -= TimeUnit.HOURS.toMillis(hours);
return days + " Days, " + hours + " Hours, " + TimeUnit.MILLISECONDS.toMinutes(time) + " Minutes";
}
private String buildTheardInfo(String category)
{
final StringBuilder tb = new StringBuilder();
tb.append("<table width=\"270\" border=\"0\" bgcolor=\"444444\">");
for (Entry<String, Object> info : ThreadPoolManager.getInstance().getStats(category).getSet().entrySet())
{
tb.append("<tr>");
tb.append("<td>" + info.getKey() + ":</td>");
tb.append("<td><font color=\"00FF00\">" + info.getValue() + "</font></td>");
tb.append("</tr>");
}
tb.append("</table>");
return tb.toString();
}
private int getPlayersCount(String type)
{
switch (type)
{
case "ALL":
{
return L2World.getInstance().getPlayers().size();
}
case "OFF_TRADE":
{
int offlineCount = 0;
final Collection<L2PcInstance> objs = L2World.getInstance().getPlayers();
for (L2PcInstance player : objs)
{
if ((player.getClient() == null) || player.getClient().isDetached())
{
offlineCount++;
}
}
return offlineCount;
}
case "GM":
{
int onlineGMcount = 0;
for (L2PcInstance gm : AdminData.getInstance().getAllGms(true))
{
if ((gm != null) && gm.isOnline() && (gm.getClient() != null) && !gm.getClient().isDetached())
{
onlineGMcount++;
}
}
return onlineGMcount;
}
case "ALL_REAL":
{
final Set<String> realPlayers = new HashSet<>();
for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
{
if ((onlinePlayer != null) && (onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached())
{
realPlayers.add(onlinePlayer.getIPAddress());
}
}
return realPlayers.size();
}
}
return 0;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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);
}
}

View File

@@ -0,0 +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.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].contains("_"))
{
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>&nbsp;</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>&nbsp;</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;
}
}

View File

@@ -0,0 +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
*/
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);
}
}

View File

@@ -0,0 +1,649 @@
/*
* 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 java.util.logging.Level;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.data.xml.impl.ClassListData;
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.L2Clan;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2SkillLearn;
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.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.AcquireSkillList;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.PledgeSkillList;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
/**
* This class handles following admin commands:
* <ul>
* <li>show_skills</li>
* <li>remove_skills</li>
* <li>skill_list</li>
* <li>skill_index</li>
* <li>add_skill</li>
* <li>remove_skill</li>
* <li>get_skills</li>
* <li>reset_skills</li>
* <li>give_all_skills</li>
* <li>give_all_skills_fs</li>
* <li>admin_give_all_clan_skills</li>
* <li>remove_all_skills</li>
* <li>add_clan_skills</li>
* <li>admin_setskill</li>
* </ul>
* @version 2012/02/26 Small fixes by Zoey76 05/03/2011
*/
public class AdminSkill implements IAdminCommandHandler
{
private static Logger _log = Logger.getLogger(AdminSkill.class.getName());
private static final String[] ADMIN_COMMANDS =
{
"admin_show_skills",
"admin_remove_skills",
"admin_skill_list",
"admin_skill_index",
"admin_add_skill",
"admin_remove_skill",
"admin_get_skills",
"admin_reset_skills",
"admin_give_all_skills",
"admin_give_all_skills_fs",
"admin_give_clan_skills",
"admin_give_all_clan_skills",
"admin_remove_all_skills",
"admin_add_clan_skill",
"admin_setskill",
"admin_cast",
"admin_castnow"
};
private static Skill[] adminSkills;
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_show_skills"))
{
showMainPage(activeChar);
}
else if (command.startsWith("admin_remove_skills"))
{
try
{
final String val = command.substring(20);
removeSkillsPage(activeChar, Integer.parseInt(val));
}
catch (StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_skill_list"))
{
AdminHtml.showAdminHtml(activeChar, "skills.htm");
}
else if (command.startsWith("admin_skill_index"))
{
try
{
final String val = command.substring(18);
AdminHtml.showAdminHtml(activeChar, "skills/" + val + ".htm");
}
catch (StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_add_skill"))
{
try
{
final String val = command.substring(15);
adminAddSkill(activeChar, val);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //add_skill <skill_id> <level>");
}
}
else if (command.startsWith("admin_remove_skill"))
{
try
{
final String id = command.substring(19);
final int idval = Integer.parseInt(id);
adminRemoveSkill(activeChar, idval);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //remove_skill <skill_id>");
}
}
else if (command.equals("admin_get_skills"))
{
adminGetSkills(activeChar);
}
else if (command.equals("admin_reset_skills"))
{
adminResetSkills(activeChar);
}
else if (command.equals("admin_give_all_skills"))
{
adminGiveAllSkills(activeChar, false);
}
else if (command.equals("admin_give_all_skills_fs"))
{
adminGiveAllSkills(activeChar, true);
}
else if (command.equals("admin_give_clan_skills"))
{
adminGiveClanSkills(activeChar, false);
}
else if (command.equals("admin_give_all_clan_skills"))
{
adminGiveClanSkills(activeChar, true);
}
else if (command.equals("admin_remove_all_skills"))
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return false;
}
final L2PcInstance player = target.getActingPlayer();
for (Skill skill : player.getAllSkills())
{
player.removeSkill(skill);
}
activeChar.sendMessage("You have removed all skills from " + player.getName() + ".");
player.sendMessage("Admin removed all skills from you.");
player.sendSkillList();
player.broadcastUserInfo();
player.sendPacket(new AcquireSkillList(player));
}
else if (command.startsWith("admin_add_clan_skill"))
{
try
{
final String[] val = command.split(" ");
adminAddClanSkill(activeChar, Integer.parseInt(val[1]), Integer.parseInt(val[2]));
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //add_clan_skill <skill_id> <level>");
}
}
else if (command.startsWith("admin_setskill"))
{
final String[] split = command.split(" ");
final int id = Integer.parseInt(split[1]);
final int lvl = Integer.parseInt(split[2]);
final Skill skill = SkillData.getInstance().getSkill(id, lvl);
if (skill != null)
{
activeChar.addSkill(skill);
activeChar.sendSkillList();
activeChar.sendMessage("You added yourself skill " + skill.getName() + "(" + id + ") level " + lvl);
activeChar.sendPacket(new AcquireSkillList(activeChar));
}
else
{
activeChar.sendMessage("No such skill found. Id: " + id + " Level: " + lvl);
}
}
else if (command.startsWith("admin_cast"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
command = st.nextToken();
if (!st.hasMoreTokens())
{
activeChar.sendMessage("Skill Id and level are not specified.");
activeChar.sendMessage("Usage: //cast <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 Skill skill = SkillData.getInstance().getSkill(skillId, skillLevel);
if (skill == null)
{
activeChar.sendMessage("Skill with id: " + skillId + ", lvl: " + skillLevel + " not found.");
return false;
}
if (command.equalsIgnoreCase("admin_castnow"))
{
activeChar.sendMessage("Admin instant casting " + skill.getName() + " (" + skillId + "," + skillLevel + ")");
final L2Object target = skill.getTarget(activeChar, true, false, true);
if (target != null)
{
skill.forEachTargetAffected(activeChar, target, o ->
{
if (o.isCharacter())
{
skill.activateSkill(activeChar, (L2Character) o);
}
});
}
}
else
{
activeChar.sendMessage("Admin casting " + skill.getName() + " (" + skillId + "," + skillLevel + ")");
activeChar.doCast(skill);
}
return true;
}
catch (Exception e)
{
activeChar.sendMessage("Failed casting: " + e.getMessage());
activeChar.sendMessage("Usage: //cast <skillId> <skillLevel>");
return false;
}
}
return true;
}
/**
* This function will give all the skills that the target can learn at his/her level
* @param activeChar the active char
* @param includedByFs if {@code true} Forgotten Scroll skills will be delivered.
*/
private void adminGiveAllSkills(L2PcInstance activeChar, boolean includedByFs)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
// Notify player and admin
activeChar.sendMessage("You gave " + player.giveAvailableSkills(includedByFs, true) + " skills to " + player.getName());
player.sendSkillList();
player.sendPacket(new AcquireSkillList(player));
}
/**
* This function will give all the skills that the target's clan can learn at it's level.<br>
* If the target is not the clan leader, a system message will be sent to the Game Master.
* @param activeChar the active char, probably a Game Master.
* @param includeSquad if Squad skills is included
*/
private void adminGiveClanSkills(L2PcInstance activeChar, boolean includeSquad)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
final L2Clan clan = player.getClan();
if (clan == null)
{
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
return;
}
if (!player.isClanLeader())
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER);
sm.addString(player.getName());
activeChar.sendPacket(sm);
}
final Map<Integer, L2SkillLearn> skills = SkillTreesData.getInstance().getMaxPledgeSkills(clan, includeSquad);
for (L2SkillLearn s : skills.values())
{
clan.addNewSkill(SkillData.getInstance().getSkill(s.getSkillId(), s.getSkillLevel()));
}
// Notify target and active char
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
for (L2PcInstance member : clan.getOnlineMembers(0))
{
member.sendSkillList();
}
activeChar.sendMessage("You gave " + skills.size() + " skills to " + player.getName() + "'s clan " + clan.getName() + ".");
player.sendMessage("Your clan received " + skills.size() + " skills.");
}
/**
* TODO: Externalize HTML
* @param activeChar the active Game Master.
* @param page
*/
private void removeSkillsPage(L2PcInstance activeChar, int page)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
final Skill[] skills = player.getAllSkills().toArray(new Skill[player.getAllSkills().size()]);
final int maxSkillsPerPage = 10;
int maxPages = skills.length / maxSkillsPerPage;
if (skills.length > (maxSkillsPerPage * maxPages))
{
maxPages++;
}
if (page > maxPages)
{
page = maxPages;
}
final int skillsStart = maxSkillsPerPage * page;
int skillsEnd = skills.length;
if ((skillsEnd - skillsStart) > maxSkillsPerPage)
{
skillsEnd = skillsStart + maxSkillsPerPage;
}
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
final StringBuilder replyMSG = new StringBuilder(500 + (maxPages * 50) + (((skillsEnd - skillsStart) + 1) * 50));
replyMSG.append("<html><body><table width=260><tr><td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>Character Selection Menu</center></td><td width=40><button value=\"Back\" action=\"bypass -h admin_show_skills\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><br><center>Editing <font color=\"LEVEL\">" + player.getName() + "</font></center><br><table width=270><tr><td>Lv: " + player.getLevel() + " " + ClassListData.getInstance().getClass(player.getClassId()).getClientCode() + "</td></tr></table><br><table width=270><tr><td>Note: Dont forget that modifying players skills can</td></tr><tr><td>ruin the game...</td></tr></table><br><center>Click on the skill you wish to remove:</center><br><center><table width=270><tr>");
for (int x = 0; x < maxPages; x++)
{
final int pagenr = x + 1;
replyMSG.append("<td><a action=\"bypass -h admin_remove_skills " + x + "\">Page " + pagenr + "</a></td>");
}
replyMSG.append("</tr></table></center><br><table width=270><tr><td width=80>Name:</td><td width=60>Level:</td><td width=40>Id:</td></tr>");
for (int i = skillsStart; i < skillsEnd; i++)
{
replyMSG.append("<tr><td width=80><a action=\"bypass -h admin_remove_skill " + skills[i].getId() + "\">" + skills[i].getName() + "</a></td><td width=60>" + skills[i].getLevel() + "</td><td width=40>" + skills[i].getId() + "</td></tr>");
}
replyMSG.append("</table><br><center><table>Remove skill by ID :<tr><td>Id: </td><td><edit var=\"id_to_remove\" width=110></td></tr></table></center><center><button value=\"Remove skill\" action=\"bypass -h admin_remove_skill $id_to_remove\" width=110 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center><br><center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
adminReply.setHtml(replyMSG.toString());
activeChar.sendPacket(adminReply);
}
/**
* @param activeChar the active Game Master.
*/
private void showMainPage(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/charskills.htm");
adminReply.replace("%name%", player.getName());
adminReply.replace("%level%", String.valueOf(player.getLevel()));
adminReply.replace("%class%", ClassListData.getInstance().getClass(player.getClassId()).getClientCode());
activeChar.sendPacket(adminReply);
}
/**
* @param activeChar the active Game Master.
*/
private void adminGetSkills(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
if (player.getName().equals(activeChar.getName()))
{
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_ON_YOURSELF);
}
else
{
final Skill[] skills = player.getAllSkills().toArray(new Skill[player.getAllSkills().size()]);
adminSkills = activeChar.getAllSkills().toArray(new Skill[activeChar.getAllSkills().size()]);
for (Skill skill : adminSkills)
{
activeChar.removeSkill(skill);
}
for (Skill skill : skills)
{
activeChar.addSkill(skill, true);
}
activeChar.sendMessage("You now have all the skills of " + player.getName() + ".");
activeChar.sendSkillList();
}
showMainPage(activeChar);
}
/**
* @param activeChar the active Game Master.
*/
private void adminResetSkills(L2PcInstance activeChar)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
if (adminSkills == null)
{
activeChar.sendMessage("You must get the skills of someone in order to do this.");
}
else
{
final Skill[] skills = player.getAllSkills().toArray(new Skill[player.getAllSkills().size()]);
for (Skill skill : skills)
{
player.removeSkill(skill);
}
for (Skill skill : activeChar.getAllSkills())
{
player.addSkill(skill, true);
}
for (Skill skill : skills)
{
activeChar.removeSkill(skill);
}
for (Skill skill : adminSkills)
{
activeChar.addSkill(skill, true);
}
player.sendMessage("[GM]" + activeChar.getName() + " updated your skills.");
activeChar.sendMessage("You now have all your skills back.");
adminSkills = null;
activeChar.sendSkillList();
player.sendSkillList();
}
showMainPage(activeChar);
}
/**
* @param activeChar the active Game Master.
* @param val
*/
private void adminAddSkill(L2PcInstance activeChar, String val)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
showMainPage(activeChar);
return;
}
final L2PcInstance player = target.getActingPlayer();
final StringTokenizer st = new StringTokenizer(val);
if ((st.countTokens() != 1) && (st.countTokens() != 2))
{
showMainPage(activeChar);
}
else
{
Skill skill = null;
try
{
final String id = st.nextToken();
final String level = st.countTokens() == 1 ? st.nextToken() : null;
final int idval = Integer.parseInt(id);
final int levelval = level == null ? 1 : Integer.parseInt(level);
skill = SkillData.getInstance().getSkill(idval, levelval);
}
catch (Exception e)
{
_log.log(Level.WARNING, "", e);
}
if (skill != null)
{
final String name = skill.getName();
// Player's info.
player.sendMessage("Admin gave you the skill " + name + ".");
player.addSkill(skill, true);
player.sendSkillList();
// Admin info.
activeChar.sendMessage("You gave the skill " + name + " to " + player.getName() + ".");
if (Config.DEBUG)
{
_log.finer("[GM]" + activeChar.getName() + " gave skill " + name + " to " + player.getName() + ".");
}
activeChar.sendSkillList();
}
else
{
activeChar.sendMessage("Error: there is no such skill.");
}
showMainPage(activeChar); // Back to start
}
}
/**
* @param activeChar the active Game Master.
* @param idval
*/
private void adminRemoveSkill(L2PcInstance activeChar, int idval)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;
}
final L2PcInstance player = target.getActingPlayer();
final Skill skill = SkillData.getInstance().getSkill(idval, player.getSkillLevel(idval));
if (skill != null)
{
final String skillname = skill.getName();
player.sendMessage("Admin removed the skill " + skillname + " from your skills list.");
player.removeSkill(skill);
// Admin information
activeChar.sendMessage("You removed the skill " + skillname + " from " + player.getName() + ".");
if (Config.DEBUG)
{
_log.finer("[GM]" + activeChar.getName() + " removed skill " + skillname + " from " + player.getName() + ".");
}
activeChar.sendSkillList();
}
else
{
activeChar.sendMessage("Error: there is no such skill.");
}
removeSkillsPage(activeChar, 0); // Back to previous page
}
/**
* @param activeChar the active Game Master.
* @param id
* @param level
*/
private void adminAddClanSkill(L2PcInstance activeChar, int id, int level)
{
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
showMainPage(activeChar);
return;
}
final L2PcInstance player = target.getActingPlayer();
if (!player.isClanLeader())
{
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER);
sm.addString(player.getName());
activeChar.sendPacket(sm);
showMainPage(activeChar);
return;
}
if ((id < 370) || (id > 391) || (level < 1) || (level > 3))
{
activeChar.sendMessage("Usage: //add_clan_skill <skill_id> <level>");
showMainPage(activeChar);
return;
}
final Skill skill = SkillData.getInstance().getSkill(id, level);
if (skill == null)
{
activeChar.sendMessage("Error: there is no such skill.");
return;
}
final String skillname = skill.getName();
final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THE_CLAN_SKILL_S1_HAS_BEEN_ADDED);
sm.addSkillName(skill);
player.sendPacket(sm);
final L2Clan clan = player.getClan();
clan.broadcastToOnlineMembers(sm);
clan.addNewSkill(skill);
activeChar.sendMessage("You gave the Clan Skill: " + skillname + " to the clan " + clan.getName() + ".");
clan.broadcastToOnlineMembers(new PledgeSkillList(clan));
for (L2PcInstance member : clan.getOnlineMembers(0))
{
member.sendSkillList();
}
showMainPage(activeChar);
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +1,468 @@
/*
* 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();
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()));
}
}

View File

@@ -0,0 +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());
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;
}
}

View File

@@ -0,0 +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.");
}
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +1,605 @@
/*
* 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 java.util.NoSuchElementException;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import com.l2jmobius.Config;
import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.GeoData;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.data.xml.impl.NpcData;
import com.l2jmobius.gameserver.datatables.SpawnTable;
import com.l2jmobius.gameserver.enums.AdminTeleportType;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.instancemanager.DBSpawnManager;
import com.l2jmobius.gameserver.instancemanager.MapRegionManager;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Spawn;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2GrandBossInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2RaidBossInstance;
import com.l2jmobius.gameserver.model.actor.templates.L2NpcTemplate;
import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
/**
* This class handles following admin commands: - show_moves - show_teleport - teleport_to_character - move_to - teleport_character
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $ con.close() change and small typo fix by Zoey76 24/02/2011
*/
public class AdminTeleport implements IAdminCommandHandler
{
private static final Logger _log = Logger.getLogger(AdminTeleport.class.getName());
private static final String[] ADMIN_COMMANDS =
{
"admin_show_moves",
"admin_show_moves_other",
"admin_show_teleport",
"admin_teleport_to_character",
"admin_teleportto",
"admin_teleport",
"admin_move_to",
"admin_teleport_character",
"admin_recall",
"admin_walk",
"teleportto",
"recall",
"admin_recall_npc",
"admin_gonorth",
"admin_gosouth",
"admin_goeast",
"admin_gowest",
"admin_goup",
"admin_godown",
"admin_tele",
"admin_teleto",
"admin_instant_move",
"admin_sendhome"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.equals("admin_instant_move"))
{
activeChar.sendMessage("Instant move ready. Click where you want to go.");
activeChar.setTeleMode(AdminTeleportType.DEMONIC);
}
else if (command.equals("admin_teleto sayune"))
{
activeChar.sendMessage("Sayune move ready. Click where you want to go.");
activeChar.setTeleMode(AdminTeleportType.SAYUNE);
}
else if (command.equals("admin_teleto charge"))
{
activeChar.sendMessage("Charge move ready. Click where you want to go.");
activeChar.setTeleMode(AdminTeleportType.CHARGE);
}
else if (command.equals("admin_teleto end"))
{
activeChar.setTeleMode(AdminTeleportType.NORMAL);
}
else if (command.equals("admin_show_moves"))
{
AdminHtml.showAdminHtml(activeChar, "teleports.htm");
}
else if (command.equals("admin_show_moves_other"))
{
AdminHtml.showAdminHtml(activeChar, "tele/other.html");
}
else if (command.equals("admin_show_teleport"))
{
showTeleportCharWindow(activeChar);
}
else if (command.equals("admin_recall_npc"))
{
recallNPC(activeChar);
}
else if (command.equals("admin_teleport_to_character"))
{
teleportToCharacter(activeChar, activeChar.getTarget());
}
else if (command.startsWith("admin_walk"))
{
try
{
final String val = command.substring(11);
final StringTokenizer st = new StringTokenizer(val);
final int x = Integer.parseInt(st.nextToken());
final int y = Integer.parseInt(st.nextToken());
final int z = Integer.parseInt(st.nextToken());
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(x, y, z, 0));
}
catch (Exception e)
{
if (Config.DEBUG)
{
_log.info("admin_walk: " + e);
}
}
}
else if (command.startsWith("admin_move_to"))
{
try
{
final String val = command.substring(14);
teleportTo(activeChar, val);
}
catch (StringIndexOutOfBoundsException e)
{
// Case of empty or missing coordinates
AdminHtml.showAdminHtml(activeChar, "teleports.htm");
}
catch (NumberFormatException nfe)
{
activeChar.sendMessage("Usage: //move_to <x> <y> <z>");
AdminHtml.showAdminHtml(activeChar, "teleports.htm");
}
}
else if (command.startsWith("admin_teleport_character"))
{
try
{
final String val = command.substring(25);
teleportCharacter(activeChar, val);
}
catch (StringIndexOutOfBoundsException e)
{
// Case of empty coordinates
activeChar.sendMessage("Wrong or no Coordinates given.");
showTeleportCharWindow(activeChar); // back to character teleport
}
}
else if (command.startsWith("admin_teleportto "))
{
try
{
final String targetName = command.substring(17);
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
teleportToCharacter(activeChar, player);
}
catch (StringIndexOutOfBoundsException e)
{
}
}
else if (command.startsWith("admin_teleport"))
{
try
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
final int x = (int) Float.parseFloat(st.nextToken());
final int y = (int) Float.parseFloat(st.nextToken());
final int z = st.hasMoreTokens() ? ((int) Float.parseFloat(st.nextToken())) : GeoData.getInstance().getHeight(x, y, L2World.MAP_MAX_Z);
activeChar.teleToLocation(x, y, z);
}
catch (Exception e)
{
activeChar.sendMessage("Wrong coordinates!");
}
}
else if (command.startsWith("admin_recall "))
{
try
{
final String[] param = command.split(" ");
if (param.length != 2)
{
activeChar.sendMessage("Usage: //recall <playername>");
return false;
}
final String targetName = param[1];
final L2PcInstance player = L2World.getInstance().getPlayer(targetName);
if (player != null)
{
teleportCharacter(player, activeChar.getLocation(), activeChar);
}
else
{
changeCharacterPosition(activeChar, targetName);
}
}
catch (StringIndexOutOfBoundsException e)
{
}
}
else if (command.equals("admin_tele"))
{
showTeleportWindow(activeChar);
}
else if (command.startsWith("admin_go"))
{
int intVal = 150;
int x = activeChar.getX(), y = activeChar.getY(), z = activeChar.getZ();
try
{
final String val = command.substring(8);
final StringTokenizer st = new StringTokenizer(val);
final String dir = st.nextToken();
if (st.hasMoreTokens())
{
intVal = Integer.parseInt(st.nextToken());
}
if (dir.equals("east"))
{
x += intVal;
}
else if (dir.equals("west"))
{
x -= intVal;
}
else if (dir.equals("north"))
{
y -= intVal;
}
else if (dir.equals("south"))
{
y += intVal;
}
else if (dir.equals("up"))
{
z += intVal;
}
else if (dir.equals("down"))
{
z -= intVal;
}
activeChar.teleToLocation(new Location(x, y, z));
showTeleportWindow(activeChar);
}
catch (Exception e)
{
activeChar.sendMessage("Usage: //go<north|south|east|west|up|down> [offset] (default 150)");
}
}
else if (command.startsWith("admin_sendhome"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken(); // Skip command.
if (st.countTokens() > 1)
{
activeChar.sendMessage("Usage: //sendhome <playername>");
}
else if (st.countTokens() == 1)
{
final String name = st.nextToken();
final L2PcInstance player = L2World.getInstance().getPlayer(name);
if (player == null)
{
activeChar.sendPacket(SystemMessageId.THAT_PLAYER_IS_NOT_ONLINE);
return false;
}
teleportHome(player);
}
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
{
teleportHome(target.getActingPlayer());
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
/**
* This method sends a player to it's home town.
* @param player the player to teleport.
*/
private void teleportHome(L2PcInstance player)
{
String regionName;
switch (player.getRace())
{
case ELF:
regionName = "elf_town";
break;
case DARK_ELF:
regionName = "darkelf_town";
break;
case ORC:
regionName = "orc_town";
break;
case DWARF:
regionName = "dwarf_town";
break;
case KAMAEL:
regionName = "kamael_town";
break;
case HUMAN:
default:
regionName = "talking_island_town";
}
player.teleToLocation(MapRegionManager.getInstance().getMapRegionByName(regionName).getSpawnLoc(), true, null);
}
private void teleportTo(L2PcInstance activeChar, String Coords)
{
try
{
final StringTokenizer st = new StringTokenizer(Coords);
final int x = Integer.parseInt(st.nextToken());
final int y = Integer.parseInt(st.nextToken());
final int z = Integer.parseInt(st.nextToken());
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.teleToLocation(x, y, z);
activeChar.sendMessage("You have been teleported to " + Coords);
}
catch (NoSuchElementException nsee)
{
activeChar.sendMessage("Wrong or no Coordinates given.");
}
}
private void showTeleportWindow(L2PcInstance activeChar)
{
AdminHtml.showAdminHtml(activeChar, "move.htm");
}
private void showTeleportCharWindow(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);
final String replyMSG = "<html><title>Teleport Character</title><body>The character you will teleport is " + player.getName() + ".<br>Co-ordinate x<edit var=\"char_cord_x\" width=110>Co-ordinate y<edit var=\"char_cord_y\" width=110>Co-ordinate z<edit var=\"char_cord_z\" width=110><button value=\"Teleport\" action=\"bypass -h admin_teleport_character $char_cord_x $char_cord_y $char_cord_z\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Teleport near you\" action=\"bypass -h admin_teleport_character " + activeChar.getX() + " " + activeChar.getY() + " " + activeChar.getZ() + "\" width=115 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><center><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>";
adminReply.setHtml(replyMSG);
activeChar.sendPacket(adminReply);
}
private void teleportCharacter(L2PcInstance activeChar, String Cords)
{
final L2Object target = activeChar.getTarget();
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
{
try
{
final StringTokenizer st = new StringTokenizer(Cords);
final String x1 = st.nextToken();
final int x = Integer.parseInt(x1);
final String y1 = st.nextToken();
final int y = Integer.parseInt(y1);
final String z1 = st.nextToken();
final int z = Integer.parseInt(z1);
teleportCharacter(player, new Location(x, y, z), null);
}
catch (NoSuchElementException nsee)
{
}
}
}
/**
* @param player
* @param loc
* @param activeChar
*/
private void teleportCharacter(L2PcInstance player, Location loc, L2PcInstance activeChar)
{
if (player != null)
{
// Check for jail
if (player.isJailed())
{
activeChar.sendMessage("Sorry, player " + player.getName() + " is in Jail.");
}
else
{
activeChar.sendMessage("You have recalled " + player.getName());
player.sendMessage("Admin is teleporting you.");
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
player.teleToLocation(loc, true, activeChar.getInstanceWorld());
}
}
}
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
{
if ((target == null) || !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.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
activeChar.teleToLocation(player, true, player.getInstanceWorld());
activeChar.sendMessage("You have teleported to character " + player.getName() + ".");
}
}
private void changeCharacterPosition(L2PcInstance activeChar, String name)
{
final int x = activeChar.getX();
final int y = activeChar.getY();
final int z = activeChar.getZ();
try (Connection con = DatabaseFactory.getInstance().getConnection())
{
final PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=? WHERE char_name=?");
statement.setInt(1, x);
statement.setInt(2, y);
statement.setInt(3, z);
statement.setString(4, name);
statement.execute();
final int count = statement.getUpdateCount();
statement.close();
if (count == 0)
{
activeChar.sendMessage("Character not found or position unaltered.");
}
else
{
activeChar.sendMessage("Player's [" + name + "] position is now set to (" + x + "," + y + "," + z + ").");
}
}
catch (SQLException se)
{
activeChar.sendMessage("SQLException while changing offline character's position");
}
}
private void recallNPC(L2PcInstance activeChar)
{
final L2Object obj = activeChar.getTarget();
if ((obj instanceof L2Npc) && !((L2Npc) obj).isMinion() && !(obj instanceof L2RaidBossInstance) && !(obj instanceof L2GrandBossInstance))
{
final L2Npc target = (L2Npc) obj;
final int monsterTemplate = target.getTemplate().getId();
final L2NpcTemplate template1 = NpcData.getInstance().getTemplate(monsterTemplate);
if (template1 == null)
{
activeChar.sendMessage("Incorrect monster template.");
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
return;
}
L2Spawn spawn = target.getSpawn();
if (spawn == null)
{
activeChar.sendMessage("Incorrect monster spawn.");
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
return;
}
final int respawnTime = spawn.getRespawnDelay() / 1000;
target.deleteMe();
spawn.stopRespawn();
SpawnTable.getInstance().deleteSpawn(spawn, true);
try
{
spawn = new L2Spawn(template1);
spawn.setX(activeChar.getX());
spawn.setY(activeChar.getY());
spawn.setZ(activeChar.getZ());
spawn.setAmount(1);
spawn.setHeading(activeChar.getHeading());
spawn.setRespawnDelay(respawnTime);
if (activeChar.isInInstance())
{
spawn.setInstanceId(activeChar.getInstanceId());
}
SpawnTable.getInstance().addNewSpawn(spawn, true);
spawn.init();
activeChar.sendMessage("Created " + template1.getName() + " on " + target.getObjectId() + ".");
if (Config.DEBUG)
{
_log.finer("Spawn at X=" + spawn.getX() + " Y=" + spawn.getY() + " Z=" + spawn.getZ());
_log.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") moved NPC " + target.getObjectId());
}
}
catch (Exception e)
{
activeChar.sendMessage("Target is not in game.");
}
}
else if (obj instanceof L2RaidBossInstance)
{
final L2RaidBossInstance target = (L2RaidBossInstance) obj;
final L2Spawn spawn = target.getSpawn();
final double curHP = target.getCurrentHp();
final double curMP = target.getCurrentMp();
if (spawn == null)
{
activeChar.sendMessage("Incorrect raid spawn.");
_log.warning("ERROR: NPC Id" + target.getId() + " has a 'null' spawn.");
return;
}
DBSpawnManager.getInstance().deleteSpawn(spawn, true);
try
{
final L2Spawn spawnDat = new L2Spawn(target.getId());
spawnDat.setX(activeChar.getX());
spawnDat.setY(activeChar.getY());
spawnDat.setZ(activeChar.getZ());
spawnDat.setAmount(1);
spawnDat.setHeading(activeChar.getHeading());
spawnDat.setRespawnMinDelay(43200);
spawnDat.setRespawnMaxDelay(129600);
DBSpawnManager.getInstance().addNewSpawn(spawnDat, 0, curHP, curMP, true);
}
catch (Exception e)
{
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
}
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
}
}

View File

@@ -0,0 +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.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;
}
}

View File

@@ -0,0 +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 java.util.logging.Logger;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
/**
* This class handles following admin commands:
* <ul>
* <li>admin_unblockip</li>
* </ul>
* @version $Revision: 1.3.2.6.2.4 $ $Date: 2005/04/11 10:06:06 $
*/
public class AdminUnblockIp implements IAdminCommandHandler
{
private static final Logger _log = Logger.getLogger(AdminUnblockIp.class.getName());
private static final String[] ADMIN_COMMANDS =
{
"admin_unblockip"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (command.startsWith("admin_unblockip "))
{
try
{
final String ipAddress = command.substring(16);
if (unblockIp(ipAddress, activeChar))
{
activeChar.sendMessage("Removed IP " + ipAddress + " from blocklist!");
}
}
catch (StringIndexOutOfBoundsException e)
{
activeChar.sendMessage("Usage: //unblockip <ip>");
}
}
return true;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
private boolean unblockIp(String ipAddress, L2PcInstance activeChar)
{
// LoginServerThread.getInstance().unBlockip(ipAddress);
_log.warning("IP removed by GM " + activeChar.getName());
return true;
}
}

View File

@@ -0,0 +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.admincommandhandlers;
import java.util.StringTokenizer;
import com.l2jmobius.Config;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.PcStat;
/**
* @author Psychokiller1888
*/
public class AdminVitality implements IAdminCommandHandler
{
private static final String[] ADMIN_COMMANDS =
{
"admin_set_vitality",
"admin_full_vitality",
"admin_empty_vitality",
"admin_get_vitality"
};
@Override
public boolean useAdminCommand(String command, L2PcInstance activeChar)
{
if (activeChar == null)
{
return false;
}
if (!Config.ENABLE_VITALITY)
{
activeChar.sendMessage("Vitality is not enabled on the server!");
return false;
}
int vitality = 0;
final StringTokenizer st = new StringTokenizer(command, " ");
final String cmd = st.nextToken();
if (activeChar.getTarget() instanceof L2PcInstance)
{
final L2PcInstance target = (L2PcInstance) activeChar.getTarget();
if (cmd.equals("admin_set_vitality"))
{
try
{
vitality = Integer.parseInt(st.nextToken());
}
catch (Exception e)
{
activeChar.sendMessage("Incorrect vitality");
}
target.setVitalityPoints(vitality, true);
target.sendMessage("Admin set your Vitality points to " + vitality);
}
else if (cmd.equals("admin_full_vitality"))
{
target.setVitalityPoints(PcStat.MAX_VITALITY_POINTS, true);
target.sendMessage("Admin completly recharged your Vitality");
}
else if (cmd.equals("admin_empty_vitality"))
{
target.setVitalityPoints(PcStat.MIN_VITALITY_POINTS, true);
target.sendMessage("Admin completly emptied your Vitality");
}
else if (cmd.equals("admin_get_vitality"))
{
vitality = target.getVitalityPoints();
activeChar.sendMessage("Player vitality points: " + vitality);
}
return true;
}
activeChar.sendMessage("Target not found or not a player");
return false;
}
@Override
public String[] getAdminCommandList()
{
return ADMIN_COMMANDS;
}
}

View File

@@ -0,0 +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.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;
}
}

View 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;
}
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +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;
}
}

View File

@@ -0,0 +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.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;
}
}

Some files were not shown because too many files have changed in this diff Show More