Separated the Classic Datapack to it's own folder.
This commit is contained in:
226
trunk/dist/game/data_classic/scripts/handlers/EffectMasterHandler.java
vendored
Normal file
226
trunk/dist/game/data_classic/scripts/handlers/EffectMasterHandler.java
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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 handlers.effecthandlers.*;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.gameserver.handler.EffectHandler;
|
||||
import com.l2jserver.gameserver.model.effects.AbstractEffect;
|
||||
|
||||
/**
|
||||
* Effect Master handler.
|
||||
* @author BiggBoss, Zoey76
|
||||
*/
|
||||
public final class EffectMasterHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(EffectMasterHandler.class.getName());
|
||||
|
||||
private static final Class<?>[] EFFECTS =
|
||||
{
|
||||
AddHate.class,
|
||||
AttackTrait.class,
|
||||
Backstab.class,
|
||||
Betray.class,
|
||||
Blink.class,
|
||||
BlockAction.class,
|
||||
BlockChat.class,
|
||||
BlockParty.class,
|
||||
BlockBuffSlot.class,
|
||||
BlockResurrection.class,
|
||||
Bluff.class,
|
||||
Buff.class,
|
||||
CallParty.class,
|
||||
CallPc.class,
|
||||
CallSkill.class,
|
||||
ChameleonRest.class,
|
||||
ChangeFace.class,
|
||||
ChangeFishingMastery.class,
|
||||
ChangeHairColor.class,
|
||||
ChangeHairStyle.class,
|
||||
ClanGate.class,
|
||||
ClassChange.class,
|
||||
Confuse.class,
|
||||
ConsumeBody.class,
|
||||
ConvertItem.class,
|
||||
CpDamPercent.class,
|
||||
CpHeal.class,
|
||||
CpHealOverTime.class,
|
||||
CpHealPercent.class,
|
||||
CrystalGradeModify.class,
|
||||
CubicMastery.class,
|
||||
DamOverTime.class,
|
||||
DamOverTimePercent.class,
|
||||
DeathLink.class,
|
||||
Debuff.class,
|
||||
DefenceTrait.class,
|
||||
DeleteHate.class,
|
||||
DeleteHateOfMe.class,
|
||||
DetectHiddenObjects.class,
|
||||
Detection.class,
|
||||
Disarm.class,
|
||||
DispelAll.class,
|
||||
DispelByCategory.class,
|
||||
DispelBySlot.class,
|
||||
DispelBySlotProbability.class,
|
||||
EnableCloak.class,
|
||||
EnemyCharge.class,
|
||||
EnergyAttack.class,
|
||||
EnlargeAbnormalSlot.class,
|
||||
Escape.class,
|
||||
FakeDeath.class,
|
||||
FatalBlow.class,
|
||||
Fear.class,
|
||||
Fishing.class,
|
||||
Flag.class,
|
||||
FocusEnergy.class,
|
||||
FocusMaxEnergy.class,
|
||||
FocusSouls.class,
|
||||
GetAgro.class,
|
||||
GiveRecommendation.class,
|
||||
GiveSp.class,
|
||||
Grow.class,
|
||||
HairAccessorySet.class,
|
||||
Harvesting.class,
|
||||
HeadquarterCreate.class,
|
||||
Heal.class,
|
||||
HealOverTime.class,
|
||||
HealPercent.class,
|
||||
Hide.class,
|
||||
HpByLevel.class,
|
||||
HpCpHeal.class,
|
||||
HpDrain.class,
|
||||
ImmobileBuff.class,
|
||||
ImmobilePetBuff.class,
|
||||
Invincible.class,
|
||||
JumpToFriend.class,
|
||||
KnockBack.class,
|
||||
KnockDown.class,
|
||||
Lethal.class,
|
||||
Lucky.class,
|
||||
MagicalAttack.class,
|
||||
MagicalAttackByAbnormal.class,
|
||||
MagicalAttackMp.class,
|
||||
MagicalSoulAttack.class,
|
||||
ManaDamOverTime.class,
|
||||
ManaHeal.class,
|
||||
ManaHealByLevel.class,
|
||||
ManaHealOverTime.class,
|
||||
ManaHealPercent.class,
|
||||
MaxCp.class,
|
||||
MaxHp.class,
|
||||
MpConsumePerLevel.class,
|
||||
Mute.class,
|
||||
NoblesseBless.class,
|
||||
OpenChest.class,
|
||||
Unsummon.class,
|
||||
OpenCommonRecipeBook.class,
|
||||
OpenDoor.class,
|
||||
OpenDwarfRecipeBook.class,
|
||||
Paralyze.class,
|
||||
Passive.class,
|
||||
Petrification.class,
|
||||
PhysicalAttack.class,
|
||||
PhysicalAttackHpLink.class,
|
||||
PhysicalAttackMute.class,
|
||||
PhysicalMute.class,
|
||||
PhysicalSoulAttack.class,
|
||||
Pumping.class,
|
||||
ProtectionBlessing.class,
|
||||
RandomizeHate.class,
|
||||
RebalanceHP.class,
|
||||
Recovery.class,
|
||||
Reeling.class,
|
||||
RefuelAirship.class,
|
||||
Relax.class,
|
||||
ResistSkill.class,
|
||||
Restoration.class,
|
||||
RestorationRandom.class,
|
||||
Resurrection.class,
|
||||
ResurrectionSpecial.class,
|
||||
Root.class,
|
||||
ServitorShare.class,
|
||||
SetSkill.class,
|
||||
ShilensBreath.class,
|
||||
SilentMove.class,
|
||||
SkillTurning.class,
|
||||
Sleep.class,
|
||||
SoulBlow.class,
|
||||
SoulEating.class,
|
||||
Sow.class,
|
||||
Spoil.class,
|
||||
StaticDamage.class,
|
||||
StealAbnormal.class,
|
||||
Stun.class,
|
||||
Summon.class,
|
||||
SummonAgathion.class,
|
||||
SummonCubic.class,
|
||||
SummonNpc.class,
|
||||
SummonPet.class,
|
||||
SummonTrap.class,
|
||||
Sweeper.class,
|
||||
TakeCastle.class,
|
||||
TakeCastleStart.class,
|
||||
TakeFort.class,
|
||||
TakeFortStart.class,
|
||||
TalismanSlot.class,
|
||||
TargetCancel.class,
|
||||
TargetMe.class,
|
||||
TargetMeProbability.class,
|
||||
Teleport.class,
|
||||
TeleportToTarget.class,
|
||||
ThrowUp.class,
|
||||
TransferDamage.class,
|
||||
TransferHate.class,
|
||||
Transformation.class,
|
||||
TrapDetect.class,
|
||||
TrapRemove.class,
|
||||
TriggerSkillByAttack.class,
|
||||
TriggerSkillByAvoid.class,
|
||||
TriggerSkillByDamage.class,
|
||||
TriggerSkillBySkill.class,
|
||||
UnsummonAgathion.class,
|
||||
VitalityPointUp.class,
|
||||
};
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for (Class<?> c : EFFECTS)
|
||||
{
|
||||
if (c == null)
|
||||
{
|
||||
continue; // Disabled handler
|
||||
}
|
||||
EffectHandler.getInstance().registerHandler((Class<? extends AbstractEffect>) c);
|
||||
}
|
||||
|
||||
// And lets try get size
|
||||
try
|
||||
{
|
||||
_log.log(Level.INFO, EffectMasterHandler.class.getSimpleName() + ": Loaded " + EffectHandler.getInstance().size() + " effect handlers.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Failed invoking size method for handler: " + EffectMasterHandler.class.getSimpleName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
648
trunk/dist/game/data_classic/scripts/handlers/MasterHandler.java
vendored
Normal file
648
trunk/dist/game/data_classic/scripts/handlers/MasterHandler.java
vendored
Normal file
@@ -0,0 +1,648 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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 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.AdminCHSiege;
|
||||
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.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.AdminPCBangPoints;
|
||||
import handlers.admincommandhandlers.AdminPForge;
|
||||
import handlers.admincommandhandlers.AdminPathNode;
|
||||
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.AdminTvTEvent;
|
||||
import handlers.admincommandhandlers.AdminUnblockIp;
|
||||
import handlers.admincommandhandlers.AdminVitality;
|
||||
import handlers.admincommandhandlers.AdminZone;
|
||||
import handlers.bypasshandlers.ArcanCityMovie;
|
||||
import handlers.bypasshandlers.Augment;
|
||||
import handlers.bypasshandlers.Buy;
|
||||
import handlers.bypasshandlers.BuyShadowItem;
|
||||
import handlers.bypasshandlers.ChatLink;
|
||||
import handlers.bypasshandlers.ClanWarehouse;
|
||||
import handlers.bypasshandlers.EventEngine;
|
||||
import handlers.bypasshandlers.Freight;
|
||||
import handlers.bypasshandlers.ItemAuctionLink;
|
||||
import handlers.bypasshandlers.Link;
|
||||
import handlers.bypasshandlers.Loto;
|
||||
import handlers.bypasshandlers.Multisell;
|
||||
import handlers.bypasshandlers.NpcViewMod;
|
||||
import handlers.bypasshandlers.Observation;
|
||||
import handlers.bypasshandlers.OlympiadManagerLink;
|
||||
import handlers.bypasshandlers.OlympiadObservation;
|
||||
import handlers.bypasshandlers.PlayerHelp;
|
||||
import handlers.bypasshandlers.PrivateWarehouse;
|
||||
import handlers.bypasshandlers.QuestLink;
|
||||
import handlers.bypasshandlers.QuestList;
|
||||
import handlers.bypasshandlers.ReceivePremium;
|
||||
import handlers.bypasshandlers.ReleaseAttribute;
|
||||
import handlers.bypasshandlers.RentPet;
|
||||
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.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.ChangeAttribute;
|
||||
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.ManaPotion;
|
||||
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.itemhandlers.TeleportBookmark;
|
||||
import handlers.punishmenthandlers.BanHandler;
|
||||
import handlers.punishmenthandlers.ChatBanHandler;
|
||||
import handlers.punishmenthandlers.JailHandler;
|
||||
import handlers.targethandlers.Area;
|
||||
import handlers.targethandlers.AreaCorpseMob;
|
||||
import handlers.targethandlers.AreaFriendly;
|
||||
import handlers.targethandlers.AreaSummon;
|
||||
import handlers.targethandlers.Aura;
|
||||
import handlers.targethandlers.AuraCorpseMob;
|
||||
import handlers.targethandlers.BehindArea;
|
||||
import handlers.targethandlers.BehindAura;
|
||||
import handlers.targethandlers.Clan;
|
||||
import handlers.targethandlers.ClanMember;
|
||||
import handlers.targethandlers.CommandChannel;
|
||||
import handlers.targethandlers.CorpseClan;
|
||||
import handlers.targethandlers.CorpseMob;
|
||||
import handlers.targethandlers.EnemySummon;
|
||||
import handlers.targethandlers.FlagPole;
|
||||
import handlers.targethandlers.FrontArea;
|
||||
import handlers.targethandlers.FrontAura;
|
||||
import handlers.targethandlers.Ground;
|
||||
import handlers.targethandlers.Holy;
|
||||
import handlers.targethandlers.One;
|
||||
import handlers.targethandlers.OneFriendly;
|
||||
import handlers.targethandlers.OwnerPet;
|
||||
import handlers.targethandlers.Party;
|
||||
import handlers.targethandlers.PartyClan;
|
||||
import handlers.targethandlers.PartyMember;
|
||||
import handlers.targethandlers.PartyNotMe;
|
||||
import handlers.targethandlers.PartyOther;
|
||||
import handlers.targethandlers.PcBody;
|
||||
import handlers.targethandlers.Pet;
|
||||
import handlers.targethandlers.Self;
|
||||
import handlers.targethandlers.Servitor;
|
||||
import handlers.targethandlers.Summon;
|
||||
import handlers.targethandlers.TargetParty;
|
||||
import handlers.targethandlers.Unlockable;
|
||||
import handlers.telnethandlers.ChatsHandler;
|
||||
import handlers.telnethandlers.DebugHandler;
|
||||
import handlers.telnethandlers.HelpHandler;
|
||||
import handlers.telnethandlers.PlayerHandler;
|
||||
import handlers.telnethandlers.ReloadHandler;
|
||||
import handlers.telnethandlers.ServerHandler;
|
||||
import handlers.telnethandlers.StatusHandler;
|
||||
import handlers.telnethandlers.ThreadHandler;
|
||||
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.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;
|
||||
import handlers.voicedcommandhandlers.Wedding;
|
||||
|
||||
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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.ActionHandler;
|
||||
import com.l2jserver.gameserver.handler.ActionShiftHandler;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.BypassHandler;
|
||||
import com.l2jserver.gameserver.handler.ChatHandler;
|
||||
import com.l2jserver.gameserver.handler.CommunityBoardHandler;
|
||||
import com.l2jserver.gameserver.handler.IHandler;
|
||||
import com.l2jserver.gameserver.handler.ItemHandler;
|
||||
import com.l2jserver.gameserver.handler.PunishmentHandler;
|
||||
import com.l2jserver.gameserver.handler.TargetHandler;
|
||||
import com.l2jserver.gameserver.handler.TelnetHandler;
|
||||
import com.l2jserver.gameserver.handler.UserCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
|
||||
|
||||
/**
|
||||
* 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(),
|
||||
TelnetHandler.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,
|
||||
AdminCHSiege.class,
|
||||
AdminClan.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,
|
||||
AdminInstance.class,
|
||||
AdminInstanceZone.class,
|
||||
AdminInvul.class,
|
||||
AdminKick.class,
|
||||
AdminKill.class,
|
||||
AdminLevel.class,
|
||||
AdminLogin.class,
|
||||
AdminManor.class,
|
||||
AdminMenu.class,
|
||||
AdminMessages.class,
|
||||
AdminMobGroup.class,
|
||||
AdminMonsterRace.class,
|
||||
AdminPathNode.class,
|
||||
AdminPCBangPoints.class,
|
||||
AdminPetition.class,
|
||||
AdminPForge.class,
|
||||
AdminPledge.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,
|
||||
AdminClanHall.class,
|
||||
AdminSkill.class,
|
||||
AdminSpawn.class,
|
||||
AdminSummon.class,
|
||||
AdminTarget.class,
|
||||
AdminTargetSay.class,
|
||||
AdminTeleport.class,
|
||||
AdminTest.class,
|
||||
AdminTvTEvent.class,
|
||||
AdminUnblockIp.class,
|
||||
AdminVitality.class,
|
||||
AdminZone.class,
|
||||
},
|
||||
{
|
||||
// Bypass Handlers
|
||||
ArcanCityMovie.class,
|
||||
Augment.class,
|
||||
Buy.class,
|
||||
BuyShadowItem.class,
|
||||
ChatLink.class,
|
||||
ClanWarehouse.class,
|
||||
EventEngine.class,
|
||||
Freight.class,
|
||||
ItemAuctionLink.class,
|
||||
Link.class,
|
||||
Loto.class,
|
||||
Multisell.class,
|
||||
NpcViewMod.class,
|
||||
Observation.class,
|
||||
OlympiadObservation.class,
|
||||
OlympiadManagerLink.class,
|
||||
QuestLink.class,
|
||||
PlayerHelp.class,
|
||||
PrivateWarehouse.class,
|
||||
QuestList.class,
|
||||
ReceivePremium.class,
|
||||
ReleaseAttribute.class,
|
||||
RentPet.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,
|
||||
},
|
||||
{
|
||||
// Item Handlers
|
||||
Appearance.class,
|
||||
BeastSoulShot.class,
|
||||
BeastSpiritShot.class,
|
||||
BlessedSpiritShot.class,
|
||||
Book.class,
|
||||
Bypass.class,
|
||||
Calculator.class,
|
||||
ChangeAttribute.class,
|
||||
CharmOfCourage.class,
|
||||
Elixir.class,
|
||||
EnchantAttribute.class,
|
||||
EnchantScrolls.class,
|
||||
EventItem.class,
|
||||
ExtractableItems.class,
|
||||
FatedSupportBox.class,
|
||||
FishShots.class,
|
||||
Harvester.class,
|
||||
ItemSkills.class,
|
||||
ItemSkillsTemplate.class,
|
||||
ManaPotion.class,
|
||||
Maps.class,
|
||||
MercTicket.class,
|
||||
NicknameColor.class,
|
||||
PetFood.class,
|
||||
Recipes.class,
|
||||
RollingDice.class,
|
||||
Seed.class,
|
||||
SoulShots.class,
|
||||
SpecialXMas.class,
|
||||
SpiritShot.class,
|
||||
SummonItems.class,
|
||||
TeleportBookmark.class,
|
||||
},
|
||||
{
|
||||
// Punishment Handlers
|
||||
BanHandler.class,
|
||||
ChatBanHandler.class,
|
||||
JailHandler.class,
|
||||
},
|
||||
{
|
||||
// User Command Handlers
|
||||
ClanPenalty.class,
|
||||
ClanWarsList.class,
|
||||
Dismount.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.L2JMOD_ALLOW_WEDDING ? Wedding.class : null),
|
||||
(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
|
||||
Area.class,
|
||||
AreaCorpseMob.class,
|
||||
AreaFriendly.class,
|
||||
AreaSummon.class,
|
||||
Aura.class,
|
||||
AuraCorpseMob.class,
|
||||
BehindArea.class,
|
||||
BehindAura.class,
|
||||
Clan.class,
|
||||
ClanMember.class,
|
||||
CommandChannel.class,
|
||||
CorpseClan.class,
|
||||
CorpseMob.class,
|
||||
EnemySummon.class,
|
||||
FlagPole.class,
|
||||
FrontArea.class,
|
||||
FrontAura.class,
|
||||
Ground.class,
|
||||
Holy.class,
|
||||
One.class,
|
||||
OneFriendly.class,
|
||||
OwnerPet.class,
|
||||
Party.class,
|
||||
PartyClan.class,
|
||||
PartyMember.class,
|
||||
PartyNotMe.class,
|
||||
PartyOther.class,
|
||||
PcBody.class,
|
||||
Pet.class,
|
||||
Self.class,
|
||||
Servitor.class,
|
||||
Summon.class,
|
||||
TargetParty.class,
|
||||
Unlockable.class,
|
||||
},
|
||||
{
|
||||
// Telnet Handlers
|
||||
ChatsHandler.class,
|
||||
DebugHandler.class,
|
||||
HelpHandler.class,
|
||||
PlayerHandler.class,
|
||||
ReloadHandler.class,
|
||||
ServerHandler.class,
|
||||
StatusHandler.class,
|
||||
ThreadHandler.class,
|
||||
},
|
||||
};
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
_log.log(Level.INFO, "Loading Handlers...");
|
||||
|
||||
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.log(Level.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
|
||||
{
|
||||
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.log(Level.INFO, loadInstance.getClass().getSimpleName() + ": Loaded " + loadInstance.size() + " Handlers");
|
||||
}
|
||||
|
||||
_log.log(Level.INFO, "Handlers Loaded...");
|
||||
}
|
||||
}
|
||||
71
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java
vendored
Normal file
71
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2ArtefactInstanceAction.java
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.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);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!((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;
|
||||
}
|
||||
}
|
||||
48
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2DecoyAction.java
vendored
Normal file
48
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2DecoyAction.java
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
102
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2DoorInstanceAction.java
vendored
Normal file
102
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2DoorInstanceAction.java
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jserver.gameserver.model.holders.DoorRequestHolder;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
L2DoorInstance door = (L2DoorInstance) target;
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400)
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (door.getClanHall() != null) && (activeChar.getClanId() == door.getClanHall().getOwnerId()))
|
||||
{
|
||||
if (!door.isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else if (!door.getClanHall().isSiegableHall() || !((SiegableHall) door.getClanHall()).isInSiege())
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder(door));
|
||||
if (!door.getOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getClan() != null) && (((L2DoorInstance) target).getFort() != null) && (activeChar.getClan() == ((L2DoorInstance) target).getFort().getOwnerClan()) && ((L2DoorInstance) target).isOpenableBySkill() && !((L2DoorInstance) target).getFort().getSiege().isInProgress())
|
||||
{
|
||||
if (!((L2Character) target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.addScript(new DoorRequestHolder((L2DoorInstance) target));
|
||||
if (!((L2DoorInstance) target).getOpen())
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
64
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2ItemInstanceAction.java
vendored
Normal file
64
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2ItemInstanceAction.java
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// this causes the validate position handler to do the pickup if the location is reached.
|
||||
// mercenary tickets can only be picked up by the castle owner.
|
||||
final int castleId = MercTicketManager.getInstance().getTicketCastleId(target.getId());
|
||||
|
||||
if ((castleId > 0) && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
|
||||
{
|
||||
if (activeChar.isInParty())
|
||||
{
|
||||
activeChar.sendMessage("You cannot pickup mercenaries while in a party.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Only the castle lord can pickup mercenaries.");
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
}
|
||||
else if (!activeChar.isFlying())
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
149
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2NpcAction.java
vendored
Normal file
149
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2NpcAction.java
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.EventType;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MoveToPawn;
|
||||
import com.l2jserver.util.Rnd;
|
||||
|
||||
public class L2NpcAction implements IActionHandler
|
||||
{
|
||||
/**
|
||||
* Manage actions when a player click on the L2Npc.<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on first click on the L2Npc (Select it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the L2Npc as target of the L2PcInstance player (if necessary)</li> <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> <li>If L2Npc is autoAttackable, send a Server->Client packet StatusUpdate to the L2PcInstance in order to
|
||||
* update L2Npc HP bar</li> <li>Send a Server->Client packet ValidateLocation to correct the L2Npc position and heading on the client</li><BR>
|
||||
* <BR>
|
||||
* <B><U> Actions on second click on the L2Npc (Attack it/Intercat with it)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> <li>If L2Npc is autoAttackable, notify the L2PcInstance AI with AI_INTENTION_ATTACK (after a height verification)</li> <li>If L2Npc is NOT autoAttackable, notify the L2PcInstance AI
|
||||
* with AI_INTENTION_INTERACT (after a distance verification) and show message</li><BR>
|
||||
* <BR>
|
||||
* <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid that client wait an other packet</B></FONT><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action, AttackRequest</li><BR>
|
||||
* <BR>
|
||||
* @param activeChar The L2PcInstance that start an action on the L2Npc
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc) target).canTarget(activeChar))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setLastFolkNPC((L2Npc) target);
|
||||
// Check if the L2PcInstance already target the L2Npc
|
||||
if (target != activeChar.getTarget())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
// Check if the activeChar is attackable (without a forced attack)
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
((L2Npc) target).getAI(); // wake up ai
|
||||
}
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if the activeChar is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !((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.isEventMob())
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (npc.hasListener(EventType.ON_NPC_QUEST_START))
|
||||
{
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
}
|
||||
if (npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
if ((Config.PLAYER_MOVEMENT_BLOCK_TIME > 0) && !activeChar.isGM())
|
||||
{
|
||||
activeChar.updateNotMoveUntil();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
129
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java
vendored
Normal file
129
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PcInstanceAction.java
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.enums.PrivateStoreType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
// See description in TvTEvent.java
|
||||
if (!TvTEvent.onAction(activeChar, target.getObjectId()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance is confused
|
||||
if (activeChar.isOutOfControl())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ENMITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
98
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PetInstanceAction.java
vendored
Normal file
98
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2PetInstanceAction.java
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
89
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java
vendored
Normal file
89
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2StaticObjectInstanceAction.java
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(final L2PcInstance activeChar, final L2Object target, final boolean interact)
|
||||
{
|
||||
final L2StaticObjectInstance staticObject = (L2StaticObjectInstance) target;
|
||||
if (staticObject.getType() < 0)
|
||||
{
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: " + staticObject.getId());
|
||||
}
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != staticObject)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(staticObject);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(staticObject, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, staticObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (staticObject.getType() == 2)
|
||||
{
|
||||
final String filename = (staticObject.getId() == 24230101) ? "html/signboards/tomb_of_crystalgolem.htm" : "html/signboards/pvp_signboard.htm";
|
||||
final String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(staticObject.getObjectId());
|
||||
|
||||
if (content == null)
|
||||
{
|
||||
html.setHtml("<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;
|
||||
}
|
||||
}
|
||||
94
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2SummonAction.java
vendored
Normal file
94
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2SummonAction.java
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.player.OnPlayerSummonTalk;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
48
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2TrapAction.java
vendored
Normal file
48
trunk/dist/game/data_classic/scripts/handlers/actionhandlers/L2TrapAction.java
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
67
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java
vendored
Normal file
67
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2DoorInstanceActionShift.java
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StaticObject;
|
||||
|
||||
public class L2DoorInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
L2DoorInstance door = (L2DoorInstance) target;
|
||||
activeChar.sendPacket(new StaticObject(door, activeChar.isGM()));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/doorinfo.htm");
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%hp%", String.valueOf((int) door.getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(door.getMaxHp()));
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%doorid%", String.valueOf(door.getId()));
|
||||
|
||||
html.replace("%minx%", String.valueOf(door.getX(0)));
|
||||
html.replace("%miny%", String.valueOf(door.getY(0)));
|
||||
html.replace("%minz%", String.valueOf(door.getZMin()));
|
||||
|
||||
html.replace("%maxx%", String.valueOf(door.getX(2)));
|
||||
html.replace("%maxy%", String.valueOf(door.getY(2)));
|
||||
html.replace("%maxz%", String.valueOf(door.getZMax()));
|
||||
html.replace("%unlock%", door.isOpenableBySkill() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
47
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java
vendored
Normal file
47
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2ItemInstanceActionShift.java
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2ItemInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(StringUtil.concat("<html><body><center><font color=\"LEVEL\">Item Info</font></center><br><table border=0>", "<tr><td>Object ID: </td><td>", String.valueOf(target.getObjectId()), "</td></tr><tr><td>Item ID: </td><td>", String.valueOf(target.getId()), "</td></tr><tr><td>Owner ID: </td><td>", String.valueOf(((L2ItemInstance) target).getOwnerId()), "</td></tr><tr><td>Location: </td><td>", String.valueOf(((L2ItemInstance) target).getLocation()), "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", target.getClass().getSimpleName(), "</td></tr></table></body></html>"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
204
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2NpcActionShift.java
vendored
Normal file
204
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2NpcActionShift.java
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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 handlers.bypasshandlers.NpcViewMod;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.L2Attackable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
public class L2NpcActionShift implements IActionShiftHandler
|
||||
{
|
||||
/**
|
||||
* Manage and Display the GM console to modify the L2NpcInstance (GM only).<BR>
|
||||
* <BR>
|
||||
* <B><U> Actions (If the L2PcInstance is a GM only)</U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Set the L2NpcInstance as target of the L2PcInstance player (if necessary)</li> <li>Send a Server->Client packet MyTargetSelected to the L2PcInstance player (display the select window)</li> <li>If L2NpcInstance is autoAttackable, send a Server->Client packet StatusUpdate to the
|
||||
* L2PcInstance in order to update L2NpcInstance HP bar</li> <li>Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance</li><BR>
|
||||
* <BR>
|
||||
* <FONT COLOR=#FF0000><B> <U>Caution</U> : Each group of Server->Client packet must be terminated by a ActionFailed packet in order to avoid that client wait an other packet</B></FONT><BR>
|
||||
* <BR>
|
||||
* <B><U> Example of use </U> :</B><BR>
|
||||
* <BR>
|
||||
* <li>Client packet : Action</li><BR>
|
||||
* <BR>
|
||||
*/
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance is a GM
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/npcinfo.htm");
|
||||
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%race%", ((L2Npc) target).getTemplate().getRace().toString());
|
||||
html.replace("%id%", String.valueOf(((L2Npc) target).getTemplate().getId()));
|
||||
html.replace("%lvl%", String.valueOf(((L2Npc) target).getTemplate().getLevel()));
|
||||
html.replace("%name%", String.valueOf(((L2Npc) target).getTemplate().getName()));
|
||||
html.replace("%tmplid%", String.valueOf(((L2Npc) target).getTemplate().getId()));
|
||||
html.replace("%aggro%", String.valueOf((target instanceof L2Attackable) ? ((L2Attackable) target).getAggroRange() : 0));
|
||||
html.replace("%hp%", String.valueOf((int) ((L2Character) target).getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(((L2Character) target).getMaxHp()));
|
||||
html.replace("%mp%", String.valueOf((int) ((L2Character) target).getCurrentMp()));
|
||||
html.replace("%mpmax%", String.valueOf(((L2Character) target).getMaxMp()));
|
||||
|
||||
html.replace("%patk%", String.valueOf(((L2Character) target).getPAtk(null)));
|
||||
html.replace("%matk%", String.valueOf(((L2Character) target).getMAtk(null, null)));
|
||||
html.replace("%pdef%", String.valueOf(((L2Character) target).getPDef(null)));
|
||||
html.replace("%mdef%", String.valueOf(((L2Character) target).getMDef(null, null)));
|
||||
html.replace("%accu%", String.valueOf(((L2Character) target).getAccuracy()));
|
||||
html.replace("%evas%", String.valueOf(((L2Character) target).getEvasionRate(null)));
|
||||
html.replace("%crit%", String.valueOf(((L2Character) target).getCriticalHit(null, null)));
|
||||
html.replace("%rspd%", String.valueOf((int) ((L2Character) target).getRunSpeed()));
|
||||
html.replace("%aspd%", String.valueOf(((L2Character) target).getPAtkSpd()));
|
||||
html.replace("%cspd%", String.valueOf(((L2Character) target).getMAtkSpd()));
|
||||
html.replace("%atkType%", String.valueOf(((L2Character) target).getTemplate().getBaseAttackType()));
|
||||
html.replace("%atkRng%", String.valueOf(((L2Character) target).getTemplate().getBaseAttackRange()));
|
||||
html.replace("%str%", String.valueOf(((L2Character) target).getSTR()));
|
||||
html.replace("%dex%", String.valueOf(((L2Character) target).getDEX()));
|
||||
html.replace("%con%", String.valueOf(((L2Character) target).getCON()));
|
||||
html.replace("%int%", String.valueOf(((L2Character) target).getINT()));
|
||||
html.replace("%wit%", String.valueOf(((L2Character) target).getWIT()));
|
||||
html.replace("%men%", String.valueOf(((L2Character) target).getMEN()));
|
||||
html.replace("%loc%", String.valueOf(target.getX() + " " + target.getY() + " " + target.getZ()));
|
||||
html.replace("%heading%", String.valueOf(((L2Character) target).getHeading()));
|
||||
html.replace("%collision_radius%", String.valueOf(((L2Character) target).getTemplate().getfCollisionRadius()));
|
||||
html.replace("%collision_height%", String.valueOf(((L2Character) target).getTemplate().getfCollisionHeight()));
|
||||
html.replace("%dist%", String.valueOf((int) activeChar.calculateDistance(target, true, false)));
|
||||
|
||||
byte attackAttribute = ((L2Character) target).getAttackElement();
|
||||
html.replace("%ele_atk%", Elementals.getElementName(attackAttribute));
|
||||
html.replace("%ele_atk_value%", String.valueOf(((L2Character) target).getAttackElementValue(attackAttribute)));
|
||||
html.replace("%ele_dfire%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.FIRE)));
|
||||
html.replace("%ele_dwater%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.WATER)));
|
||||
html.replace("%ele_dwind%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.WIND)));
|
||||
html.replace("%ele_dearth%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.EARTH)));
|
||||
html.replace("%ele_dholy%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.HOLY)));
|
||||
html.replace("%ele_ddark%", String.valueOf(((L2Character) target).getDefenseElementValue(Elementals.DARK)));
|
||||
|
||||
if (((L2Npc) target).getSpawn() != null)
|
||||
{
|
||||
html.replace("%territory%", ((L2Npc) target).getSpawn().getSpawnTerritory() == null ? "None" : ((L2Npc) target).getSpawn().getSpawnTerritory().getName());
|
||||
if (((L2Npc) target).getSpawn().isTerritoryBased())
|
||||
{
|
||||
html.replace("%spawntype%", "Random");
|
||||
final Location spawnLoc = ((L2Npc) target).getSpawn().getLocation(target);
|
||||
html.replace("%spawn%", spawnLoc.getX() + " " + spawnLoc.getY() + " " + spawnLoc.getZ());
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%spawntype%", "Fixed");
|
||||
html.replace("%spawn%", ((L2Npc) target).getSpawn().getX() + " " + ((L2Npc) target).getSpawn().getY() + " " + ((L2Npc) target).getSpawn().getZ());
|
||||
}
|
||||
html.replace("%loc2d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), false, false)));
|
||||
html.replace("%loc3d%", String.valueOf((int) target.calculateDistance(((L2Npc) target).getSpawn().getLocation(target), true, false)));
|
||||
if (((L2Npc) target).getSpawn().getRespawnMinDelay() == 0)
|
||||
{
|
||||
html.replace("%resp%", "None");
|
||||
}
|
||||
else if (((L2Npc) target).getSpawn().hasRespawnRandom())
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(((L2Npc) target).getSpawn().getRespawnMinDelay() / 1000) + "-" + String.valueOf((((L2Npc) target).getSpawn().getRespawnMaxDelay() / 1000) + " sec"));
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%resp%", String.valueOf(((L2Npc) target).getSpawn().getRespawnMinDelay() / 1000) + " sec");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%territory%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawntype%", "<font color=FF0000>--</font>");
|
||||
html.replace("%spawn%", "<font color=FF0000>null</font>");
|
||||
html.replace("%loc2d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%loc3d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%resp%", "<font color=FF0000>--</font>");
|
||||
}
|
||||
|
||||
if (((L2Npc) target).hasAI())
|
||||
{
|
||||
Set<Integer> clans = ((L2Npc) target).getTemplate().getClans();
|
||||
Set<Integer> ignoreClanNpcIds = ((L2Npc) target).getTemplate().getIgnoreClanNpcIds();
|
||||
String clansString = clans != null ? Util.implode(clans.toArray(), ", ") : "";
|
||||
String ignoreClanNpcIdsString = ignoreClanNpcIds != null ? Util.implode(ignoreClanNpcIds.toArray(), ", ") : "";
|
||||
|
||||
html.replace("%ai_intention%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Intention:</font></td><td align=right width=170>" + String.valueOf(((L2Npc) target).getAI().getIntention().name()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>AI</font></td><td align=right width=170>" + ((L2Npc) target).getAI().getClass().getSimpleName() + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_type%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>AIType</font></td><td align=right width=170>" + String.valueOf(((L2Npc) target).getAiType()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_clan%", "<tr><td><table width=270 border=0><tr><td width=100><font color=FFAA00>Clan & Range:</font></td><td align=right width=170>" + clansString + " " + String.valueOf(((L2Npc) target).getTemplate().getClanHelpRange()) + "</td></tr></table></td></tr>");
|
||||
html.replace("%ai_enemy_clan%", "<tr><td><table width=270 border=0 bgcolor=131210><tr><td width=100><font color=FFAA00>Ignore & Range:</font></td><td align=right width=170>" + ignoreClanNpcIdsString + " " + String.valueOf(((L2Npc) target).getTemplate().getAggroRange()) + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%ai_intention%", "");
|
||||
html.replace("%ai%", "");
|
||||
html.replace("%ai_type%", "");
|
||||
html.replace("%ai_clan%", "");
|
||||
html.replace("%ai_enemy_clan%", "");
|
||||
}
|
||||
|
||||
final String routeName = WalkingManager.getInstance().getRouteName((L2Npc) target);
|
||||
if (!routeName.isEmpty())
|
||||
{
|
||||
html.replace("%route%", "<tr><td><table width=270 border=0><tr><td width=100><font color=LEVEL>Route:</font></td><td align=right width=170>" + routeName + "</td></tr></table></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%route%", "");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (Config.ALT_GAME_VIEWNPC)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
activeChar.setTarget(target);
|
||||
NpcViewMod.sendNpcView(activeChar, (L2Npc) target);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
56
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2PcInstanceActionShift.java
vendored
Normal file
56
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2PcInstanceActionShift.java
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StaticObject;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2StaticObjectInstanceActionShift implements IActionShiftHandler
|
||||
{
|
||||
@Override
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new StaticObject((L2StaticObjectInstance) target));
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(StringUtil.concat("<html><body><center><font color=\"LEVEL\">Static Object Info</font></center><br><table border=0><tr><td>Coords X,Y,Z: </td><td>", String.valueOf(target.getX()), ", ", String.valueOf(target.getY()), ", ", String.valueOf(target.getZ()), "</td></tr><tr><td>Object ID: </td><td>", String.valueOf(target.getObjectId()), "</td></tr><tr><td>Static Object ID: </td><td>", String.valueOf(target.getId()), "</td></tr><tr><td>Mesh Index: </td><td>", String.valueOf(((L2StaticObjectInstance) target).getMeshIndex()), "</td></tr><tr><td><br></td></tr><tr><td>Class: </td><td>", target.getClass().getSimpleName(), "</td></tr></table></body></html>"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
55
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2SummonActionShift.java
vendored
Normal file
55
trunk/dist/game/data_classic/scripts/handlers/actionshifthandlers/L2SummonActionShift.java
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.InstanceType;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IActionShiftHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
448
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminAdmin.java
vendored
Normal file
448
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminAdmin.java
vendored
Normal file
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.enums.ChatType;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Hero;
|
||||
import com.l2jserver.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExWorldChatCnt;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - admin|admin1/admin2/admin3/admin4/admin5 = slots for the 5 starting admin menus - gmliston/gmlistoff = includes/excludes active character from /gmlist results - silence = toggles private messages acceptance mode - diet = toggles weight penalty mode -
|
||||
* tradeoff = toggles trade acceptance mode - reload = reloads specified component from multisell|skill|npc|htm|item - set/set_menu/set_mod = alters specified server setting - saveolymp = saves olympiad state manually - manualhero = cycles olympiad and calculate new heroes.
|
||||
* @version $Revision: 1.3.2.1.2.4 $ $Date: 2007/07/28 10:06:06 $
|
||||
*/
|
||||
public class AdminAdmin implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminAdmin.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_admin",
|
||||
"admin_admin1",
|
||||
"admin_admin2",
|
||||
"admin_admin3",
|
||||
"admin_admin4",
|
||||
"admin_admin5",
|
||||
"admin_admin6",
|
||||
"admin_admin7",
|
||||
"admin_gmliston",
|
||||
"admin_gmlistoff",
|
||||
"admin_silence",
|
||||
"admin_diet",
|
||||
"admin_tradeoff",
|
||||
"admin_set",
|
||||
"admin_set_mod",
|
||||
"admin_saveolymp",
|
||||
"admin_sethero",
|
||||
"admin_givehero",
|
||||
"admin_endolympiad",
|
||||
"admin_setconfig",
|
||||
"admin_config_server",
|
||||
"admin_gmon",
|
||||
"admin_worldchat",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_admin"))
|
||||
{
|
||||
showMainPage(activeChar, command);
|
||||
}
|
||||
else if (command.equals("admin_config_server"))
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_gmliston"))
|
||||
{
|
||||
AdminData.getInstance().showGm(activeChar);
|
||||
activeChar.sendMessage("Registered into gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_gmlistoff"))
|
||||
{
|
||||
AdminData.getInstance().hideGm(activeChar);
|
||||
activeChar.sendMessage("Removed from gm list");
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_silence"))
|
||||
{
|
||||
if (activeChar.isSilenceMode()) // already in message refusal mode
|
||||
{
|
||||
activeChar.setSilenceMode(false);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_ACCEPTANCE_MODE);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
activeChar.sendPacket(SystemMessageId.MESSAGE_REFUSAL_MODE);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_saveolymp"))
|
||||
{
|
||||
Olympiad.getInstance().saveOlympiadStatus();
|
||||
activeChar.sendMessage("olympiad system saved.");
|
||||
}
|
||||
else if (command.startsWith("admin_endolympiad"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Olympiad.getInstance().manualSelectHeroes();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.warning("An error occured while ending olympiad: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Heroes formed.");
|
||||
}
|
||||
else if (command.startsWith("admin_sethero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
target.setHero(!target.isHero());
|
||||
target.broadcastUserInfo();
|
||||
}
|
||||
else if (command.startsWith("admin_givehero"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance target = activeChar.getTarget().isPlayer() ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
if (Hero.getInstance().isHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player has already claimed the hero status.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Hero.getInstance().isUnclaimedHero(target.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("This player cannot claim the hero status.");
|
||||
return false;
|
||||
}
|
||||
Hero.getInstance().claimHero(target);
|
||||
}
|
||||
else if (command.startsWith("admin_diet"))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
if (st.nextToken().equalsIgnoreCase("on"))
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
else if (st.nextToken().equalsIgnoreCase("off"))
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (activeChar.getDietMode())
|
||||
{
|
||||
activeChar.setDietMode(false);
|
||||
activeChar.sendMessage("Diet mode off");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setDietMode(true);
|
||||
activeChar.sendMessage("Diet mode on");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
activeChar.refreshOverloaded();
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_tradeoff"))
|
||||
{
|
||||
try
|
||||
{
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
try
|
||||
{
|
||||
String pName = st.nextToken();
|
||||
String pValue = st.nextToken();
|
||||
if (Config.setParameterValue(pName, pValue))
|
||||
{
|
||||
activeChar.sendMessage("Config parameter " + pName + " set to " + pValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameter!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setconfig <parameter> <value>");
|
||||
}
|
||||
finally
|
||||
{
|
||||
showConfigPage(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_set"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
String[] cmd = st.nextToken().split("_");
|
||||
try
|
||||
{
|
||||
String[] parameter = st.nextToken().split("=");
|
||||
String pName = parameter[0].trim();
|
||||
String pValue = parameter[1].trim();
|
||||
if (Config.setParameterValue(pName, pValue))
|
||||
{
|
||||
activeChar.sendMessage("parameter " + pName + " succesfully set to " + pValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameter!");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (cmd.length == 2)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //set parameter=value");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (cmd.length == 3)
|
||||
{
|
||||
if (cmd[2].equalsIgnoreCase("mod"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "mods_menu.htm");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_gmon"))
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
else if (command.startsWith("admin_worldchat"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // admin_worldchat
|
||||
final String subCmd = st.hasMoreTokens() ? st.nextToken() : "";
|
||||
switch (subCmd)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
public void showConfigPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
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);
|
||||
}
|
||||
}
|
||||
513
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminAnnouncements.java
vendored
Normal file
513
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminAnnouncements.java
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.AnnouncementsTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.PageResult;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.announce.Announcement;
|
||||
import com.l2jserver.gameserver.model.announce.AnnouncementType;
|
||||
import com.l2jserver.gameserver.model.announce.AutoAnnouncement;
|
||||
import com.l2jserver.gameserver.model.announce.IAnnouncement;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.gameserver.util.HtmlUtil;
|
||||
import com.l2jserver.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())
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "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;
|
||||
}
|
||||
String annInitDelay = st.nextToken();
|
||||
if (!Util.isDigit(annInitDelay))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
int initDelay = Integer.parseInt(annInitDelay) * 1000;
|
||||
// ************************************
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
String annDelay = st.nextToken();
|
||||
if (!Util.isDigit(annDelay))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
String annId = st.nextToken();
|
||||
if (!Util.isDigit(annId))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces edit <id>");
|
||||
break;
|
||||
}
|
||||
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(), "html/admin/announces-edit.htm");
|
||||
String announcementId = "" + announce.getId();
|
||||
String announcementType = announce.getType().name();
|
||||
String announcementInital = "0";
|
||||
String announcementDelay = "0";
|
||||
String announcementRepeat = "0";
|
||||
String announcementAuthor = announce.getAuthor();
|
||||
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;
|
||||
}
|
||||
String annInitDelay = st.nextToken();
|
||||
if (!Util.isDigit(annInitDelay))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
int initDelay = Integer.parseInt(annInitDelay);
|
||||
// ************************************
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
String annDelay = st.nextToken();
|
||||
if (!Util.isDigit(annDelay))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces add <type> <delay> <repeat> <text>");
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces remove <announcement id>");
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces show <announcement id>");
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
activeChar.sendMessage("Syntax: //announces show <announcement id>");
|
||||
break;
|
||||
}
|
||||
int id = Integer.parseInt(token);
|
||||
final IAnnouncement announce = AnnouncementsTable.getInstance().getAnnounce(id);
|
||||
if (announce != null)
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/announces-show.htm");
|
||||
String announcementId = "" + announce.getId();
|
||||
String announcementType = announce.getType().name();
|
||||
String announcementInital = "0";
|
||||
String announcementDelay = "0";
|
||||
String announcementRepeat = "0";
|
||||
String announcementAuthor = announce.getAuthor();
|
||||
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(), "html/admin/announces-list.htm");
|
||||
final PageResult result = HtmlUtil.createPage(AnnouncementsTable.getInstance().getAllAnnouncements(), page, 8, currentPage ->
|
||||
{
|
||||
return "<td align=center><button action=\"bypass admin_announces list " + currentPage + "\" value=\"" + (currentPage + 1) + "\" width=35 height=20 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></td>";
|
||||
}, announcement ->
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
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>");
|
||||
return sb.toString();
|
||||
});
|
||||
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;
|
||||
}
|
||||
}
|
||||
42
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminBBS.java
vendored
Normal file
42
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminBBS.java
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
387
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminBuffs.java
vendored
Normal file
387
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminBuffs.java
vendored
Normal file
@@ -0,0 +1,387 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.effects.AbstractEffect;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalType;
|
||||
import com.l2jserver.gameserver.model.skills.BuffInfo;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SkillCoolTime;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class AdminBuffs implements IAdminCommandHandler
|
||||
{
|
||||
private final static int PAGE_LIMIT = 20;
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_getbuffs",
|
||||
"admin_getbuffs_ps",
|
||||
"admin_stopbuff",
|
||||
"admin_stopallbuffs",
|
||||
"admin_areacancel",
|
||||
"admin_removereuse",
|
||||
"admin_switch_gm_buffs"
|
||||
};
|
||||
// Misc
|
||||
private static final String FONT_RED1 = "<font color=\"FF0000\">";
|
||||
private static final String FONT_RED2 = "</font>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_getbuffs"))
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String playername = st.nextToken();
|
||||
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
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
int objectId = Integer.parseInt(st.nextToken());
|
||||
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
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken();
|
||||
String val = st.nextToken();
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(val);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (knownChar.isPlayer() && !knownChar.equals(activeChar))
|
||||
{
|
||||
knownChar.stopAllEffects();
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("All effects canceled within radius " + radius);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //areacancel <radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_removereuse"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
L2PcInstance player = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
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 = StringUtil.startAppend(500 + (effects.size() * 200), "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center><font color=\"LEVEL\">Effects of ", target.getName(), "</font></td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br><table width=\"100%\"><tr><td width=200>Skill</td><td width=30>Rem. Time</td><td width=70>Action</td></tr>");
|
||||
int start = ((page - 1) * PAGE_LIMIT);
|
||||
int end = Math.min(((page - 1) * PAGE_LIMIT) + PAGE_LIMIT, effects.size());
|
||||
int count = 0;
|
||||
for (BuffInfo info : effects)
|
||||
{
|
||||
if ((count >= start) && (count < end))
|
||||
{
|
||||
final Skill skill = info.getSkill();
|
||||
for (AbstractEffect effect : info.getEffects())
|
||||
{
|
||||
StringUtil.append(html, "<tr><td>", (!info.isInUse() ? FONT_RED1 : "") + skill.getName(), " Lv ", String.valueOf(skill.getLevel()), " (", effect.getClass().getSimpleName(), ")" + (!info.isInUse() ? FONT_RED2 : ""), "</td><td>", skill.isToggle() ? "T (" + info.getTickCount(effect) + ")" : skill.isPassive() ? "P" : info.getTime() + "s", "</td><td><button value=\"X\" action=\"bypass -h admin_stopbuff ", Integer.toString(target.getObjectId()), " ", String.valueOf(skill.getId()), "\" width=30 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
html.append("</table><table width=300 bgcolor=444444><tr>");
|
||||
for (int x = 0; x < max; x++)
|
||||
{
|
||||
int pagenr = x + 1;
|
||||
if (page == pagenr)
|
||||
{
|
||||
html.append("<td>Page ");
|
||||
html.append(pagenr);
|
||||
html.append("</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.append("<td><a action=\"bypass -h admin_getbuffs" + (passive ? "_ps " : " "));
|
||||
html.append(target.getName());
|
||||
html.append(" ");
|
||||
html.append(x + 1);
|
||||
html.append("\"> Page ");
|
||||
html.append(pagenr);
|
||||
html.append(" </a></td>");
|
||||
}
|
||||
}
|
||||
|
||||
html.append("</tr></table>");
|
||||
|
||||
// Buttons
|
||||
StringUtil.append(html, "<br><center><button value=\"Refresh\" action=\"bypass -h admin_getbuffs", (passive ? "_ps " : " "), target.getName(), "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
StringUtil.append(html, "<button value=\"Remove All\" action=\"bypass -h admin_stopallbuffs ", Integer.toString(target.getObjectId()), "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br>");
|
||||
// Legend
|
||||
if (!passive)
|
||||
{
|
||||
StringUtil.append(html, FONT_RED1, "Inactive buffs: ", String.valueOf(target.getEffectList().getHiddenBuffsCount()), FONT_RED2, "<br>");
|
||||
}
|
||||
StringUtil.append(html, "Total", passive ? " passive" : "", " buff count: ", String.valueOf(effects.size()));
|
||||
if ((target.getEffectList().getAllBlockedBuffSlots() != null) && !target.getEffectList().getAllBlockedBuffSlots().isEmpty())
|
||||
{
|
||||
StringUtil.append(html, "<br>Blocked buff slots: ");
|
||||
String slots = "";
|
||||
for (AbnormalType slot : target.getEffectList().getAllBlockedBuffSlots())
|
||||
{
|
||||
slots += slot.toString() + ", ";
|
||||
}
|
||||
|
||||
if (!slots.isEmpty() && (slots.length() > 3))
|
||||
{
|
||||
StringUtil.append(html, slots.substring(0, slots.length() - 2));
|
||||
}
|
||||
}
|
||||
StringUtil.append(html, "</html>");
|
||||
// Send the packet
|
||||
activeChar.sendPacket(new NpcHtmlMessage(html.toString()));
|
||||
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "getbuffs", target.getName() + " (" + Integer.toString(target.getObjectId()) + ")", "");
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeBuff(L2PcInstance activeChar, int objId, int skillId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if ((target != null) && (skillId > 0))
|
||||
{
|
||||
if (target.isAffectedBySkill(skillId))
|
||||
{
|
||||
target.stopSkillEffects(true, skillId);
|
||||
activeChar.sendMessage("Removed skill ID: " + skillId + " effects from " + target.getName() + " (" + objId + ").");
|
||||
}
|
||||
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopbuff", target.getName() + " (" + objId + ")", Integer.toString(skillId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeAllBuffs(L2PcInstance activeChar, int objId)
|
||||
{
|
||||
L2Character target = null;
|
||||
try
|
||||
{
|
||||
target = (L2Character) L2World.getInstance().findObject(objId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
{
|
||||
target.stopAllEffects();
|
||||
activeChar.sendMessage("Removed all effects from " + target.getName() + " (" + objId + ")");
|
||||
showBuffs(activeChar, target, 1, false);
|
||||
if (Config.GMAUDIT)
|
||||
{
|
||||
GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", "stopallbuffs", target.getName() + " (" + objId + ")", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
381
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCHSiege.java
vendored
Normal file
381
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCHSiege.java
vendored
Normal file
@@ -0,0 +1,381 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.ClanHallSiegeEngine;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SiegeInfo;
|
||||
|
||||
/**
|
||||
* @author BiggBoss
|
||||
*/
|
||||
public final class AdminCHSiege implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"admin_chsiege_siegablehall",
|
||||
"admin_chsiege_startSiege",
|
||||
"admin_chsiege_endsSiege",
|
||||
"admin_chsiege_setSiegeDate",
|
||||
"admin_chsiege_addAttacker",
|
||||
"admin_chsiege_removeAttacker",
|
||||
"admin_chsiege_clearAttackers",
|
||||
"admin_chsiege_listAttackers",
|
||||
"admin_chsiege_forwardSiege"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final String[] split = command.split(" ");
|
||||
SiegableHall hall = null;
|
||||
if (Config.ALT_DEV_NO_QUESTS)
|
||||
{
|
||||
activeChar.sendMessage("AltDevNoQuests = true; Clan Hall Sieges are disabled!");
|
||||
return false;
|
||||
}
|
||||
if (split.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("You have to specify the hall id at least");
|
||||
return false;
|
||||
}
|
||||
if ((hall = getHall(split[1], activeChar)) == null)
|
||||
{
|
||||
activeChar.sendMessage("Couldnt find he desired siegable hall (" + split[1] + ")");
|
||||
return false;
|
||||
}
|
||||
if (hall.getSiege() == null)
|
||||
{
|
||||
activeChar.sendMessage("The given hall dont have any attached siege!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (split[0].equals(COMMANDS[1]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested clan hall is alredy in siege!");
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
hall.free();
|
||||
owner.setHideoutId(0);
|
||||
hall.addAttacker(owner);
|
||||
}
|
||||
hall.getSiege().startSiege();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[2]))
|
||||
{
|
||||
if (!hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested clan hall isnt in siege!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.getSiege().endSiege();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[3]))
|
||||
{
|
||||
if (!hall.isRegistering())
|
||||
{
|
||||
activeChar.sendMessage("Cannot change siege date while hall is in siege");
|
||||
}
|
||||
else if (split.length < 3)
|
||||
{
|
||||
activeChar.sendMessage("The date format is incorrect. Try again.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] rawDate = split[2].split(";");
|
||||
if (rawDate.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("You have to specify this format DD-MM-YYYY;HH:MM");
|
||||
}
|
||||
else
|
||||
{
|
||||
String[] day = rawDate[0].split("-");
|
||||
String[] hour = rawDate[1].split(":");
|
||||
if ((day.length < 3) || (hour.length < 2))
|
||||
{
|
||||
activeChar.sendMessage("Incomplete day, hour or both!");
|
||||
}
|
||||
else
|
||||
{
|
||||
int d = parseInt(day[0]);
|
||||
int month = parseInt(day[1]) - 1;
|
||||
int year = parseInt(day[2]);
|
||||
int h = parseInt(hour[0]);
|
||||
int min = parseInt(hour[1]);
|
||||
if (((month == 2) && (d > 28)) || (d > 31) || (d <= 0) || (month <= 0) || (month > 12) || (year < Calendar.getInstance().get(Calendar.YEAR)))
|
||||
{
|
||||
activeChar.sendMessage("Wrong day/month/year gave!");
|
||||
}
|
||||
else if ((h <= 0) || (h > 24) || (min < 0) || (min >= 60))
|
||||
{
|
||||
activeChar.sendMessage("Wrong hour/minutes gave!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.YEAR, year);
|
||||
c.set(Calendar.MONTH, month);
|
||||
c.set(Calendar.DAY_OF_MONTH, d);
|
||||
c.set(Calendar.HOUR_OF_DAY, h);
|
||||
c.set(Calendar.MINUTE, min);
|
||||
c.set(Calendar.SECOND, 0);
|
||||
|
||||
if (c.getTimeInMillis() > System.currentTimeMillis())
|
||||
{
|
||||
activeChar.sendMessage(hall.getName() + " siege: " + c.getTime().toString());
|
||||
hall.setNextSiegeDate(c.getTimeInMillis());
|
||||
hall.getSiege().updateSiege();
|
||||
hall.updateDb();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The given time is in the past!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[4]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The clan hall is in siege, cannot add attackers now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
L2Clan attacker = null;
|
||||
if (split.length < 3)
|
||||
{
|
||||
L2Object rawTarget = activeChar.getTarget();
|
||||
L2PcInstance target = null;
|
||||
if (rawTarget == null)
|
||||
{
|
||||
activeChar.sendMessage("You must target a clan member of the attacker!");
|
||||
}
|
||||
else if (!(rawTarget instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You must target a player with clan!");
|
||||
}
|
||||
else if ((target = (L2PcInstance) rawTarget).getClan() == null)
|
||||
{
|
||||
activeChar.sendMessage("Your target does not have any clan!");
|
||||
}
|
||||
else if (hall.getSiege().checkIsAttacker(target.getClan()))
|
||||
{
|
||||
activeChar.sendMessage("Your target's clan is alredy participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker = target.getClan();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Clan rawClan = ClanTable.getInstance().getClanByName(split[2]);
|
||||
if (rawClan == null)
|
||||
{
|
||||
activeChar.sendMessage("The given clan does not exist!");
|
||||
}
|
||||
else if (hall.getSiege().checkIsAttacker(rawClan))
|
||||
{
|
||||
activeChar.sendMessage("The given clan is alredy participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
attacker = rawClan;
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null)
|
||||
{
|
||||
hall.addAttacker(attacker);
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[5]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The clan hall is in siege, cannot remove attackers now.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (split.length < 3)
|
||||
{
|
||||
L2Object rawTarget = activeChar.getTarget();
|
||||
L2PcInstance target = null;
|
||||
if (rawTarget == null)
|
||||
{
|
||||
activeChar.sendMessage("You must target a clan member of the attacker!");
|
||||
}
|
||||
else if (!(rawTarget instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You must target a player with clan!");
|
||||
}
|
||||
else if ((target = (L2PcInstance) rawTarget).getClan() == null)
|
||||
{
|
||||
activeChar.sendMessage("Your target does not have any clan!");
|
||||
}
|
||||
else if (!hall.getSiege().checkIsAttacker(target.getClan()))
|
||||
{
|
||||
activeChar.sendMessage("Your target's clan is not participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.removeAttacker(target.getClan());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Clan rawClan = ClanTable.getInstance().getClanByName(split[2]);
|
||||
if (rawClan == null)
|
||||
{
|
||||
activeChar.sendMessage("The given clan does not exist!");
|
||||
}
|
||||
else if (!hall.getSiege().checkIsAttacker(rawClan))
|
||||
{
|
||||
activeChar.sendMessage("The given clan is not participating!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.removeAttacker(rawClan);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[6]))
|
||||
{
|
||||
if (hall.isInSiege())
|
||||
{
|
||||
activeChar.sendMessage("The requested hall is in siege right now, cannot clear attacker list!");
|
||||
}
|
||||
else
|
||||
{
|
||||
hall.getSiege().getAttackers().clear();
|
||||
}
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[7]))
|
||||
{
|
||||
activeChar.sendPacket(new SiegeInfo(hall));
|
||||
}
|
||||
else if (split[0].equals(COMMANDS[8]))
|
||||
{
|
||||
ClanHallSiegeEngine siegable = hall.getSiege();
|
||||
siegable.cancelSiegeTask();
|
||||
switch (hall.getSiegeStatus())
|
||||
{
|
||||
case REGISTERING:
|
||||
siegable.prepareOwner();
|
||||
break;
|
||||
case WAITING_BATTLE:
|
||||
siegable.startSiege();
|
||||
break;
|
||||
case RUNNING:
|
||||
siegable.endSiege();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sendSiegableHallPage(activeChar, split[1], hall);
|
||||
return false;
|
||||
}
|
||||
|
||||
private SiegableHall getHall(String id, L2PcInstance gm)
|
||||
{
|
||||
int ch = parseInt(id);
|
||||
if (ch == 0)
|
||||
{
|
||||
gm.sendMessage("Wrong clan hall id, unparseable id!");
|
||||
return null;
|
||||
}
|
||||
|
||||
SiegableHall hall = CHSiegeManager.getInstance().getSiegableHall(ch);
|
||||
|
||||
if (hall == null)
|
||||
{
|
||||
gm.sendMessage("Couldnt find the clan hall.");
|
||||
}
|
||||
|
||||
return hall;
|
||||
}
|
||||
|
||||
private int parseInt(String st)
|
||||
{
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(st);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
private void sendSiegableHallPage(L2PcInstance activeChar, String hallId, SiegableHall hall)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(null, "html/admin/siegablehall.htm");
|
||||
msg.replace("%clanhallId%", hallId);
|
||||
msg.replace("%clanhallName%", hall.getName());
|
||||
if (hall.getOwnerId() > 0)
|
||||
{
|
||||
L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
if (owner != null)
|
||||
{
|
||||
msg.replace("%clanhallOwner%", owner.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
92
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCamera.java
vendored
Normal file
92
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCamera.java
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.AbstractScript;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
263
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCastle.java
vendored
Normal file
263
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCastle.java
vendored
Normal file
@@ -0,0 +1,263 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.enums.CastleSide;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Castle manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminCastle implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_castlemanage",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_castlemanage"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String param = st.nextToken();
|
||||
final Castle castle;
|
||||
if (Util.isDigit(param))
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastleById(Integer.parseInt(param));
|
||||
}
|
||||
else
|
||||
{
|
||||
castle = CastleManager.getInstance().getCastle(param);
|
||||
}
|
||||
|
||||
if (castle == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters! Usage: //castlemanage <castleId[1-9] / castleName>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
final L2PcInstance target = checkTarget(activeChar) ? activeChar.getActingPlayer() : null;
|
||||
switch (action)
|
||||
{
|
||||
case "showRegWindow":
|
||||
{
|
||||
castle.getSiege().listRegisterClan(activeChar);
|
||||
break;
|
||||
}
|
||||
case "addAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerAttacker(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeAttacker":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "addDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().registerDefender(target, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "removeDeffender":
|
||||
{
|
||||
if (checkTarget(activeChar))
|
||||
{
|
||||
castle.getSiege().removeSiegeClan(target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "startSiege":
|
||||
{
|
||||
if (!castle.getSiege().getAttackerClans().isEmpty())
|
||||
{
|
||||
castle.getSiege().startSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("There is currently not registered any clan for castle siege!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "stopSiege":
|
||||
{
|
||||
if (castle.getSiege().isInProgress())
|
||||
{
|
||||
castle.getSiege().endSiege();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Castle siege is not currently in progress!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "setOwner":
|
||||
{
|
||||
if ((target == null) || !checkTarget(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else if (target.getClan().getCastleId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("This clan already have castle!");
|
||||
}
|
||||
else if (castle.getOwner() != null)
|
||||
{
|
||||
activeChar.sendMessage("This castle is already taken by another clan!");
|
||||
}
|
||||
else if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Invalid parameters!!");
|
||||
}
|
||||
else
|
||||
{
|
||||
final CastleSide side = Enum.valueOf(CastleSide.class, st.nextToken().toUpperCase());
|
||||
if (side != null)
|
||||
{
|
||||
castle.setSide(side);
|
||||
castle.setOwner(target.getClan());
|
||||
}
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "takeCastle":
|
||||
{
|
||||
final L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
|
||||
if (clan != null)
|
||||
{
|
||||
castle.removeOwner(clan);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error during removing castle!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
case "switchSide":
|
||||
{
|
||||
if (castle.getSide() == CastleSide.DARK)
|
||||
{
|
||||
castle.setSide(CastleSide.LIGHT);
|
||||
}
|
||||
else if (castle.getSide() == CastleSide.LIGHT)
|
||||
{
|
||||
castle.setSide(CastleSide.DARK);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You can't switch sides when is castle neutral!");
|
||||
}
|
||||
showCastleMenu(activeChar, castle.getResidenceId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/castlemanage.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showCastleMenu(L2PcInstance player, int castleId)
|
||||
{
|
||||
final Castle castle = CastleManager.getInstance().getCastleById(castleId);
|
||||
|
||||
if (castle != null)
|
||||
{
|
||||
final L2Clan ownerClan = castle.getOwner();
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "html/admin/castlemanage_selected.htm"));
|
||||
html.replace("%castleId%", castle.getResidenceId());
|
||||
html.replace("%castleName%", castle.getName());
|
||||
html.replace("%ownerName%", ownerClan != null ? ownerClan.getLeaderName() : "NPC");
|
||||
html.replace("%ownerClan%", ownerClan != null ? ownerClan.getName() : "NPC");
|
||||
html.replace("%castleSide%", Util.capitalizeFirst(castle.getSide().toString().toLowerCase()));
|
||||
player.sendPacket(html);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkTarget(L2PcInstance player)
|
||||
{
|
||||
return ((player.getTarget() != null) && player.getTarget().isPlayer() && (((L2PcInstance) player.getTarget()).getClan() != null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
142
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminChangeAccessLevel.java
vendored
Normal file
142
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminChangeAccessLevel.java
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2AccessLevel;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
String name = parts[1];
|
||||
int lvl = Integer.parseInt(parts[2]);
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
onlineChange(activeChar, player, lvl);
|
||||
}
|
||||
else
|
||||
{
|
||||
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
|
||||
statement.setInt(1, lvl);
|
||||
statement.setString(2, name);
|
||||
statement.execute();
|
||||
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)
|
||||
{
|
||||
if (AdminData.getInstance().hasAccessLevel(lvl))
|
||||
{
|
||||
final L2AccessLevel acccessLevel = AdminData.getInstance().getAccessLevel(lvl);
|
||||
player.setAccessLevel(lvl, true);
|
||||
player.sendMessage("Your access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
activeChar.sendMessage(player.getName() + "'s access level has been changed to " + acccessLevel.getName() + " (" + acccessLevel.getLevel() + ").");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You are trying to set unexisting access level: " + lvl + " please try again with a valid one!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAccessLevel(lvl, false);
|
||||
player.sendMessage("Your character has been banned. Bye.");
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
}
|
||||
223
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminClan.java
vendored
Normal file
223
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminClan.java
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jserver.gameserver.instancemanager.FortManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2ClanMember;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid, Zoey76
|
||||
*/
|
||||
public class AdminClan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clan_info",
|
||||
"admin_clan_changeleader",
|
||||
"admin_clan_show_pending",
|
||||
"admin_clan_force_pending"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command);
|
||||
final String cmd = st.nextToken();
|
||||
switch (cmd)
|
||||
{
|
||||
case "admin_clan_info":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/claninfo.htm"));
|
||||
html.replace("%clan_name%", clan.getName());
|
||||
html.replace("%clan_leader%", clan.getLeaderName());
|
||||
html.replace("%clan_level%", String.valueOf(clan.getLevel()));
|
||||
html.replace("%clan_has_castle%", clan.getCastleId() > 0 ? CastleManager.getInstance().getCastleById(clan.getCastleId()).getName() : "No");
|
||||
html.replace("%clan_has_clanhall%", clan.getHideoutId() > 0 ? ClanHallManager.getInstance().getClanHallById(clan.getHideoutId()).getName() : "No");
|
||||
html.replace("%clan_has_fortress%", clan.getFortId() > 0 ? FortManager.getInstance().getFortById(clan.getFortId()).getName() : "No");
|
||||
html.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
|
||||
html.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
|
||||
html.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
|
||||
html.replace("%current_player_objectId%", String.valueOf(player.getObjectId()));
|
||||
html.replace("%current_player_name%", player.getName());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
}
|
||||
case "admin_clan_changeleader":
|
||||
{
|
||||
final L2PcInstance player = getPlayer(activeChar, st);
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
final L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THE_TARGET_MUST_BE_A_CLAN_MEMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2ClanMember member = clan.getClanMember(player.getObjectId());
|
||||
if (member != null)
|
||||
{
|
||||
if (player.isAcademyMember())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.THAT_PRIVILEGE_CANNOT_BE_GRANTED_TO_A_CLAN_ACADEMY_MEMBER);
|
||||
}
|
||||
else
|
||||
{
|
||||
clan.setNewLeader(member);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_clan_show_pending":
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/clanchanges.htm"));
|
||||
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())
|
||||
{
|
||||
String token = st.nextToken();
|
||||
if (!Util.isDigit(token))
|
||||
{
|
||||
break;
|
||||
}
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
278
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminClanHall.java
vendored
Normal file
278
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminClanHall.java
vendored
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ClanHallAuctionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.ClanHall;
|
||||
import com.l2jserver.gameserver.model.entity.clanhall.SiegableHall;
|
||||
import com.l2jserver.gameserver.model.zone.type.L2ClanHallZone;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles Clan Hall commands.
|
||||
* @author Zoey76 (rework)
|
||||
*/
|
||||
public class AdminClanHall implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clanhall",
|
||||
"admin_clanhallset",
|
||||
"admin_clanhalldel",
|
||||
"admin_clanhallopendoors",
|
||||
"admin_clanhallclosedoors",
|
||||
"admin_clanhallteleportself"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken(); // Get actual command
|
||||
|
||||
ClanHall clanhall = null;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
|
||||
{
|
||||
player = activeChar.getTarget().getActingPlayer();
|
||||
}
|
||||
|
||||
String val = st.nextToken();
|
||||
if (command.startsWith("admin_clanhall"))
|
||||
{
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(val));
|
||||
L2Clan clan = null;
|
||||
switch (command)
|
||||
{
|
||||
case "admin_clanhallset":
|
||||
if ((player == null) || (player.getClan() == null))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (clanhall.getOwnerId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("This Clan Hall is not free!");
|
||||
return false;
|
||||
}
|
||||
|
||||
clan = player.getClan();
|
||||
if (clan.getHideoutId() > 0)
|
||||
{
|
||||
activeChar.sendMessage("You have already a Clan Hall!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
ClanHallManager.getInstance().setOwner(clanhall.getId(), clan);
|
||||
if (ClanHallAuctionManager.getInstance().getAuction(clanhall.getId()) != null)
|
||||
{
|
||||
ClanHallAuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clanhall.setOwner(clan);
|
||||
clan.setHideoutId(clanhall.getId());
|
||||
}
|
||||
break;
|
||||
case "admin_clanhalldel":
|
||||
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
|
||||
{
|
||||
ClanHallManager.getInstance().setFree(clanhall.getId());
|
||||
ClanHallAuctionManager.getInstance().initNPC(clanhall.getId());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("This Clan Hall is already free!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int oldOwner = clanhall.getOwnerId();
|
||||
if (oldOwner > 0)
|
||||
{
|
||||
clanhall.free();
|
||||
clan = ClanTable.getInstance().getClan(oldOwner);
|
||||
if (clan != null)
|
||||
{
|
||||
clan.setHideoutId(0);
|
||||
clan.broadcastClanStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "admin_clanhallopendoors":
|
||||
clanhall.openCloseDoors(true);
|
||||
break;
|
||||
case "admin_clanhallclosedoors":
|
||||
clanhall.openCloseDoors(false);
|
||||
break;
|
||||
case "admin_clanhallteleportself":
|
||||
final L2ClanHallZone zone = clanhall.getZone();
|
||||
if (zone != null)
|
||||
{
|
||||
activeChar.teleToLocation(zone.getSpawnLoc(), true);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (!clanhall.isSiegableHall())
|
||||
{
|
||||
showClanHallPage(activeChar, clanhall);
|
||||
}
|
||||
else
|
||||
{
|
||||
showSiegableHallPage(activeChar, (SiegableHall) clanhall);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showClanHallSelectPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show clan hall select page.
|
||||
* @param activeChar the active char
|
||||
*/
|
||||
private void showClanHallSelectPage(L2PcInstance activeChar)
|
||||
{
|
||||
int i = 0;
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/clanhalls.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (SiegableHall hall : CHSiegeManager.getInstance().getConquerableHalls().values())
|
||||
{
|
||||
if (hall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_chsiege_siegablehall ", String.valueOf(hall.getId()), "\">", hall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%siegableHalls%", cList.toString());
|
||||
cList.setLength(0);
|
||||
i = 0;
|
||||
for (ClanHall clanhall : ClanHallManager.getInstance().getClanHalls().values())
|
||||
{
|
||||
if (clanhall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%clanhalls%", cList.toString());
|
||||
cList.setLength(0);
|
||||
i = 0;
|
||||
for (ClanHall clanhall : ClanHallManager.getInstance().getFreeClanHalls().values())
|
||||
{
|
||||
if (clanhall != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=134><a action=\"bypass -h admin_clanhall ", String.valueOf(clanhall.getId()), "\">", clanhall.getName(), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 1)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%freeclanhalls%", cList.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the clan hall page.
|
||||
* @param activeChar the active char
|
||||
* @param clanhall the clan hall
|
||||
*/
|
||||
private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/clanhall.htm");
|
||||
adminReply.replace("%clanhallName%", clanhall.getName());
|
||||
adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
|
||||
adminReply.replace("%clanhallOwner%", (owner == null) ? "None" : owner.getName());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the siegable hall page.
|
||||
* @param activeChar the active char
|
||||
* @param hall the siegable hall
|
||||
*/
|
||||
private void showSiegableHallPage(L2PcInstance activeChar, SiegableHall hall)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(null, "html/admin/siegablehall.htm");
|
||||
msg.replace("%clanhallId%", String.valueOf(hall.getId()));
|
||||
msg.replace("%clanhallName%", hall.getName());
|
||||
if (hall.getOwnerId() > 0)
|
||||
{
|
||||
final L2Clan owner = ClanTable.getInstance().getClan(hall.getOwnerId());
|
||||
msg.replace("%clanhallOwner%", (owner != null) ? owner.getName() : "No Owner");
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.replace("%clanhallOwner%", "No Owner");
|
||||
}
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
276
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCreateItem.java
vendored
Normal file
276
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCreateItem.java
vendored
Normal file
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.items.L2Item;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExAdenaInvenCount;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - itemcreate = show menu - create_item <id> [num] = creates num items with respective id, if num is not specified, assumes 1.
|
||||
* @version $Revision: 1.2.2.2.2.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminCreateItem implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_itemcreate",
|
||||
"admin_create_item",
|
||||
"admin_create_coin",
|
||||
"admin_give_item_target",
|
||||
"admin_give_item_to_all"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_itemcreate"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "itemcreation.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_create_item"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(17);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
int idval = Integer.parseInt(id);
|
||||
String num = st.nextToken();
|
||||
long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
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
|
||||
{
|
||||
String val = command.substring(17);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String name = st.nextToken();
|
||||
int idval = getCoinId(name);
|
||||
if (idval > 0)
|
||||
{
|
||||
String num = st.nextToken();
|
||||
long numval = Long.parseLong(num);
|
||||
createItem(activeChar, activeChar, idval, numval);
|
||||
}
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
String name = st.nextToken();
|
||||
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;
|
||||
}
|
||||
|
||||
String val = command.substring(22);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
int idval = Integer.parseInt(id);
|
||||
String num = st.nextToken();
|
||||
long numval = Long.parseLong(num);
|
||||
createItem(activeChar, target, idval, numval);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
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"))
|
||||
{
|
||||
String val = command.substring(22);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
int idval = 0;
|
||||
long numval = 0;
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
String num = st.nextToken();
|
||||
numval = Long.parseLong(num);
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
String id = st.nextToken();
|
||||
idval = Integer.parseInt(id);
|
||||
numval = 1;
|
||||
}
|
||||
int counter = 0;
|
||||
L2Item template = ItemTable.getInstance().getTemplate(idval);
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("This item doesn't exist.");
|
||||
return false;
|
||||
}
|
||||
if ((numval > 10) && !template.isStackable())
|
||||
{
|
||||
activeChar.sendMessage("This item does not stack - Creation aborted.");
|
||||
return false;
|
||||
}
|
||||
for (L2PcInstance onlinePlayer : L2World.getInstance().getPlayers())
|
||||
{
|
||||
if ((activeChar != onlinePlayer) && onlinePlayer.isOnline() && ((onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached()))
|
||||
{
|
||||
onlinePlayer.getInventory().addItem("Admin", idval, numval, onlinePlayer, activeChar);
|
||||
onlinePlayer.sendMessage("Admin spawned " + numval + " " + template.getName() + " in your inventory.");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(counter + " players rewarded with " + template.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void createItem(L2PcInstance activeChar, L2PcInstance target, int id, long num)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
204
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCursedWeapons.java
vendored
Normal file
204
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminCursedWeapons.java
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.model.CursedWeapon;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - cw_info = displays cursed weapon status - cw_remove = removes a cursed weapon from the world, item id or name must be provided - cw_add = adds a cursed weapon into the world, item id or name must be provided. Target will be the weilder - cw_goto =
|
||||
* teleports GM to the specified cursed weapon - cw_reload = reloads instance manager
|
||||
* @version $Revision: 1.1.6.3 $ $Date: 2007/07/31 10:06:06 $
|
||||
*/
|
||||
public class AdminCursedWeapons implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_cw_info",
|
||||
"admin_cw_remove",
|
||||
"admin_cw_goto",
|
||||
"admin_cw_reload",
|
||||
"admin_cw_add",
|
||||
"admin_cw_info_menu"
|
||||
};
|
||||
|
||||
private int itemId;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
CursedWeaponsManager cwm = CursedWeaponsManager.getInstance();
|
||||
int id = 0;
|
||||
|
||||
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())
|
||||
{
|
||||
L2PcInstance pl = cw.getPlayer();
|
||||
activeChar.sendMessage(" Player holding: " + (pl == null ? "null" : pl.getName()));
|
||||
activeChar.sendMessage(" Player karma: " + cw.getPlayerKarma());
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
activeChar.sendMessage(" Lying on the ground.");
|
||||
activeChar.sendMessage(" Time Remaining: " + (cw.getTimeLeft() / 60000) + " min.");
|
||||
activeChar.sendMessage(" Kills : " + cw.getNbKills());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(" Don't exist in the world.");
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.EMPTY3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Collection<CursedWeapon> cws = cwm.getCursedWeapons();
|
||||
final StringBuilder replyMSG = new StringBuilder(cws.size() * 300);
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/cwinfo.htm");
|
||||
for (CursedWeapon cw : cwm.getCursedWeapons())
|
||||
{
|
||||
itemId = cw.getItemId();
|
||||
|
||||
StringUtil.append(replyMSG, "<table width=270><tr><td>Name:</td><td>", cw.getName(), "</td></tr>");
|
||||
|
||||
if (cw.isActivated())
|
||||
{
|
||||
L2PcInstance pl = cw.getPlayer();
|
||||
StringUtil.append(replyMSG, "<tr><td>Weilder:</td><td>", (pl == null ? "null" : pl.getName()), "</td></tr>" + "<tr><td>Karma:</td><td>", String.valueOf(cw.getPlayerKarma()), "</td></tr>" + "<tr><td>Kills:</td><td>", String.valueOf(cw.getPlayerPkKills()), "/", String.valueOf(cw.getNbKills()), "</td></tr>" + "<tr><td>Time remaining:</td><td>", String.valueOf(cw.getTimeLeft() / 60000), " min.</td></tr>" + "<tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "<td><button value=\"Go\" action=\"bypass -h admin_cw_goto ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else if (cw.isDropped())
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td>Position:</td><td>Lying on the ground</td></tr>" + "<tr><td>Time remaining:</td><td>", String.valueOf(cw.getTimeLeft() / 60000), " min.</td></tr>" + "<tr><td>Kills:</td><td>", String.valueOf(cw.getNbKills()), "</td></tr>" + "<tr><td><button value=\"Remove\" action=\"bypass -h admin_cw_remove ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "<td><button value=\"Go\" action=\"bypass -h admin_cw_goto ", String.valueOf(itemId), "\" width=73 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td>Position:</td><td>Doesn't exist.</td></tr>" + "<tr><td><button value=\"Give to Target\" action=\"bypass -h admin_cw_add ", String.valueOf(itemId), "\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td></td></tr>");
|
||||
}
|
||||
|
||||
replyMSG.append("</table><br>");
|
||||
}
|
||||
adminReply.replace("%cwinfo%", replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_cw_reload"))
|
||||
{
|
||||
cwm.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
CursedWeapon cw = null;
|
||||
try
|
||||
{
|
||||
String parameter = st.nextToken();
|
||||
if (parameter.matches("[0-9]*"))
|
||||
{
|
||||
id = Integer.parseInt(parameter);
|
||||
}
|
||||
else
|
||||
{
|
||||
parameter = parameter.replace('_', ' ');
|
||||
for (CursedWeapon cwp : cwm.getCursedWeapons())
|
||||
{
|
||||
if (cwp.getName().toLowerCase().contains(parameter.toLowerCase()))
|
||||
{
|
||||
id = cwp.getItemId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
cw = cwm.getCursedWeapon(id);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cw_remove|//cw_goto|//cw_add <itemid|name>");
|
||||
}
|
||||
|
||||
if (cw == null)
|
||||
{
|
||||
activeChar.sendMessage("Unknown cursed weapon ID.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_cw_remove "))
|
||||
{
|
||||
cw.endOfLife();
|
||||
}
|
||||
else if (command.startsWith("admin_cw_goto "))
|
||||
{
|
||||
cw.goTo(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_cw_add"))
|
||||
{
|
||||
if (cw.isActive())
|
||||
{
|
||||
activeChar.sendMessage("This cursed weapon is already active.");
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDebug.java
vendored
Normal file
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDebug.java
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDelete.java
vendored
Normal file
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDelete.java
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Npc)
|
||||
{
|
||||
L2Npc target = (L2Npc) obj;
|
||||
target.deleteMe();
|
||||
|
||||
L2Spawn spawn = target.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
}
|
||||
76
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDisconnect.java
vendored
Normal file
76
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDisconnect.java
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
152
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDoorControl.java
vendored
Normal file
152
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminDoorControl.java
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.startsWith("admin_open "))
|
||||
{
|
||||
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 "))
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (command.equals("admin_open"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2DoorInstance)
|
||||
{
|
||||
((L2DoorInstance) target).openMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
|
||||
if (command.equals("admin_close"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2DoorInstance)
|
||||
{
|
||||
((L2DoorInstance) target).closeMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
1496
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEditChar.java
vendored
Normal file
1496
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEditChar.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
780
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEffects.java
vendored
Normal file
780
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEffects.java
vendored
Normal file
@@ -0,0 +1,780 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.enums.Team;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.skills.AbnormalVisualEffect;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Earthquake;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExRedSky;
|
||||
import com.l2jserver.gameserver.network.serverpackets.L2GameServerPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SocialAction;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SunRise;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SunSet;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.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"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
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.sendMessage("You are now invisible.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.broadcastUserInfo();
|
||||
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.sendMessage("You are now invisible.");
|
||||
}
|
||||
else if (command.startsWith("admin_vis"))
|
||||
{
|
||||
activeChar.setInvisible(false);
|
||||
activeChar.broadcastUserInfo();
|
||||
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
|
||||
{
|
||||
String val1 = st.nextToken();
|
||||
int intensity = Integer.parseInt(val1);
|
||||
String val2 = st.nextToken();
|
||||
int duration = Integer.parseInt(val2);
|
||||
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
|
||||
{
|
||||
String type = st.nextToken();
|
||||
String state = st.nextToken();
|
||||
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"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
if (!player.isGM())
|
||||
{
|
||||
player.startAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
|
||||
player.setIsParalyzed(true);
|
||||
player.startParalyze();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpara_all"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
player.stopAbnormalVisualEffect(AbnormalVisualEffect.PARALYZE);
|
||||
player.setIsParalyzed(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_para")) // || command.startsWith("admin_para_menu"))
|
||||
{
|
||||
String type = "1";
|
||||
try
|
||||
{
|
||||
type = st.nextToken();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
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.setIsParalyzed(true);
|
||||
player.startParalyze();
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
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.setIsParalyzed(false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_bighead"))
|
||||
{
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
int val = Integer.parseInt(st.nextToken());
|
||||
boolean sendMessage = activeChar.isAffectedBySkill(7029);
|
||||
activeChar.stopSkillEffects((val == 0) && sendMessage, 7029);
|
||||
if ((val >= 1) && (val <= 4))
|
||||
{
|
||||
Skill gmSpeedSkill = SkillData.getInstance().getSkill(7029, val);
|
||||
activeChar.doSimultaneousCast(gmSpeedSkill);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
|
||||
}
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
command = "";
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_polyself"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String id = st.nextToken();
|
||||
activeChar.getPoly().setPolyInfo("npc", id);
|
||||
activeChar.teleToLocation(activeChar.getLocation());
|
||||
CharInfo info1 = new CharInfo(activeChar);
|
||||
activeChar.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(activeChar);
|
||||
activeChar.sendPacket(info2);
|
||||
}
|
||||
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());
|
||||
CharInfo info1 = new CharInfo(activeChar);
|
||||
activeChar.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(activeChar);
|
||||
activeChar.sendPacket(info2);
|
||||
}
|
||||
else if (command.equals("admin_clearteams"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
player.setTeam(Team.NONE);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setteam_close"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = st.nextToken();
|
||||
int radius = 400;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
radius = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
Team team = Team.valueOf(val.toUpperCase());
|
||||
Collection<L2Character> plrs = activeChar.getKnownList().getKnownCharactersInRadius(radius);
|
||||
|
||||
for (L2Character player : plrs)
|
||||
{
|
||||
player.setTeam(team);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setteam_close <none|blue|red> [radius]");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setteam"))
|
||||
{
|
||||
try
|
||||
{
|
||||
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)
|
||||
{
|
||||
int social = Integer.parseInt(st.nextToken());
|
||||
target = st.nextToken();
|
||||
if (target != null)
|
||||
{
|
||||
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
|
||||
{
|
||||
int radius = Integer.parseInt(target);
|
||||
Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
for (L2Object object : objs)
|
||||
{
|
||||
if (activeChar.isInsideRadius(object, radius, false, false))
|
||||
{
|
||||
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)
|
||||
{
|
||||
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"))
|
||||
{
|
||||
if (st.countTokens() > 0)
|
||||
{
|
||||
final String param1 = st.nextToken();
|
||||
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)
|
||||
{
|
||||
for (L2Object object : activeChar.getKnownList().getKnownObjects().values())
|
||||
{
|
||||
if (activeChar.isInsideRadius(object, radius, false, false))
|
||||
{
|
||||
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
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < AbnormalVisualEffect.values().length; i++)
|
||||
{
|
||||
final AbnormalVisualEffect abnormalVisualEffect = AbnormalVisualEffect.values()[i];
|
||||
sb.append("<button action=\"bypass admin_ave_abnormal " + abnormalVisualEffect.name() + "\" align=left icon=teleport>" + abnormalVisualEffect.name() + "</button>");
|
||||
}
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/ave_abnormal.htm");
|
||||
html.replace("%abnormals%", sb.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;
|
||||
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
|
||||
{
|
||||
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"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (!(target instanceof L2Npc))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
L2Npc npc = (L2Npc) target;
|
||||
try
|
||||
{
|
||||
String type = st.nextToken();
|
||||
int diplayeffect = Integer.parseInt(type);
|
||||
npc.setState(diplayeffect);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //set_displayeffect <id>");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
L2GameServerPacket 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)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
188
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminElement.java
vendored
Normal file
188
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminElement.java
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
String[] args = command.split(" ");
|
||||
|
||||
byte element = Elementals.getElementId(args[1]);
|
||||
int value = Integer.parseInt(args[2]);
|
||||
if ((element < -1) || (element > 5) || (value < 0) || (value > 450))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element> <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
|
||||
setElement(activeChar, element, value, armorType);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setlh/setlc/setlg/setlb/setll/setlw/setls <element>[0-5] <value>[0-450]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void setElement(L2PcInstance activeChar, byte type, int value, int armorType)
|
||||
{
|
||||
// get the target
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
String old, current;
|
||||
Elementals element = itemInstance.getElemental(type);
|
||||
if (element == null)
|
||||
{
|
||||
old = "None";
|
||||
}
|
||||
else
|
||||
{
|
||||
old = element.toString();
|
||||
}
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
if (type == -1)
|
||||
{
|
||||
itemInstance.clearElementAttr(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemInstance.setElementAttr(type, value);
|
||||
}
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
if (itemInstance.getElementals() == null)
|
||||
{
|
||||
current = "None";
|
||||
}
|
||||
else
|
||||
{
|
||||
current = itemInstance.getElemental(type).toString();
|
||||
}
|
||||
|
||||
// send packets
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendPacket(iu);
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed elemental power of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
if (player != activeChar)
|
||||
{
|
||||
player.sendMessage(activeChar.getName() + " has changed the elemental power of your " + itemInstance.getItem().getName() + " from " + old + " to " + current + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
237
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEnchant.java
vendored
Normal file
237
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEnchant.java
vendored
Normal file
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - enchant_armor
|
||||
* @version $Revision: 1.3.2.1.2.10 $ $Date: 2005/08/24 21:06:06 $
|
||||
*/
|
||||
public class AdminEnchant implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminEnchant.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_seteh",// 6
|
||||
"admin_setec",// 10
|
||||
"admin_seteg",// 9
|
||||
"admin_setel",// 11
|
||||
"admin_seteb",// 12
|
||||
"admin_setew",// 7
|
||||
"admin_setes",// 8
|
||||
"admin_setle",// 1
|
||||
"admin_setre",// 2
|
||||
"admin_setlf",// 4
|
||||
"admin_setrf",// 5
|
||||
"admin_seten",// 3
|
||||
"admin_setun",// 0
|
||||
"admin_setba",// 13
|
||||
"admin_setbe",
|
||||
"admin_enchant"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_enchant"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
int armorType = -1;
|
||||
|
||||
if (command.startsWith("admin_seteh"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_HEAD;
|
||||
}
|
||||
else if (command.startsWith("admin_setec"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CHEST;
|
||||
}
|
||||
else if (command.startsWith("admin_seteg"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_GLOVES;
|
||||
}
|
||||
else if (command.startsWith("admin_seteb"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_FEET;
|
||||
}
|
||||
else if (command.startsWith("admin_setel"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEGS;
|
||||
}
|
||||
else if (command.startsWith("admin_setew"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setes"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LHAND;
|
||||
}
|
||||
else if (command.startsWith("admin_setle"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LEAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setre"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_REAR;
|
||||
}
|
||||
else if (command.startsWith("admin_setlf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_LFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_setrf"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_RFINGER;
|
||||
}
|
||||
else if (command.startsWith("admin_seten"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_NECK;
|
||||
}
|
||||
else if (command.startsWith("admin_setun"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_UNDER;
|
||||
}
|
||||
else if (command.startsWith("admin_setba"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_CLOAK;
|
||||
}
|
||||
else if (command.startsWith("admin_setbe"))
|
||||
{
|
||||
armorType = Inventory.PAPERDOLL_BELT;
|
||||
}
|
||||
|
||||
if (armorType != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
int ench = Integer.parseInt(command.substring(12));
|
||||
|
||||
// check value
|
||||
if ((ench < 0) || (ench > 65535))
|
||||
{
|
||||
activeChar.sendMessage("You must set the enchant level to be between 0-65535.");
|
||||
}
|
||||
else
|
||||
{
|
||||
setEnchant(activeChar, ench, armorType);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a new enchant value.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
if (Config.DEVELOPER)
|
||||
{
|
||||
_log.warning("Set enchant error: " + e);
|
||||
}
|
||||
activeChar.sendMessage("Please specify a valid new enchant value.");
|
||||
}
|
||||
}
|
||||
|
||||
// show the enchant menu after an action
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setEnchant(L2PcInstance activeChar, int ench, int armorType)
|
||||
{
|
||||
// get the target
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
// now we need to find the equipped weapon of the targeted character...
|
||||
int curEnchant = 0; // display purposes only
|
||||
L2ItemInstance itemInstance = null;
|
||||
|
||||
// only attempt to enchant if there is a weapon equipped
|
||||
L2ItemInstance parmorInstance = player.getInventory().getPaperdollItem(armorType);
|
||||
if ((parmorInstance != null) && (parmorInstance.getLocationSlot() == armorType))
|
||||
{
|
||||
itemInstance = parmorInstance;
|
||||
}
|
||||
|
||||
if (itemInstance != null)
|
||||
{
|
||||
curEnchant = itemInstance.getEnchantLevel();
|
||||
|
||||
// set enchant value
|
||||
player.getInventory().unEquipItemInSlot(armorType);
|
||||
itemInstance.setEnchantLevel(ench);
|
||||
player.getInventory().equipItem(itemInstance);
|
||||
|
||||
// send packets
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addModifiedItem(itemInstance);
|
||||
player.sendPacket(iu);
|
||||
player.broadcastPacket(new CharInfo(player));
|
||||
player.sendPacket(new UserInfo(player));
|
||||
|
||||
// informations
|
||||
activeChar.sendMessage("Changed enchantment of " + player.getName() + "'s " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
player.sendMessage("Admin has changed the enchantment of your " + itemInstance.getItem().getName() + " from " + curEnchant + " to " + ench + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "enchant.htm");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
607
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEventEngine.java
vendored
Normal file
607
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEventEngine.java
vendored
Normal file
@@ -0,0 +1,607 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event.EventState;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.util.Rnd;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
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.
|
||||
String eventName = command.substring(16);
|
||||
try
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "events/" + eventName)));
|
||||
BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
|
||||
adminReply.setFile("en", "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.
|
||||
String eventName = command.substring(16);
|
||||
File file = new File(Config.DATAPACK_ROOT + "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
|
||||
{
|
||||
FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "events/" + tempName));
|
||||
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.");
|
||||
|
||||
PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
|
||||
activeChar.sendPacket(_snd);
|
||||
activeChar.broadcastPacket(_snd);
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
final String replyMSG = StringUtil.concat("<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
|
||||
{
|
||||
int teamId = Integer.parseInt(st.nextToken());
|
||||
|
||||
for (L2PcInstance player : L2Event._teams.get(teamId))
|
||||
{
|
||||
player.setTitle(L2Event._teamNames.get(teamId));
|
||||
player.teleToLocation(activeChar.getLocation(), true);
|
||||
player.setInstanceId(activeChar.getInstanceId());
|
||||
}
|
||||
}
|
||||
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"))
|
||||
{
|
||||
int teamId = Integer.parseInt(st.nextToken());
|
||||
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);
|
||||
CharInfo info1 = new CharInfo(player);
|
||||
player.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(player);
|
||||
player.sendPacket(info2);
|
||||
}
|
||||
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());
|
||||
CharInfo info1 = new CharInfo(player);
|
||||
player.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(player);
|
||||
player.sendPacket(info2);
|
||||
}
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (actualCommand.startsWith("admin_event_control_transform"))
|
||||
{
|
||||
int teamId = Integer.parseInt(st.nextToken());
|
||||
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))
|
||||
{
|
||||
int transId = transIds[Rnd.get(transIds.length)];
|
||||
if (!TransformData.getInstance().transformPlayer(transId, player))
|
||||
{
|
||||
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())
|
||||
{
|
||||
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"))
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
String[] n = st.nextToken().split("\\*");
|
||||
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, "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)
|
||||
{
|
||||
StringUtil.append(result, "<tr><td align=center>", fileName, " </td></tr><tr><td><table cellspacing=0><tr><td><button value=\"Select Event\" action=\"bypass -h admin_event_set ", fileName, "\" 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 ", fileName, "\" 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 ", fileName, "\" width=90 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table></td></tr>", "<tr><td> </td></tr><tr><td> </td></tr>");
|
||||
}
|
||||
|
||||
result.append("</table>");
|
||||
|
||||
return note + result.toString();
|
||||
}
|
||||
|
||||
public void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
final String replyMSG = StringUtil.concat("<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();
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(500, "<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();
|
||||
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();
|
||||
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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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> </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();
|
||||
adminReply.setHtml("<html><body> CONGRATULATIONS! You should have been rewarded. </body></html>");
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
}
|
||||
167
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEvents.java
vendored
Normal file
167
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminEvents.java
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Event;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class AdminEvents implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_event_menu",
|
||||
"admin_event_start",
|
||||
"admin_event_stop",
|
||||
"admin_event_start_menu",
|
||||
"admin_event_stop_menu",
|
||||
"admin_event_bypass"
|
||||
};
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String event_name = "";
|
||||
String _event_bypass = "";
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Event event = (Event) QuestManager.getInstance().getQuest(event_name);
|
||||
if (event != null)
|
||||
{
|
||||
event.eventBypass(activeChar, _event_bypass);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //event_bypass <eventname> <bypass>");
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void showMenu(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/gm_events.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (Quest event : QuestManager.getInstance().getScripts().values())
|
||||
{
|
||||
if (event instanceof Event)
|
||||
{
|
||||
StringUtil.append(cList, "<font color=\"LEVEL\">" + event.getName() + ":</font><br1>", "<table width=270><tr>", "<td><button value=\"Start\" action=\"bypass -h admin_event_start_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "<td><button value=\"Stop\" action=\"bypass -h admin_event_stop_menu " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "<td><button value=\"Menu\" action=\"bypass -h admin_event_bypass " + event.getName() + "\" width=80 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>", "</tr></table><br>");
|
||||
}
|
||||
}
|
||||
html.replace("%LIST%", cList.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
}
|
||||
207
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminExpSp.java
vendored
Normal file
207
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminExpSp.java
vendored
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.ClassListData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/expsp.htm");
|
||||
adminReply.replace("%name%", player.getName());
|
||||
adminReply.replace("%level%", String.valueOf(player.getLevel()));
|
||||
adminReply.replace("%xp%", String.valueOf(player.getExp()));
|
||||
adminReply.replace("%sp%", String.valueOf(player.getSp()));
|
||||
adminReply.replace("%class%", ClassListData.getInstance().getClass(player.getClassId()).getClientCode());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private boolean adminAddExpSp(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String exp = st.nextToken();
|
||||
String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
long spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Long.parseLong(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is adding you " + expval + " xp and " + spval + " sp.");
|
||||
player.addExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Added " + expval + " xp and " + spval + " sp to " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") added " + expval + " xp and " + spval + " sp to " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean adminRemoveExpSP(L2PcInstance activeChar, String ExpSp)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String exp = st.nextToken();
|
||||
String sp = st.nextToken();
|
||||
long expval = 0;
|
||||
int spval = 0;
|
||||
try
|
||||
{
|
||||
expval = Long.parseLong(exp);
|
||||
spval = Integer.parseInt(sp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if ((expval != 0) || (spval != 0))
|
||||
{
|
||||
// Common character information
|
||||
player.sendMessage("Admin is removing you " + expval + " xp and " + spval + " sp.");
|
||||
player.removeExpAndSp(expval, spval);
|
||||
// Admin information
|
||||
activeChar.sendMessage("Removed " + expval + " xp and " + spval + " sp from " + player.getName() + ".");
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") removed " + expval + " xp and " + spval + " sp from " + player.getObjectId() + ".");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
356
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminFightCalculator.java
vendored
Normal file
356
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminFightCalculator.java
vendored
Normal file
@@ -0,0 +1,356 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.model.stats.Formulas;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode on/off
|
||||
* @version $Revision: 1.1.2.1 $ $Date: 2005/03/15 21:32:48 $
|
||||
*/
|
||||
public class AdminFightCalculator implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fight_calculator",
|
||||
"admin_fight_calculator_show",
|
||||
"admin_fcs",
|
||||
};
|
||||
|
||||
// TODO: remove from gm list etc etc
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.startsWith("admin_fight_calculator_show"))
|
||||
{
|
||||
handleShow(command.substring("admin_fight_calculator_show".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fcs"))
|
||||
{
|
||||
handleShow(command.substring("admin_fcs".length()), activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_fight_calculator"))
|
||||
{
|
||||
handleStart(command.substring("admin_fight_calculator".length()), activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleStart(String params, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(params);
|
||||
int lvl1 = 0;
|
||||
int lvl2 = 0;
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
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();
|
||||
|
||||
final String replyMSG;
|
||||
|
||||
if ((npc1 != null) && (npc2 != null))
|
||||
{
|
||||
replyMSG = StringUtil.concat("<html><title>Selected mobs to fight</title>" + "<body>" + "<table>" + "<tr><td>First</td><td>Second</td></tr>" + "<tr><td>level ", String.valueOf(lvl1), "</td><td>level ", String.valueOf(lvl2), "</td></tr>" + "<tr><td>id ", String.valueOf(npc1.getId()), "</td><td>id ", String.valueOf(npc2.getId()), "</td></tr>" + "<tr><td>", npc1.getName(), "</td><td>", npc2.getName(), "</td></tr>" + "</table>" + "<center><br><br><br>" + "<button value=\"OK\" action=\"bypass -h admin_fight_calculator_show ", String.valueOf(npc1.getId()), " ", String.valueOf(npc2.getId()), "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "</center>" + "</body></html>");
|
||||
}
|
||||
else if ((lvl1 != 0) && (npc1 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl1);
|
||||
final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "<html><title>Select first mob to fight</title>" + "<body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 ", String.valueOf(lvl1), " lvl2 ", String.valueOf(lvl2), " mid1 ", String.valueOf(n.getId()), " mid2 ", String.valueOf(mid2), "\">", n.getName(), "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else if ((lvl2 != 0) && (npc2 == null))
|
||||
{
|
||||
final List<L2NpcTemplate> npcs = NpcData.getInstance().getAllOfLevel(lvl2);
|
||||
final StringBuilder sb = StringUtil.startAppend(50 + (npcs.size() * 200), "<html><title>Select second mob to fight</title>" + "<body><table>");
|
||||
|
||||
for (L2NpcTemplate n : npcs)
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td><a action=\"bypass -h admin_fight_calculator lvl1 ", String.valueOf(lvl1), " lvl2 ", String.valueOf(lvl2), " mid1 ", String.valueOf(mid1), " mid2 ", String.valueOf(n.getId()), "\">", n.getName(), "</a></td></tr>");
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG = "<html><title>Select mobs to fight</title>" + "<body>" + "<table>" + "<tr><td>First</td><td>Second</td></tr>" + "<tr><td><edit var=\"lvl1\" width=80></td><td><edit var=\"lvl2\" width=80></td></tr>" + "</table>" + "<center><br><br><br>" + "<button value=\"OK\" action=\"bypass -h admin_fight_calculator lvl1 $lvl1 lvl2 $lvl2\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" + "</center>" + "</body></html>";
|
||||
}
|
||||
|
||||
adminReply.setHtml(replyMSG);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void handleShow(String params, L2PcInstance activeChar)
|
||||
{
|
||||
params = params.trim();
|
||||
|
||||
L2Character npc1 = null;
|
||||
L2Character npc2 = null;
|
||||
if (params.length() == 0)
|
||||
{
|
||||
npc1 = activeChar;
|
||||
npc2 = (L2Character) activeChar.getTarget();
|
||||
if (npc2 == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int mid1 = 0;
|
||||
int mid2 = 0;
|
||||
StringTokenizer st = new StringTokenizer(params);
|
||||
mid1 = Integer.parseInt(st.nextToken());
|
||||
mid2 = Integer.parseInt(st.nextToken());
|
||||
|
||||
npc1 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid1));
|
||||
npc2 = new L2MonsterInstance(NpcData.getInstance().getTemplate(mid2));
|
||||
}
|
||||
|
||||
int miss1 = 0;
|
||||
int miss2 = 0;
|
||||
int shld1 = 0;
|
||||
int shld2 = 0;
|
||||
int crit1 = 0;
|
||||
int crit2 = 0;
|
||||
double patk1 = 0;
|
||||
double patk2 = 0;
|
||||
double pdef1 = 0;
|
||||
double pdef2 = 0;
|
||||
double dmg1 = 0;
|
||||
double dmg2 = 0;
|
||||
|
||||
// ATTACK speed in milliseconds
|
||||
int sAtk1 = npc1.calculateTimeBetweenAttacks(npc2, null);
|
||||
int sAtk2 = npc2.calculateTimeBetweenAttacks(npc1, null);
|
||||
// number of ATTACK per 100 seconds
|
||||
sAtk1 = 100000 / sAtk1;
|
||||
sAtk2 = 100000 / sAtk2;
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
boolean _miss1 = Formulas.calcHitMiss(npc1, npc2);
|
||||
if (_miss1)
|
||||
{
|
||||
miss1++;
|
||||
}
|
||||
byte _shld1 = Formulas.calcShldUse(npc1, npc2, null, false);
|
||||
if (_shld1 > 0)
|
||||
{
|
||||
shld1++;
|
||||
}
|
||||
boolean _crit1 = Formulas.calcCrit(npc1.getCriticalHit(npc2, null), false, npc2);
|
||||
if (_crit1)
|
||||
{
|
||||
crit1++;
|
||||
}
|
||||
|
||||
double _patk1 = npc1.getPAtk(npc2);
|
||||
_patk1 += npc1.getRandomDamageMultiplier();
|
||||
patk1 += _patk1;
|
||||
|
||||
double _pdef1 = npc1.getPDef(npc2);
|
||||
pdef1 += _pdef1;
|
||||
|
||||
if (!_miss1)
|
||||
{
|
||||
double _dmg1 = Formulas.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false);
|
||||
dmg1 += _dmg1;
|
||||
npc1.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10000; i++)
|
||||
{
|
||||
boolean _miss2 = Formulas.calcHitMiss(npc2, npc1);
|
||||
if (_miss2)
|
||||
{
|
||||
miss2++;
|
||||
}
|
||||
byte _shld2 = Formulas.calcShldUse(npc2, npc1, null, false);
|
||||
if (_shld2 > 0)
|
||||
{
|
||||
shld2++;
|
||||
}
|
||||
boolean _crit2 = Formulas.calcCrit(npc2.getCriticalHit(npc1, null), false, npc1);
|
||||
if (_crit2)
|
||||
{
|
||||
crit2++;
|
||||
}
|
||||
|
||||
double _patk2 = npc2.getPAtk(npc1);
|
||||
_patk2 *= npc2.getRandomDamageMultiplier();
|
||||
patk2 += _patk2;
|
||||
|
||||
double _pdef2 = npc2.getPDef(npc1);
|
||||
pdef2 += _pdef2;
|
||||
|
||||
if (!_miss2)
|
||||
{
|
||||
double _dmg2 = Formulas.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false);
|
||||
dmg2 += _dmg2;
|
||||
npc2.abortAttack();
|
||||
}
|
||||
}
|
||||
|
||||
miss1 /= 100;
|
||||
miss2 /= 100;
|
||||
shld1 /= 100;
|
||||
shld2 /= 100;
|
||||
crit1 /= 100;
|
||||
crit2 /= 100;
|
||||
patk1 /= 10000;
|
||||
patk2 /= 10000;
|
||||
pdef1 /= 10000;
|
||||
pdef2 /= 10000;
|
||||
dmg1 /= 10000;
|
||||
dmg2 /= 10000;
|
||||
|
||||
// total damage per 100 seconds
|
||||
int tdmg1 = (int) (sAtk1 * dmg1);
|
||||
int tdmg2 = (int) (sAtk2 * dmg2);
|
||||
// HP restored per 100 seconds
|
||||
double maxHp1 = npc1.getMaxHp();
|
||||
int hp1 = (int) ((Formulas.calcHpRegen(npc1) * 100000) / Formulas.getRegeneratePeriod(npc1));
|
||||
|
||||
double maxHp2 = npc2.getMaxHp();
|
||||
int hp2 = (int) ((Formulas.calcHpRegen(npc2) * 100000) / Formulas.getRegeneratePeriod(npc2));
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(1000, "<html><title>Selected mobs to fight</title>" + "<body>" + "<table>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<tr><td width=140>Parameter</td><td width=70>me</td><td width=70>target</td></tr>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td width=140>Parameter</td><td width=70>", ((L2NpcTemplate) npc1.getTemplate()).getName(), "</td><td width=70>", ((L2NpcTemplate) npc2.getTemplate()).getName(), "</td></tr>");
|
||||
}
|
||||
|
||||
StringUtil.append(replyMSG, "<tr><td>miss</td><td>", String.valueOf(miss1), "%</td><td>", String.valueOf(miss2), "%</td></tr>" + "<tr><td>shld</td><td>", String.valueOf(shld2), "%</td><td>", String.valueOf(shld1), "%</td></tr>" + "<tr><td>crit</td><td>", String.valueOf(crit1), "%</td><td>", String.valueOf(crit2), "%</td></tr>" + "<tr><td>pAtk / pDef</td><td>", String.valueOf((int) patk1), " / ", String.valueOf((int) pdef1), "</td><td>", String.valueOf((int) patk2), " / ", String.valueOf((int) pdef2), "</td></tr>" + "<tr><td>made hits</td><td>", String.valueOf(sAtk1), "</td><td>", String.valueOf(sAtk2), "</td></tr>" + "<tr><td>dmg per hit</td><td>", String.valueOf((int) dmg1), "</td><td>", String.valueOf((int) dmg2), "</td></tr>" + "<tr><td>got dmg</td><td>", String.valueOf(tdmg2), "</td><td>", String.valueOf(tdmg1), "</td></tr>" + "<tr><td>got regen</td><td>", String.valueOf(hp1), "</td><td>", String.valueOf(hp2), "</td></tr>" + "<tr><td>had HP</td><td>", String.valueOf((int) maxHp1), "</td><td>", String.valueOf((int) maxHp2), "</td></tr>" + "<tr><td>die</td>");
|
||||
|
||||
if ((tdmg2 - hp1) > 1)
|
||||
{
|
||||
StringUtil.append(replyMSG, "<td>", String.valueOf((int) ((100 * maxHp1) / (tdmg2 - hp1))), " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
if ((tdmg1 - hp2) > 1)
|
||||
{
|
||||
StringUtil.append(replyMSG, "<td>", String.valueOf((int) ((100 * maxHp2) / (tdmg1 - hp2))), " sec</td>");
|
||||
}
|
||||
else
|
||||
{
|
||||
replyMSG.append("<td>never</td>");
|
||||
}
|
||||
|
||||
replyMSG.append("</tr>" + "</table>" + "<center><br>");
|
||||
|
||||
if (params.length() == 0)
|
||||
{
|
||||
replyMSG.append("<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(replyMSG, "<button value=\"Retry\" action=\"bypass -h admin_fight_calculator_show ", String.valueOf(((L2NpcTemplate) npc1.getTemplate()).getId()), " ", String.valueOf(((L2NpcTemplate) npc2.getTemplate()).getId()), "\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
|
||||
replyMSG.append("</center>" + "</body></html>");
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
|
||||
if (params.length() != 0)
|
||||
{
|
||||
((L2MonsterInstance) npc1).deleteMe();
|
||||
((L2MonsterInstance) npc2).deleteMe();
|
||||
}
|
||||
}
|
||||
}
|
||||
196
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminFortSiege.java
vendored
Normal file
196
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminFortSiege.java
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.FortManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Fort;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles all siege commands: Todo: change the class name, and neaten it up
|
||||
*/
|
||||
public class AdminFortSiege implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminFortSiege.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_fortsiege",
|
||||
"admin_add_fortattacker",
|
||||
"admin_list_fortsiege_clans",
|
||||
"admin_clear_fortsiege_list",
|
||||
"admin_spawn_fortdoors",
|
||||
"admin_endfortsiege",
|
||||
"admin_startfortsiege",
|
||||
"admin_setfort",
|
||||
"admin_removefort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
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
|
||||
{
|
||||
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"))
|
||||
{
|
||||
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();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/forts.htm");
|
||||
|
||||
final List<Fort> forts = FortManager.getInstance().getForts();
|
||||
final StringBuilder cList = new StringBuilder(forts.size() * 100);
|
||||
|
||||
for (Fort fort : forts)
|
||||
{
|
||||
if (fort != null)
|
||||
{
|
||||
StringUtil.append(cList, "<td fixwidth=90><a action=\"bypass -h admin_fortsiege ", String.valueOf(fort.getResidenceId()), "\">", fort.getName(), " id: ", String.valueOf(fort.getResidenceId()), "</a></td>");
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > 2)
|
||||
{
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
|
||||
adminReply.replace("%forts%", cList.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showFortSiegePage(L2PcInstance activeChar, Fort fort)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/fort.htm");
|
||||
adminReply.replace("%fortName%", fort.getName());
|
||||
adminReply.replace("%fortId%", String.valueOf(fort.getResidenceId()));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
151
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGeodata.java
vendored
Normal file
151
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGeodata.java
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.GeoData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
57
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGm.java
vendored
Normal file
57
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGm.java
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - gm = turns gm mode off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminGm implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminGm.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_gm"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_gm") && activeChar.isGM())
|
||||
{
|
||||
AdminData.getInstance().deleteGm(activeChar);
|
||||
activeChar.setAccessLevel(0, true);
|
||||
activeChar.sendMessage("You no longer have GM status.");
|
||||
_log.info("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") turned his GM status off");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
126
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGmChat.java
vendored
Normal file
126
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGmChat.java
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.enums.ChatType;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
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);
|
||||
CreatureSay cs = new CreatureSay(0, ChatType.ALLIANCE, activeChar.getName(), text);
|
||||
AdminData.getInstance().broadcastToGMs(cs);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
// Who cares?
|
||||
}
|
||||
}
|
||||
}
|
||||
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGraciaSeeds.java
vendored
Normal file
87
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGraciaSeeds.java
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.GraciaSeedsManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
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();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/graciaseeds.htm");
|
||||
html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
|
||||
html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
|
||||
if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
333
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGrandBoss.java
vendored
Normal file
333
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminGrandBoss.java
vendored
Normal file
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.GrandBossManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jserver.gameserver.model.StatsSet;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.model.zone.type.L2NoRestartZone;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @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
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0, 1);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/grandboss.htm"));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case "admin_grandboss_skip":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
if (grandBossId == ANTHARAS)
|
||||
{
|
||||
antharasAi().notifyEvent("SKIP_WAITING", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_skip Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_respawn":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final int grandBossId = Integer.parseInt(st.nextToken());
|
||||
|
||||
switch (grandBossId)
|
||||
{
|
||||
case ANTHARAS:
|
||||
{
|
||||
antharasAi().notifyEvent("RESPAWN_ANTHARAS", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
baiumAi().notifyEvent("RESPAWN_BAIUM", null, activeChar);
|
||||
manageHtml(activeChar, grandBossId);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage("Wrong ID!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //grandboss_respawn Id");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_grandboss_minions":
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
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 = "html/admin/grandboss_antharas.htm";
|
||||
break;
|
||||
}
|
||||
case VALAKAS:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_valakas.htm";
|
||||
break;
|
||||
}
|
||||
case BAIUM:
|
||||
{
|
||||
bossZone = ZoneManager.getInstance().getZoneById(BAIUM_ZONE, L2NoRestartZone.class);
|
||||
htmlPatch = "html/admin/grandboss_baium.htm";
|
||||
break;
|
||||
}
|
||||
case QUEENANT:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_queenant.htm";
|
||||
break;
|
||||
}
|
||||
case ORFEN:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_orfen.htm";
|
||||
break;
|
||||
}
|
||||
case CORE:
|
||||
{
|
||||
htmlPatch = "html/admin/grandboss_core.htm";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Arrays.asList(ANTHARAS, VALAKAS, BAIUM).contains(grandBossId))
|
||||
{
|
||||
deadStatus = 3;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FFFF00"; // Yellow
|
||||
text = "Waiting";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
textColor = "FF9900"; // Orange
|
||||
text = "In Fight";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deadStatus = 1;
|
||||
switch (bossStatus)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
textColor = "00FF00"; // Green
|
||||
text = "Alive";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
textColor = "FF0000"; // Red
|
||||
text = "Dead";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StatsSet info = GrandBossManager.getInstance().getStatsSet(grandBossId);
|
||||
final String bossRespawn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(info.getLong("respawn_time"));
|
||||
|
||||
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 null;
|
||||
// return QuestManager.getInstance().getQuest(Antharas.class.getSimpleName());
|
||||
}
|
||||
|
||||
private Quest baiumAi()
|
||||
{
|
||||
return null;
|
||||
// return QuestManager.getInstance().getQuest(Baium.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
143
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminHeal.java
vendored
Normal file
143
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminHeal.java
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
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)
|
||||
{
|
||||
L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(player);
|
||||
Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
for (L2Object object : objs)
|
||||
{
|
||||
if (object instanceof L2Character)
|
||||
{
|
||||
L2Character character = (L2Character) object;
|
||||
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
|
||||
if (object instanceof L2PcInstance)
|
||||
{
|
||||
character.setCurrentCp(character.getMaxCp());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Healed within " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException nbe)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
L2Character target = (L2Character) obj;
|
||||
target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.setCurrentCp(target.getMaxCp());
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") healed character " + target.getName());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
}
|
||||
123
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminHtml.java
vendored
Normal file
123
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminHtml.java
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminHtml implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_html",
|
||||
"admin_loadhtml"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_html":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //html path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showAdminHtml(activeChar, path);
|
||||
break;
|
||||
}
|
||||
case "admin_loadhtml":
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //loadhtml path");
|
||||
return false;
|
||||
}
|
||||
|
||||
final String path = st.nextToken();
|
||||
showHtml(activeChar, path, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar
|
||||
* @param activeChar activeChar where html is shown
|
||||
* @param path relative path from directory html/admin/ to html
|
||||
*/
|
||||
public static void showAdminHtml(L2PcInstance activeChar, String path)
|
||||
{
|
||||
showHtml(activeChar, "html/admin/" + path, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a html message to activeChar.
|
||||
* @param activeChar activeChar where html message is shown.
|
||||
* @param path relative path from Config.DATAPACK_ROOT to html.
|
||||
* @param reload {@code true} will reload html and show it {@code false} will show it from cache.
|
||||
*/
|
||||
public static void showHtml(L2PcInstance activeChar, String path, boolean reload)
|
||||
{
|
||||
String content = null;
|
||||
if (!reload)
|
||||
{
|
||||
content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = new File(Config.DATAPACK_ROOT, path);
|
||||
content = HtmCache.getInstance().loadFile(file);
|
||||
}
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
if (content != null)
|
||||
{
|
||||
html.setHtml(content);
|
||||
}
|
||||
else
|
||||
{
|
||||
html.setHtml("<html><body>My text is missing:<br>" + path + "</body></html>");
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
164
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInstance.java
vendored
Normal file
164
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInstance.java
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Summon;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Instance;
|
||||
|
||||
/**
|
||||
* @author evill33t, GodKratos
|
||||
*/
|
||||
public class AdminInstance implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_setinstance",
|
||||
"admin_ghoston",
|
||||
"admin_ghostoff",
|
||||
"admin_createinstance",
|
||||
"admin_destroyinstance",
|
||||
"admin_listinstances"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
// create new instance
|
||||
if (command.startsWith("admin_createinstance"))
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length != 3)
|
||||
{
|
||||
activeChar.sendMessage("Example: //createinstance <id> <templatefile> - ids => 300000 are reserved for dynamic instances");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
final int id = Integer.parseInt(parts[1]);
|
||||
if ((id < 300000) && InstanceManager.getInstance().createInstanceFromTemplate(id, parts[2]))
|
||||
{
|
||||
activeChar.sendMessage("Instance created.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Failed to create instance.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1] + " " + parts[2]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_listinstances"))
|
||||
{
|
||||
for (Instance temp : InstanceManager.getInstance().getInstances().values())
|
||||
{
|
||||
activeChar.sendMessage("Id: " + temp.getId() + " Name: " + temp.getName());
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setinstance"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(st.nextToken());
|
||||
if (InstanceManager.getInstance().getInstance(val) == null)
|
||||
{
|
||||
activeChar.sendMessage("Instance " + val + " doesnt exist.");
|
||||
return false;
|
||||
}
|
||||
|
||||
L2Object target = activeChar.getTarget();
|
||||
if ((target == null) || (target instanceof L2Summon)) // Don't separate summons from masters
|
||||
{
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
return false;
|
||||
}
|
||||
target.setInstanceId(val);
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance player = (L2PcInstance) target;
|
||||
player.sendMessage("Admin set your instance to:" + val);
|
||||
player.teleToLocation(player.getLocation());
|
||||
}
|
||||
activeChar.sendMessage("Moved " + target.getName() + " to instance " + target.getInstanceId() + ".");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Use //setinstance id");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_destroyinstance"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(st.nextToken());
|
||||
InstanceManager.getInstance().destroyInstance(val);
|
||||
activeChar.sendMessage("Instance destroyed");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Use //destroyinstance id");
|
||||
}
|
||||
}
|
||||
|
||||
// set ghost mode on aka not appearing on any knownlist
|
||||
// you will be invis to all players but you also dont get update packets ;)
|
||||
// you will see snapshots (knownlist echoes?) if you port
|
||||
// so kinda useless atm
|
||||
// TODO: enable broadcast packets for ghosts
|
||||
else if (command.startsWith("admin_ghoston"))
|
||||
{
|
||||
activeChar.getAppearance().setGhostMode(true);
|
||||
activeChar.sendMessage("Ghost mode enabled");
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
}
|
||||
// ghost mode off
|
||||
else if (command.startsWith("admin_ghostoff"))
|
||||
{
|
||||
activeChar.getAppearance().setGhostMode(false);
|
||||
activeChar.sendMessage("Ghost mode disabled");
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
146
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInstanceZone.java
vendored
Normal file
146
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInstanceZone.java
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class AdminInstanceZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_instancezone",
|
||||
"admin_instancezone_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
String target = (activeChar.getTarget() != null) ? activeChar.getTarget().getName() : "no-target";
|
||||
GMAudit.auditGMAction(activeChar.getName(), command, target, "");
|
||||
|
||||
if (command.startsWith("admin_instancezone_clear"))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
|
||||
st.nextToken();
|
||||
final L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
|
||||
final int instanceId = Integer.parseInt(st.nextToken());
|
||||
final String name = InstanceManager.getInstance().getInstanceIdName(instanceId);
|
||||
InstanceManager.getInstance().deleteInstanceTime(player.getObjectId(), instanceId);
|
||||
activeChar.sendMessage("Instance zone " + name + " cleared for player " + player.getName());
|
||||
player.sendMessage("Admin cleared instance zone " + name + " for you");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed clearing instance time: " + e.getMessage());
|
||||
activeChar.sendMessage("Usage: //instancezone_clear <playername> [instanceId]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_instancezone"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken();
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
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)
|
||||
{
|
||||
Map<Integer, Long> instanceTimes = InstanceManager.getInstance().getAllInstanceTimes(player.getObjectId());
|
||||
|
||||
final StringBuilder html = StringUtil.startAppend(500 + (instanceTimes.size() * 200), "<html><center><table width=260><tr>" + "<td width=40><button value=\"Main\" action=\"bypass -h admin_admin\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "<td width=180><center>Character Instances</center></td>" + "<td width=40><button value=\"Back\" action=\"bypass -h admin_current_player\" width=40 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "</tr></table><br><font color=\"LEVEL\">Instances for ", player.getName(), "</font><center><br>" + "<table>" + "<tr><td width=150>Name</td><td width=50>Time</td><td width=70>Action</td></tr>");
|
||||
|
||||
for (int id : instanceTimes.keySet())
|
||||
{
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
long remainingTime = (instanceTimes.get(id) - System.currentTimeMillis()) / 1000;
|
||||
if (remainingTime > 0)
|
||||
{
|
||||
hours = (int) (remainingTime / 3600);
|
||||
minutes = (int) ((remainingTime % 3600) / 60);
|
||||
}
|
||||
|
||||
StringUtil.append(html, "<tr><td>", InstanceManager.getInstance().getInstanceIdName(id), "</td><td>", String.valueOf(hours), ":", String.valueOf(minutes), "</td><td><button value=\"Clear\" action=\"bypass -h admin_instancezone_clear ", player.getName(), " ", String.valueOf(id), "\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
|
||||
StringUtil.append(html, "</table></html>");
|
||||
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage();
|
||||
ms.setHtml(html.toString());
|
||||
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
}
|
||||
90
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInvul.java
vendored
Normal file
90
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminInvul.java
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2007/07/31 10:06:02 $
|
||||
*/
|
||||
public class AdminInvul implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminInvul.class.getName());
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_invul",
|
||||
"admin_setinvul"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.equals("admin_invul"))
|
||||
{
|
||||
handleInvul(activeChar);
|
||||
AdminHtml.showAdminHtml(activeChar, "gm_menu.htm");
|
||||
}
|
||||
if (command.equals("admin_setinvul"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
handleInvul((L2PcInstance) target);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleInvul(L2PcInstance activeChar)
|
||||
{
|
||||
String text;
|
||||
if (activeChar.isInvul())
|
||||
{
|
||||
activeChar.setIsInvul(false);
|
||||
text = activeChar.getName() + " is now mortal";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: Gm removed invul mode from character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setIsInvul(true);
|
||||
text = activeChar.getName() + " is now invulnerable";
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: Gm activated invul mode for character " + activeChar.getName() + "(" + activeChar.getObjectId() + ")");
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage(text);
|
||||
}
|
||||
}
|
||||
74
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminKick.java
vendored
Normal file
74
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminKick.java
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
String player = st.nextToken();
|
||||
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;
|
||||
}
|
||||
}
|
||||
169
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminKill.java
vendored
Normal file
169
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminKill.java
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
st.nextToken(); // skip command
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
String firstParam = st.nextToken();
|
||||
L2PcInstance plyr = L2World.getInstance().getPlayer(firstParam);
|
||||
if (plyr != null)
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(st.nextToken());
|
||||
for (L2Character knownChar : plyr.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
kill(activeChar, knownChar);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Invalid radius.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
kill(activeChar, plyr);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(firstParam);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if ((knownChar instanceof L2ControllableMobInstance) || (knownChar == activeChar))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
kill(activeChar, knownChar);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Killed all characters within a " + radius + " unit radius.");
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //kill <player_name | radius>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2ControllableMobInstance) || !(obj instanceof L2Character))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
else
|
||||
{
|
||||
kill(activeChar, (L2Character) obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void kill(L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
if (!((L2PcInstance) target).isGM())
|
||||
{
|
||||
target.stopAllEffects(); // e.g. invincibility effect
|
||||
}
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean targetIsInvul = false;
|
||||
if (target.isInvul())
|
||||
{
|
||||
targetIsInvul = true;
|
||||
target.setIsInvul(false);
|
||||
}
|
||||
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
|
||||
if (targetIsInvul)
|
||||
{
|
||||
target.setIsInvul(true);
|
||||
}
|
||||
}
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ")" + " killed character " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
112
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminLevel.java
vendored
Normal file
112
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminLevel.java
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.ExperienceData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
L2Object targetChar = activeChar.getTarget();
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
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;
|
||||
}
|
||||
L2PcInstance targetPlayer = (L2PcInstance) targetChar;
|
||||
|
||||
byte lvl = Byte.parseByte(val);
|
||||
if ((lvl >= 1) && (lvl <= maxLevel))
|
||||
{
|
||||
long pXp = targetPlayer.getExp();
|
||||
long tXp = ExperienceData.getInstance().getExpForLevel(lvl);
|
||||
|
||||
if (pXp > tXp)
|
||||
{
|
||||
targetPlayer.removeExpAndSp(pXp - tXp, 0);
|
||||
}
|
||||
else if (pXp < tXp)
|
||||
{
|
||||
targetPlayer.addExpAndSp(tXp - pXp, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + 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;
|
||||
}
|
||||
}
|
||||
246
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminLogin.java
vendored
Normal file
246
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminLogin.java
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.LoginServerThread;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.gameserverpackets.ServerStatus;
|
||||
import com.l2jserver.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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
int tokens = st.countTokens();
|
||||
if (tokens > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
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();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/login.htm");
|
||||
html.replace("%server_name%", LoginServerThread.getInstance().getServerName());
|
||||
html.replace("%status%", LoginServerThread.getInstance().getStatusString());
|
||||
html.replace("%clock%", getServerTypeName(Config.SERVER_LIST_TYPE));
|
||||
html.replace("%brackets%", String.valueOf(Config.SERVER_LIST_BRACKET));
|
||||
html.replace("%max_players%", String.valueOf(LoginServerThread.getInstance().getMaxPlayer()));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private String getServerTypeName(int serverType)
|
||||
{
|
||||
String nameType = "";
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
67
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminManor.java
vendored
Normal file
67
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminManor.java
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.Castle;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* @author malyelfik
|
||||
*/
|
||||
public final class AdminManor implements IAdminCommandHandler
|
||||
{
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final CastleManorManager manor = CastleManorManager.getInstance();
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage();
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/manor.htm");
|
||||
msg.replace("%status%", manor.getCurrentModeName());
|
||||
msg.replace("%change%", manor.getNextModeChange());
|
||||
|
||||
final StringBuilder sb = new StringBuilder(3400);
|
||||
for (Castle c : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
StringUtil.append(sb, "<tr><td>Name:</td><td><font color=008000>" + c.getName() + "</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td>Current period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)), " Adena</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td>Next period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)), " Adena</font></td></tr>");
|
||||
StringUtil.append(sb, "<tr><td><font color=808080>--------------------------</font></td><td><font color=808080>--------------------------</font></td></tr>");
|
||||
}
|
||||
msg.replace("%castleInfo%", sb.toString());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
sb.setLength(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return new String[]
|
||||
{
|
||||
"admin_manor"
|
||||
};
|
||||
}
|
||||
}
|
||||
314
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMenu.java
vendored
Normal file
314
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMenu.java
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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"))
|
||||
{
|
||||
String[] data = command.split(" ");
|
||||
if (data.length == 5)
|
||||
{
|
||||
String playerName = data[1];
|
||||
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
|
||||
{
|
||||
String targetName = command.substring(23);
|
||||
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
|
||||
{
|
||||
String targetName = command.substring(24);
|
||||
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
|
||||
{
|
||||
String targetName = command.substring(23);
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return true;
|
||||
}
|
||||
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
|
||||
{
|
||||
String targetName = command.substring(21);
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
activeChar.setInstanceId(player.getInstanceId());
|
||||
teleportToCharacter(activeChar, player);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_kill_menu"))
|
||||
{
|
||||
handleKill(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_kick_menu"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
st.nextToken();
|
||||
String player = st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand + command.substring(14), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_unban_menu"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
if (st.countTokens() > 1)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
L2Character target = (L2Character) obj;
|
||||
String filename = "main_menu.htm";
|
||||
if (player != null)
|
||||
{
|
||||
L2PcInstance plyr = L2World.getInstance().getPlayer(player);
|
||||
if (plyr != null)
|
||||
{
|
||||
target = plyr;
|
||||
activeChar.sendMessage("You killed " + plyr.getName());
|
||||
}
|
||||
}
|
||||
if (target != null)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
filename = "charmanage.htm";
|
||||
}
|
||||
else if (Config.L2JMOD_CHAMPION_ENABLE && target.isChampion())
|
||||
{
|
||||
target.reduceCurrentHp((target.getMaxHp() * Config.L2JMOD_CHAMPION_HP) + 1, activeChar, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
target.reduceCurrentHp(target.getMaxHp() + 1, activeChar, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
AdminHtml.showAdminHtml(activeChar, filename);
|
||||
}
|
||||
|
||||
private void teleportCharacter(L2PcInstance player, Location loc, L2PcInstance activeChar, String message)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(message);
|
||||
player.teleToLocation(loc, true);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_CANNOT_USE_THIS_ON_YOURSELF);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setInstanceId(player.getInstanceId());
|
||||
activeChar.teleToLocation(player.getLocation(), true);
|
||||
activeChar.sendMessage("You're teleporting yourself to character " + player.getName());
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "charmanage.htm");
|
||||
}
|
||||
}
|
||||
118
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMessages.java
vendored
Normal file
118
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMessages.java
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.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 "))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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:"))
|
||||
{
|
||||
int x = Integer.parseInt(val.substring(5, val.indexOf(",")));
|
||||
int y = Integer.parseInt(val.substring(val.indexOf(",") + 1, val.lastIndexOf(",")));
|
||||
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;
|
||||
}
|
||||
}
|
||||
633
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMobGroup.java
vendored
Normal file
633
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMobGroup.java
vendored
Normal file
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.MobGroup;
|
||||
import com.l2jserver.gameserver.model.MobGroupTable;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SetupGauge;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
L2NpcTemplate template = NpcData.getInstance().getTemplate(templateId);
|
||||
|
||||
if (template == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid NPC ID specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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(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;
|
||||
}
|
||||
|
||||
MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid group specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
MobGroup group = MobGroupTable.getInstance().getGroup(groupId);
|
||||
|
||||
if (group == null)
|
||||
{
|
||||
activeChar.sendMessage("Invalid group specified.");
|
||||
return;
|
||||
}
|
||||
|
||||
group.teleportGroup(activeChar);
|
||||
}
|
||||
|
||||
private void showGroupList(L2PcInstance activeChar)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
170
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMonsterRace.java
vendored
Normal file
170
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminMonsterRace.java
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.MonsterRace;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.DeleteObject;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MonRaceInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - invul = turns invulnerability on/off
|
||||
* @version $Revision: 1.1.6.4 $ $Date: 2007/07/31 10:06:00 $
|
||||
*/
|
||||
public class AdminMonsterRace implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminMonsterRace.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_mons"
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
int[][] codes =
|
||||
{
|
||||
{
|
||||
-1,
|
||||
0
|
||||
},
|
||||
{
|
||||
0,
|
||||
15322
|
||||
},
|
||||
{
|
||||
13765,
|
||||
-1
|
||||
},
|
||||
{
|
||||
-1,
|
||||
0
|
||||
}
|
||||
};
|
||||
MonsterRace race = MonsterRace.getInstance();
|
||||
|
||||
if (state == -1)
|
||||
{
|
||||
state++;
|
||||
race.newRace();
|
||||
race.newSpeeds();
|
||||
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++;
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.THEY_RE_OFF);
|
||||
sm.addInt(0);
|
||||
activeChar.sendPacket(sm);
|
||||
PlaySound SRace = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
|
||||
activeChar.sendPacket(SRace);
|
||||
activeChar.broadcastPacket(SRace);
|
||||
PlaySound SRace2 = new PlaySound(0, "ItemSound2.race_start", 1, 121209259, 12125, 182487, -3559);
|
||||
activeChar.sendPacket(SRace2);
|
||||
activeChar.broadcastPacket(SRace2);
|
||||
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++) { //_log.info("Adding "+speeds1[i][j] +" and "+ speeds2[i][j]); speed[i] += (speeds1[i][j]*1);// + (speeds2[i][j]*1); } _log.info("Total speed for "+(i+1)+" = "+speed[i]); }
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
213
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPCBangPoints.java
vendored
Normal file
213
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPCBangPoints.java
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExPCCafePointInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin PC Points manage admin commands.<br>
|
||||
* Based on AdminPrimePoints by St3eT.
|
||||
*/
|
||||
public final class AdminPCBangPoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_pcbangpoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_pcbangpoints"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
try
|
||||
{
|
||||
value = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("Invalid Value!");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "set":
|
||||
{
|
||||
if (value > Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("You cannot set more than " + Config.PC_BANG_MAX_POINTS + " PC points!");
|
||||
return false;
|
||||
}
|
||||
if (value < 0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
|
||||
target.setPcBangPoints(value);
|
||||
target.sendMessage("Admin set your PC point(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " PC point(s) to player " + target.getName());
|
||||
target.sendPacket(new ExPCCafePointInfo(value, value, 1));
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPcBangPoints() == Config.PC_BANG_MAX_POINTS)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min((target.getPcBangPoints() + value), Config.PC_BANG_MAX_POINTS);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Config.PC_BANG_MAX_POINTS;
|
||||
}
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPcBangPoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of PC points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int pcBangCount = Math.max(target.getPcBangPoints() - value, 0);
|
||||
target.setPcBangPoints(pcBangCount);
|
||||
target.sendMessage("Admin decreased your PC point(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased PC point(s) of " + target.getName() + " by " + value);
|
||||
target.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
break;
|
||||
}
|
||||
case "rewardOnline":
|
||||
{
|
||||
int range = 0;
|
||||
try
|
||||
{
|
||||
range = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (range <= 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getPlayers(), value);
|
||||
activeChar.sendMessage("You increased PC point(s) of all online players (" + count + ") by " + value + ".");
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
final int count = increaseForAll(activeChar.getKnownList().getKnownPlayers().values(), value);
|
||||
activeChar.sendMessage("You increased PC point(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPcBangPoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int pcBangCount = Math.min((temp.getPcBangPoints() + value), Integer.MAX_VALUE);
|
||||
if (pcBangCount < 0)
|
||||
{
|
||||
pcBangCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPcBangPoints(pcBangCount);
|
||||
temp.sendMessage("Admin increased your PC point(s) by " + value + "!");
|
||||
temp.sendPacket(new ExPCCafePointInfo(pcBangCount, value, 1));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private L2PcInstance getTarget(L2PcInstance activeChar)
|
||||
{
|
||||
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
}
|
||||
|
||||
private void showMenuHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
final int points = target.getPcBangPoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/pcbang.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
627
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPForge.java
vendored
Normal file
627
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPForge.java
vendored
Normal file
@@ -0,0 +1,627 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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 commons.mmocore.NioNetStringBuffer;
|
||||
|
||||
import com.l2jserver.gameserver.GameServer;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2BoatInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AdminForgePacket;
|
||||
import com.l2jserver.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())
|
||||
{
|
||||
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.parseLong(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(), "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;
|
||||
|
||||
String editorTemplate = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/pforge/inc/editor.htm");
|
||||
|
||||
if (editorTemplate != null)
|
||||
{
|
||||
StringBuilder singleCharSequence = new StringBuilder(1);
|
||||
singleCharSequence.append(' ');
|
||||
|
||||
for (int chIdx = 0; chIdx < format.length(); ++chIdx)
|
||||
{
|
||||
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(valuesHtml));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_forge"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_forge_values "))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // skip command token
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
showValuesUsage(activeChar);
|
||||
return false;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // skip command token
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
showSendUsage(activeChar, null, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
String method = st.nextToken();
|
||||
if (!validateMethod(method))
|
||||
{
|
||||
activeChar.sendMessage("Invalid method!");
|
||||
showSendUsage(activeChar, null, null);
|
||||
return false;
|
||||
}
|
||||
|
||||
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 = ((L2Playable) 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 = String.valueOf(((L2Character) target).getTitle());
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
break;
|
||||
case "$tname":
|
||||
target = activeChar.getTarget();
|
||||
if (target != null)
|
||||
{
|
||||
value = String.valueOf(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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
103
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPathNode.java
vendored
Normal file
103
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPathNode.java
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.pathfinding.AbstractNodeLoc;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
List<AbstractNodeLoc> path = PathFinding.getInstance().findPath(activeChar.getX(), activeChar.getY(), (short) activeChar.getZ(), activeChar.getTarget().getX(), activeChar.getTarget().getY(), (short) activeChar.getTarget().getZ(), activeChar.getInstanceId(), true);
|
||||
if (path == null)
|
||||
{
|
||||
activeChar.sendMessage("No Route!");
|
||||
return true;
|
||||
}
|
||||
for (AbstractNodeLoc a : path)
|
||||
{
|
||||
activeChar.sendMessage("x:" + a.getX() + " y:" + a.getY() + " z:" + a.getZ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("No Target!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
129
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPcCondOverride.java
vendored
Normal file
129
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPcCondOverride.java
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.PcCondOverride;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Handler provides ability to override server's conditions for admin.
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public class AdminPcCondOverride implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"admin_exceptions",
|
||||
"admin_set_exception",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
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(), "html/admin/cond_override.htm");
|
||||
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())
|
||||
{
|
||||
String token = st.nextToken();
|
||||
if (Util.isDigit(token))
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
132
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPetition.java
vendored
Normal file
132
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPetition.java
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.PetitionManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
L2Object targetChar = activeChar.getTarget();
|
||||
if ((targetChar == null) || !(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
L2PcInstance targetPlayer = (L2PcInstance) targetChar;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
218
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPledge.java
vendored
Normal file
218
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPledge.java
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.sql.impl.ClanTable;
|
||||
import com.l2jserver.gameserver.enums.UserInfoType;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.GMViewPledgeInfo;
|
||||
import com.l2jserver.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())
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
202
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPolymorph.java
vendored
Normal file
202
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPolymorph.java
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SetupGauge;
|
||||
import com.l2jserver.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"))
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
((L2Character) obj).stopTransformation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_transform"))
|
||||
{
|
||||
final L2Object obj = activeChar.getTarget();
|
||||
if ((obj == null) || !obj.isPlayer())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final L2PcInstance player = obj.getActingPlayer();
|
||||
if (activeChar.isSitting())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_SITTING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
if (!command.contains(" "))
|
||||
{
|
||||
player.untransform();
|
||||
return true;
|
||||
}
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isInWater())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_POLYMORPH_INTO_THE_DESIRED_FORM_IN_WATER);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (player.isFlyingMounted() || player.isMounted())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_CANNOT_TRANSFORM_WHILE_RIDING_A_PET);
|
||||
return false;
|
||||
}
|
||||
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length != 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //transform <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int id = Integer.parseInt(parts[1]);
|
||||
if (!TransformData.getInstance().transformPlayer(id, player))
|
||||
{
|
||||
player.sendMessage("Unknown transformation ID: " + id);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_polymorph"))
|
||||
{
|
||||
final String[] parts = command.split(" ");
|
||||
if ((parts.length < 2) || !Util.isDigit(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //polymorph [type] <id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (parts.length > 2)
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[2], parts[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
doPolymorph(activeChar, activeChar.getTarget(), parts[1], "npc");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpolymorph"))
|
||||
{
|
||||
doUnPolymorph(activeChar, activeChar.getTarget());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Polymorph a creature.
|
||||
* @param activeChar the active Game Master
|
||||
* @param obj the target
|
||||
* @param id the polymorph ID
|
||||
* @param type the polymorph type
|
||||
*/
|
||||
private static void doPolymorph(L2PcInstance activeChar, L2Object obj, String id, String type)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
obj.getPoly().setPolyInfo(type, id);
|
||||
// animation
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
L2Character Char = (L2Character) obj;
|
||||
MagicSkillUse msk = new MagicSkillUse(Char, 1008, 1, 4000, 0);
|
||||
Char.broadcastPacket(msk);
|
||||
SetupGauge sg = new SetupGauge(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
166
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPremium.java
vendored
Normal file
166
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPremium.java
vendored
Normal file
@@ -0,0 +1,166 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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 com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.PremiumManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
String val = command.substring(19);
|
||||
addPremiumStatus(activeChar, 1, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_add2"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(19);
|
||||
addPremiumStatus(activeChar, 2, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_add3"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(19);
|
||||
addPremiumStatus(activeChar, 3, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_info"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(19);
|
||||
viewPremiumInfo(activeChar, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_premium_remove"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(21);
|
||||
removePremium(activeChar, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Please enter a valid account name.");
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "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().updatePremiumData(months, accountName);
|
||||
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
final long endDate = PremiumManager.getInstance().getPremiumEndDate(accountName);
|
||||
admin.sendMessage("Account " + accountName + " will now have premium status until " + String.valueOf(format.format(endDate)) + ".");
|
||||
}
|
||||
|
||||
private void viewPremiumInfo(L2PcInstance admin, String accountName)
|
||||
{
|
||||
if (PremiumManager.getInstance().getPremiumEndDate(accountName) > 0)
|
||||
{
|
||||
final SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
|
||||
final long endDate = PremiumManager.getInstance().getPremiumEndDate(accountName);
|
||||
admin.sendMessage("Account " + accountName + " has premium status until " + String.valueOf(format.format(endDate)) + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
admin.sendMessage("Account " + accountName + " has no premium status.");
|
||||
}
|
||||
}
|
||||
|
||||
private void removePremium(L2PcInstance admin, String accountName)
|
||||
{
|
||||
if (PremiumManager.getInstance().getPremiumEndDate(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;
|
||||
}
|
||||
}
|
||||
196
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPrimePoints.java
vendored
Normal file
196
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPrimePoints.java
vendored
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Admin Prime Points manage admin commands.
|
||||
* @author St3eT
|
||||
*/
|
||||
public final class AdminPrimePoints implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_primepoints",
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
|
||||
if (actualCommand.equals("admin_primepoints"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
final String action = st.nextToken();
|
||||
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
if ((target == null) || !st.hasMoreTokens())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int value = 0;
|
||||
try
|
||||
{
|
||||
value = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage("Invalid Value!");
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "set":
|
||||
{
|
||||
target.setPrimePoints(value);
|
||||
target.sendMessage("Admin set your NCoin(s) to " + value + "!");
|
||||
activeChar.sendMessage("You set " + value + " NCoin(s) to player " + target.getName());
|
||||
break;
|
||||
}
|
||||
case "increase":
|
||||
{
|
||||
if (target.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have max count of NCoins!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int primeCount = Math.min((target.getPrimePoints() + value), Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin increased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You increased NCoin(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "decrease":
|
||||
{
|
||||
if (target.getPrimePoints() == 0)
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
activeChar.sendMessage(target.getName() + " already have min count of NCoins!");
|
||||
return false;
|
||||
}
|
||||
|
||||
final int primeCount = Math.max(target.getPrimePoints() - value, 0);
|
||||
target.setPrimePoints(primeCount);
|
||||
target.sendMessage("Admin decreased your NCoin(s) by " + value + "!");
|
||||
activeChar.sendMessage("You decreased NCoin(s) of " + target.getName() + " by " + value);
|
||||
break;
|
||||
}
|
||||
case "rewardOnline":
|
||||
{
|
||||
int range = 0;
|
||||
try
|
||||
{
|
||||
range = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
if (range <= 0)
|
||||
{
|
||||
final int count = increaseForAll(L2World.getInstance().getPlayers(), value);
|
||||
activeChar.sendMessage("You increased NCoin(s) of all online players (" + count + ") by " + value + ".");
|
||||
}
|
||||
else if (range > 0)
|
||||
{
|
||||
final int count = increaseForAll(activeChar.getKnownList().getKnownPlayers().values(), value);
|
||||
activeChar.sendMessage("You increased NCoin(s) of all players (" + count + ") in range " + range + " by " + value + ".");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
showMenuHtml(activeChar);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int increaseForAll(Collection<L2PcInstance> playerList, int value)
|
||||
{
|
||||
int counter = 0;
|
||||
for (L2PcInstance temp : playerList)
|
||||
{
|
||||
if ((temp != null) && (temp.isOnlineInt() == 1))
|
||||
{
|
||||
if (temp.getPrimePoints() == Integer.MAX_VALUE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int primeCount = Math.min((temp.getPrimePoints() + value), Integer.MAX_VALUE);
|
||||
if (primeCount < 0)
|
||||
{
|
||||
primeCount = Integer.MAX_VALUE;
|
||||
}
|
||||
temp.setPrimePoints(primeCount);
|
||||
temp.sendMessage("Admin increased your NCoin(s) by " + value + "!");
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
private L2PcInstance getTarget(L2PcInstance activeChar)
|
||||
{
|
||||
return ((activeChar.getTarget() != null) && (activeChar.getTarget().getActingPlayer() != null)) ? activeChar.getTarget().getActingPlayer() : activeChar;
|
||||
}
|
||||
|
||||
private void showMenuHtml(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
|
||||
final L2PcInstance target = getTarget(activeChar);
|
||||
final int points = target.getPrimePoints();
|
||||
html.setHtml(HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "html/admin/primepoints.htm"));
|
||||
html.replace("%points%", Util.formatAdena(points));
|
||||
html.replace("%targetName%", target.getName());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
405
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPunishment.java
vendored
Normal file
405
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminPunishment.java
vendored
Normal file
@@ -0,0 +1,405 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CharNameTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.PunishmentManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
|
||||
import com.l2jserver.gameserver.model.punishment.PunishmentTask;
|
||||
import com.l2jserver.gameserver.model.punishment.PunishmentType;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
import com.l2jserver.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(), "html/admin/punishment.htm");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%affects%", Util.implode(PunishmentAffect.values(), ";"));
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment.htm is missing");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final String subcmd = st.nextToken();
|
||||
switch (subcmd)
|
||||
{
|
||||
case "info":
|
||||
{
|
||||
String key = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
String af = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
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(), "html/admin/punishment-info.htm");
|
||||
if (content != null)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (PunishmentType type : PunishmentType.values())
|
||||
{
|
||||
if (PunishmentManager.getInstance().hasPunishment(key, affect, type))
|
||||
{
|
||||
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%", Util.implode(PunishmentAffect.values(), ";"));
|
||||
content = content.replaceAll("%affect_type%", affect.name());
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment-info.htm is missing");
|
||||
}
|
||||
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(), "html/admin/punishment-player.htm");
|
||||
if (content != null)
|
||||
{
|
||||
content = content.replaceAll("%player_name%", target.getName());
|
||||
content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
|
||||
content = content.replaceAll("%acc%", target.getAccountName());
|
||||
content = content.replaceAll("%char%", target.getName());
|
||||
content = content.replaceAll("%ip%", target.getIPAddress());
|
||||
activeChar.sendPacket(new NpcHtmlMessage(0, 1, content));
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.log(Level.WARNING, getClass().getSimpleName() + ": html/admin/punishment-player.htm is missing");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "admin_punishment_add":
|
||||
{
|
||||
// Add new punishment
|
||||
String key = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
String af = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
String t = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
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("<", "<");
|
||||
reason = reason.replace(">", ">");
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
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;
|
||||
String af = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
String t = st.hasMoreTokens() ? st.nextToken() : null;
|
||||
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 final String findCharId(String key)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
338
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminQuest.java
vendored
Normal file
338
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminQuest.java
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventType;
|
||||
import com.l2jserver.gameserver.model.events.ListenerRegisterType;
|
||||
import com.l2jserver.gameserver.model.events.listeners.AbstractEventListener;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.model.quest.QuestTimer;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
public class AdminQuest implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_quest_reload",
|
||||
"admin_script_load",
|
||||
"admin_script_unload",
|
||||
"admin_show_quests",
|
||||
"admin_quest_info"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// syntax will either be:
|
||||
// //quest_reload <id>
|
||||
// //quest_reload <questName>
|
||||
// The questName MUST start with a non-numeric character for this to work,
|
||||
// regardless which of the two formats is used.
|
||||
// Example: //quest_reload orc_occupation_change_1
|
||||
// Example: //quest_reload chests
|
||||
// Example: //quest_reload SagasSuperclass
|
||||
// Example: //quest_reload 12
|
||||
if (command.startsWith("admin_quest_reload"))
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //quest_reload <questFolder>.<questSubFolders...>.questName> or //quest_reload <id>");
|
||||
}
|
||||
else
|
||||
{
|
||||
// try the first param as id
|
||||
try
|
||||
{
|
||||
int questId = Integer.parseInt(parts[1]);
|
||||
if (QuestManager.getInstance().reload(questId))
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Failed");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
if (QuestManager.getInstance().reload(parts[1]))
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Quest Reloaded Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// script load should NOT be used in place of reload. If a script is already loaded
|
||||
// successfully, quest_reload ought to be used. The script_load command should only
|
||||
// be used for scripts that failed to load altogether (eg. due to errors) or that
|
||||
// did not at all exist during server boot. Using script_load to re-load a previously
|
||||
// loaded script may cause unpredictable script flow, minor loss of data, and more.
|
||||
// This provides a way to load new scripts without having to reboot the server.
|
||||
else if (command.startsWith("admin_script_load"))
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
// activeChar.sendMessage("Example: //script_load <questFolder>/<questSubFolders...>/<filename>.<ext> ");
|
||||
activeChar.sendMessage("Example: //script_load quests/SagasSuperclass/__init__.py");
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, parts[1]);
|
||||
// Trying to reload by script name.
|
||||
if (!file.exists())
|
||||
{
|
||||
Quest quest = QuestManager.getInstance().getQuest(parts[1]);
|
||||
if (quest != null)
|
||||
{
|
||||
file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, quest.getClass().getName().replaceAll("\\.", "/") + ".java");
|
||||
}
|
||||
}
|
||||
|
||||
// Reloading by full path
|
||||
if (file.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
|
||||
// This part should be called only when the script is successfully loaded.
|
||||
activeChar.sendMessage("Script Successfully Loaded.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1]);
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + parts[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("File Not Found: " + parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (command.startsWith("admin_script_unload"))
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
activeChar.sendMessage("Example: //script_unload questName/questId");
|
||||
}
|
||||
else
|
||||
{
|
||||
Quest q = Util.isDigit(parts[1]) ? QuestManager.getInstance().getQuest(Integer.parseInt(parts[1])) : QuestManager.getInstance().getQuest(parts[1]);
|
||||
|
||||
if (q != null)
|
||||
{
|
||||
if (q.unload())
|
||||
{
|
||||
activeChar.sendMessage("Script Successfully Unloaded [" + q.getName() + "/" + q.getId() + "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Failed unloading [" + q.getName() + "/" + q.getId() + "].");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The quest [" + parts[1] + "] was not found!.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_show_quests"))
|
||||
{
|
||||
if (activeChar.getTarget() == null)
|
||||
{
|
||||
activeChar.sendMessage("Get a target first.");
|
||||
}
|
||||
else if (!activeChar.getTarget().isCharacter())
|
||||
{
|
||||
activeChar.sendMessage("Invalid Target.");
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Character character = (L2Character) activeChar.getTarget();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final Set<String> questNames = new TreeSet<>();
|
||||
for (EventType type : EventType.values())
|
||||
{
|
||||
for (AbstractEventListener listener : character.getListeners(type))
|
||||
{
|
||||
if (listener.getOwner() instanceof Quest)
|
||||
{
|
||||
final Quest quest = (Quest) listener.getOwner();
|
||||
if (questNames.contains(quest.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
sb.append("<tr><td colspan=\"4\"><font color=\"LEVEL\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></font></td></tr>");
|
||||
questNames.add(quest.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%objid%", character.getObjectId());
|
||||
msg.replace("%questName%", "");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_quest_info "))
|
||||
{
|
||||
final String questName = command.substring("admin_quest_info ".length());
|
||||
final Quest quest = QuestManager.getInstance().getQuest(questName);
|
||||
String events = "", npcs = "", items = "", timers = "";
|
||||
int counter = 0;
|
||||
if (quest == null)
|
||||
{
|
||||
activeChar.sendMessage("Couldn't find quest or script with name " + questName + " !");
|
||||
return false;
|
||||
}
|
||||
|
||||
final Set<EventType> listenerTypes = new TreeSet<>();
|
||||
for (AbstractEventListener listener : quest.getListeners())
|
||||
{
|
||||
if (!listenerTypes.contains(listener.getType()))
|
||||
{
|
||||
events += ", " + listener.getType().name();
|
||||
listenerTypes.add(listener.getType());
|
||||
counter++;
|
||||
}
|
||||
if (counter > 10)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final Set<Integer> npcIds = new TreeSet<>(quest.getRegisteredIds(ListenerRegisterType.NPC));
|
||||
for (int npcId : npcIds)
|
||||
{
|
||||
npcs += ", " + npcId;
|
||||
counter++;
|
||||
if (counter > 50)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!events.isEmpty())
|
||||
{
|
||||
events = listenerTypes.size() + ": " + events.substring(2);
|
||||
}
|
||||
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
npcs = npcIds.size() + ": " + npcs.substring(2);
|
||||
}
|
||||
|
||||
if (quest.getRegisteredItemIds() != null)
|
||||
{
|
||||
for (int itemId : quest.getRegisteredItemIds())
|
||||
{
|
||||
items += ", " + itemId;
|
||||
counter++;
|
||||
if (counter > 20)
|
||||
{
|
||||
counter = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
items = quest.getRegisteredItemIds().length + ":" + items.substring(2);
|
||||
}
|
||||
|
||||
for (List<QuestTimer> list : quest.getQuestTimers().values())
|
||||
{
|
||||
for (QuestTimer timer : list)
|
||||
{
|
||||
timers += "<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">" + timer.getName() + ":</font> <font color=00FF00>Active: " + timer.getIsActive() + " Repeatable: " + timer.getIsRepeating() + " Player: " + timer.getPlayer() + " Npc: " + timer.getNpc() + "</font></td></tr></table></td></tr>";
|
||||
counter++;
|
||||
if (counter > 10)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">ID:</font> <font color=00FF00>" + quest.getId() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Name:</font> <font color=00FF00>" + quest.getName() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Descr:</font> <font color=00FF00>" + quest.getDescr() + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Path:</font> <font color=00FF00>" + quest.getClass().getName().substring(0, quest.getClass().getName().lastIndexOf('.')).replaceAll("\\.", "/") + "</font></td></tr></table></td></tr>");
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Events:</font> <font color=00FF00>" + events + "</font></td></tr></table></td></tr>");
|
||||
if (!npcs.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">NPCs:</font> <font color=00FF00>" + npcs + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!items.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Items:</font> <font color=00FF00>" + items + "</font></td></tr></table></td></tr>");
|
||||
}
|
||||
if (!timers.isEmpty())
|
||||
{
|
||||
sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Timers:</font> <font color=00FF00></font></td></tr></table></td></tr>");
|
||||
sb.append(timers);
|
||||
}
|
||||
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/admin/npc-quests.htm");
|
||||
msg.replace("%quests%", sb.toString());
|
||||
msg.replace("%questName%", "<table><tr><td width=\"50\" align=\"left\"><a action=\"bypass -h admin_script_load " + quest.getName() + "\">Reload</a></td> <td width=\"150\" align=\"center\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></td> <td width=\"50\" align=\"right\"><a action=\"bypass -h admin_script_unload " + quest.getName() + "\">Unload</a></tr></td></table>");
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
297
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminReload.java
vendored
Normal file
297
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminReload.java
vendored
Normal file
@@ -0,0 +1,297 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.data.sql.impl.CrestTable;
|
||||
import com.l2jserver.gameserver.data.sql.impl.TeleportLocationTable;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AbilityPointsData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AppearanceItemData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.DoorData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.EnchantItemData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.EnchantItemGroupsData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.ItemCrystalizationData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.MultisellData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.PrimeShopData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.TeleportersData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.instancemanager.WalkingManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminReload implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_reload"
|
||||
};
|
||||
|
||||
private static final String RELOAD_USAGE = "Usage: //reload <config|access|npc|quest [quest_id|quest_name]|walker|htm[l] [file|directory]|multisell|buylist|teleport|skill|item|door|effect|handler|enchant>";
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
if (actualCommand.equalsIgnoreCase("admin_reload"))
|
||||
{
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "reload.htm");
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
final String type = st.nextToken();
|
||||
switch (type.toLowerCase())
|
||||
{
|
||||
case "config":
|
||||
{
|
||||
Config.load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Configs.");
|
||||
break;
|
||||
}
|
||||
case "access":
|
||||
{
|
||||
AdminData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Access.");
|
||||
break;
|
||||
}
|
||||
case "npc":
|
||||
{
|
||||
NpcData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Npcs.");
|
||||
break;
|
||||
}
|
||||
case "quest":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
String value = st.nextToken();
|
||||
if (!Util.isDigit(value))
|
||||
{
|
||||
QuestManager.getInstance().reload(value);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest Name:" + value + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
final int questId = Integer.parseInt(value);
|
||||
QuestManager.getInstance().reload(questId);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quest ID:" + questId + ".");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
activeChar.sendMessage("All scripts have been reloaded.");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Quests.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "walker":
|
||||
{
|
||||
WalkingManager.getInstance().load();
|
||||
activeChar.sendMessage("All walkers have been reloaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Walkers.");
|
||||
break;
|
||||
}
|
||||
case "htm":
|
||||
case "html":
|
||||
{
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
final String path = st.nextToken();
|
||||
final File file = new File(Config.DATAPACK_ROOT, "html/" + path);
|
||||
if (file.exists())
|
||||
{
|
||||
HtmCache.getInstance().reload(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htm File:" + file.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("File or Directory does not exist.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HtmCache.getInstance().reload();
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded");
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Htms.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "multisell":
|
||||
{
|
||||
MultisellData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Multisells.");
|
||||
break;
|
||||
}
|
||||
case "buylist":
|
||||
{
|
||||
BuyListData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Buylists.");
|
||||
break;
|
||||
}
|
||||
case "teleport":
|
||||
{
|
||||
TeleportLocationTable.getInstance().reloadAll();
|
||||
TeleportersData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Teleports.");
|
||||
break;
|
||||
}
|
||||
case "skill":
|
||||
{
|
||||
SkillData.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Skills.");
|
||||
break;
|
||||
}
|
||||
case "item":
|
||||
{
|
||||
ItemTable.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Items.");
|
||||
break;
|
||||
}
|
||||
case "door":
|
||||
{
|
||||
DoorData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Doors.");
|
||||
break;
|
||||
}
|
||||
case "zone":
|
||||
{
|
||||
ZoneManager.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Zones.");
|
||||
break;
|
||||
}
|
||||
case "cw":
|
||||
{
|
||||
CursedWeaponsManager.getInstance().reload();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Cursed Weapons.");
|
||||
break;
|
||||
}
|
||||
case "crest":
|
||||
{
|
||||
CrestTable.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Crests.");
|
||||
break;
|
||||
}
|
||||
case "effect":
|
||||
{
|
||||
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/EffectMasterHandler.java");
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Effects.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
activeChar.sendMessage("There was an error while loading handlers.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "handler":
|
||||
{
|
||||
final File file = new File(L2ScriptEngineManager.SCRIPT_FOLDER, "handlers/MasterHandler.java");
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded Handlers.");
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().reportScriptFileError(file, e);
|
||||
activeChar.sendMessage("There was an error while loading handlers.");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "enchant":
|
||||
{
|
||||
EnchantItemGroupsData.getInstance().load();
|
||||
EnchantItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item enchanting data.");
|
||||
break;
|
||||
}
|
||||
case "transform":
|
||||
{
|
||||
TransformData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded transform data.");
|
||||
break;
|
||||
}
|
||||
case "crystalizable":
|
||||
{
|
||||
ItemCrystalizationData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded item crystalization data.");
|
||||
break;
|
||||
}
|
||||
case "primeshop":
|
||||
{
|
||||
PrimeShopData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded L2 Store data.");
|
||||
break;
|
||||
}
|
||||
case "ability":
|
||||
{
|
||||
AbilityPointsData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded ability points data.");
|
||||
break;
|
||||
}
|
||||
case "appearance":
|
||||
{
|
||||
AppearanceItemData.getInstance().load();
|
||||
AdminData.getInstance().broadcastMessageToGMs(activeChar.getName() + ": Reloaded appearance item data.");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
activeChar.sendMessage(RELOAD_USAGE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("WARNING: There are several known issues regarding this feature. Reloading server data during runtime is STRONGLY NOT RECOMMENDED for live servers, just for developing environments.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
109
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRepairChar.java
vendored
Normal file
109
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRepairChar.java
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = "UPDATE characters SET x=-84318, y=244579, z=-3730 WHERE char_name=?";
|
||||
try (Connection con = L2DatabaseFactory.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]);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
197
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRes.java
vendored
Normal file
197
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRes.java
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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.
|
||||
L2PcInstance plyr = L2World.getInstance().getPlayer(resParam);
|
||||
|
||||
if (plyr != null)
|
||||
{
|
||||
obj = plyr;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, check if the param was a radius.
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(resParam);
|
||||
|
||||
for (L2PcInstance knownPlayer : activeChar.getKnownList().getKnownPlayersInRadius(radius))
|
||||
{
|
||||
doResurrect(knownPlayer);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Resurrected all players within a " + radius + " unit radius.");
|
||||
return;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid player name or radius.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj == null)
|
||||
{
|
||||
obj = activeChar;
|
||||
}
|
||||
|
||||
if (obj instanceof L2ControllableMobInstance)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") resurrected character " + obj.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar)
|
||||
{
|
||||
handleNonPlayerRes(activeChar, "");
|
||||
}
|
||||
|
||||
private void handleNonPlayerRes(L2PcInstance activeChar, String radiusStr)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
|
||||
try
|
||||
{
|
||||
int radius = 0;
|
||||
|
||||
if (!radiusStr.isEmpty())
|
||||
{
|
||||
radius = Integer.parseInt(radiusStr);
|
||||
|
||||
for (L2Character knownChar : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
|
||||
{
|
||||
doResurrect(knownChar);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Resurrected all non-players within a " + radius + " unit radius.");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Enter a valid radius.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((obj instanceof L2PcInstance) || (obj instanceof L2ControllableMobInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
doResurrect((L2Character) obj);
|
||||
}
|
||||
|
||||
private void doResurrect(L2Character targetChar)
|
||||
{
|
||||
if (!targetChar.isDead())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is a player, then restore the XP lost on death.
|
||||
if (targetChar instanceof L2PcInstance)
|
||||
{
|
||||
((L2PcInstance) targetChar).restoreExp(100.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
DecayTaskManager.getInstance().cancel(targetChar);
|
||||
}
|
||||
|
||||
targetChar.doRevive();
|
||||
}
|
||||
}
|
||||
154
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRide.java
vendored
Normal file
154
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminRide.java
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.TransformData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
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() || player.isInStance())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformData.getInstance().transformPlayer(PURPLE_MANED_HORSE_TRANSFORMATION_ID, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_bike")) // handled using transformation
|
||||
{
|
||||
if (player.isTransformed() || player.isInStance())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_ALREADY_POLYMORPHED_AND_CANNOT_POLYMORPH_AGAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformData.getInstance().transformPlayer(JET_BIKE_TRANSFORMATION_ID, player);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Command '" + command + "' not recognized");
|
||||
return false;
|
||||
}
|
||||
|
||||
player.mount(_petRideId, 0, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_unride"))
|
||||
{
|
||||
if (player.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
|
||||
{
|
||||
player.untransform();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
152
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminScan.java
vendored
Normal file
152
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminScan.java
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* @author NosBit
|
||||
*/
|
||||
public class AdminScan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_scan",
|
||||
"admin_deleteNpcByObjectId"
|
||||
};
|
||||
|
||||
private static final int DEFAULT_RADIUS = 500;
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
final StringTokenizer st = new StringTokenizer(command, " ");
|
||||
final String actualCommand = st.nextToken();
|
||||
switch (actualCommand.toLowerCase())
|
||||
{
|
||||
case "admin_scan":
|
||||
{
|
||||
int radius = DEFAULT_RADIUS;
|
||||
if (st.hasMoreElements())
|
||||
{
|
||||
try
|
||||
{
|
||||
radius = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //scan [radius]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sendNpcList(activeChar, radius);
|
||||
break;
|
||||
}
|
||||
case "admin_deletenpcbyobjectid":
|
||||
{
|
||||
if (!st.hasMoreElements())
|
||||
{
|
||||
activeChar.sendMessage("Usage: //deletenpcbyobjectid <object_id>");
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int objectId = Integer.parseInt(st.nextToken());
|
||||
|
||||
final L2Object target = L2World.getInstance().findObject(objectId);
|
||||
final L2Npc npc = target instanceof L2Npc ? (L2Npc) target : null;
|
||||
if (npc == null)
|
||||
{
|
||||
activeChar.sendMessage("NPC does not exist or object_id does not belong to an NPC");
|
||||
return false;
|
||||
}
|
||||
|
||||
npc.deleteMe();
|
||||
|
||||
final L2Spawn spawn = npc.getSpawn();
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
}
|
||||
|
||||
activeChar.sendMessage(npc.getName() + " have been deleted.");
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("object_id must be a number.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sendNpcList(activeChar, DEFAULT_RADIUS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendNpcList(L2PcInstance activeChar, int radius)
|
||||
{
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage();
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/admin/scan.htm");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (L2Character character : activeChar.getKnownList().getKnownCharactersInRadius(radius))
|
||||
{
|
||||
if (character instanceof L2Npc)
|
||||
{
|
||||
sb.append("<tr>");
|
||||
sb.append("<td width=\"54\">" + character.getId() + "</td>");
|
||||
sb.append("<td width=\"54\">" + character.getName() + "</td>");
|
||||
sb.append("<td width=\"54\">" + Math.round(activeChar.calculateDistance(character, false, false)) + "</td>");
|
||||
sb.append("<td width=\"54\"><a action=\"bypass -h admin_deleteNpcByObjectId " + character.getObjectId() + "\"><font color=\"LEVEL\">Delete</font></a></td>");
|
||||
sb.append("<td width=\"54\"><a action=\"bypass -h admin_move_to " + character.getX() + " " + character.getY() + " " + character.getZ() + "\"><font color=\"LEVEL\">Go to</font></a></td>");
|
||||
sb.append("</tr>");
|
||||
}
|
||||
}
|
||||
html.replace("%data%", sb.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
174
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminServerInfo.java
vendored
Normal file
174
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminServerInfo.java
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GameServer;
|
||||
import com.l2jserver.gameserver.GameTimeController;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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(), "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);
|
||||
final long minutes = TimeUnit.MILLISECONDS.toMinutes(time);
|
||||
|
||||
return days + " Days, " + hours + " Hours, " + minutes + " 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().getAllPlayersCount();
|
||||
}
|
||||
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 : L2World.getInstance().getAllGMs())
|
||||
{
|
||||
if ((gm != null) && gm.isOnline() && (gm.getClient() != null) && !gm.getClient().isDetached())
|
||||
{
|
||||
onlineGMcount++;
|
||||
}
|
||||
}
|
||||
return onlineGMcount;
|
||||
}
|
||||
case "ALL_REAL":
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
100
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShop.java
vendored
Normal file
100
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShop.java
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.BuyListData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.buylist.L2BuyList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.BuyList;
|
||||
import com.l2jserver.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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
388
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShowQuests.java
vendored
Normal file
388
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShowQuests.java
vendored
Normal file
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.model.quest.QuestState;
|
||||
import com.l2jserver.gameserver.model.quest.State;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowQuestMark;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.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)
|
||||
{
|
||||
String[] cmdParams = command.split(" ");
|
||||
L2PcInstance target = null;
|
||||
L2Object targetObject = null;
|
||||
String[] val = new String[4];
|
||||
val[0] = null;
|
||||
|
||||
if (cmdParams.length > 1)
|
||||
{
|
||||
target = L2World.getInstance().getPlayer(cmdParams[1]);
|
||||
if (cmdParams.length > 2)
|
||||
{
|
||||
if (cmdParams[2].equals("0"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Start";
|
||||
}
|
||||
if (cmdParams[2].equals("1"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Started";
|
||||
}
|
||||
if (cmdParams[2].equals("2"))
|
||||
{
|
||||
val[0] = "var";
|
||||
val[1] = "Completed";
|
||||
}
|
||||
if (cmdParams[2].equals("3"))
|
||||
{
|
||||
val[0] = "full";
|
||||
}
|
||||
if (cmdParams[2].indexOf("_") != -1)
|
||||
{
|
||||
val[0] = "name";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
if (cmdParams.length > 3)
|
||||
{
|
||||
if (cmdParams[3].equals("custom"))
|
||||
{
|
||||
val[0] = "custom";
|
||||
val[1] = cmdParams[2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targetObject = activeChar.getTarget();
|
||||
|
||||
if ((targetObject != null) && targetObject.isPlayer())
|
||||
{
|
||||
target = targetObject.getActingPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_charquestmenu"))
|
||||
{
|
||||
if (val[0] != null)
|
||||
{
|
||||
showQuestMenu(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
showFirstQuestMenu(target, activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setcharquest"))
|
||||
{
|
||||
if (cmdParams.length >= 5)
|
||||
{
|
||||
val[0] = cmdParams[2];
|
||||
val[1] = cmdParams[3];
|
||||
val[2] = cmdParams[4];
|
||||
if (cmdParams.length == 6)
|
||||
{
|
||||
val[3] = cmdParams[5];
|
||||
}
|
||||
setQuestVar(target, activeChar, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void showFirstQuestMenu(L2PcInstance target, L2PcInstance actor)
|
||||
{
|
||||
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();
|
||||
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 = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
int ID = target.getObjectId();
|
||||
|
||||
StringBuilder replyMSG = new StringBuilder("<html><body>");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
|
||||
switch (val[0])
|
||||
{
|
||||
case "full":
|
||||
{
|
||||
replyMSG.append("<table width=250><tr><td>Full Quest List for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")</td></tr>");
|
||||
req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' AND var='<state>' ORDER by name");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
|
||||
}
|
||||
replyMSG.append("</table></body></html>");
|
||||
break;
|
||||
}
|
||||
case "name":
|
||||
{
|
||||
QuestState qs = target.getQuestState(val[1]);
|
||||
String state = (qs != null) ? _states[qs.getState()] : "CREATED";
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + val[1] + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + val[1] + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
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;
|
||||
int qnumber = Integer.parseInt(val[1]);
|
||||
String state = null;
|
||||
String qname = null;
|
||||
QuestState qs = null;
|
||||
|
||||
Quest quest = QuestManager.getInstance().getQuest(qnumber);
|
||||
if (quest != null)
|
||||
{
|
||||
qname = quest.getName();
|
||||
qs = target.getQuestState(qname);
|
||||
}
|
||||
else
|
||||
{
|
||||
exqdb = false;
|
||||
}
|
||||
|
||||
if (qs != null)
|
||||
{
|
||||
state = _states[qs.getState()];
|
||||
}
|
||||
else
|
||||
{
|
||||
exqch = false;
|
||||
state = "N/A";
|
||||
}
|
||||
|
||||
if (exqdb)
|
||||
{
|
||||
if (exqch)
|
||||
{
|
||||
replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
|
||||
replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td> </td></tr>");
|
||||
req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + qname + "'");
|
||||
req.execute();
|
||||
rs = req.getResultSet();
|
||||
while (rs.next())
|
||||
{
|
||||
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]);
|
||||
String[] outval = new String[3];
|
||||
|
||||
if (val[1].equals("state"))
|
||||
{
|
||||
switch (val[2])
|
||||
{
|
||||
case "COMPLETED":
|
||||
{
|
||||
qs.exitQuest((val[3].equals("1")) ? true : false);
|
||||
break;
|
||||
}
|
||||
case "DELETE":
|
||||
{
|
||||
Quest.deleteQuestInDb(qs, true);
|
||||
qs.exitQuest(true);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
break;
|
||||
}
|
||||
case "CREATE":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.setState(State.STARTED);
|
||||
qs.set("cond", "1");
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
case "CC":
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.exitQuest(false);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (val[2].equals("delete"))
|
||||
{
|
||||
qs.unset(val[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
qs.set(val[1], val[2]);
|
||||
}
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getId(), qs.getCond()));
|
||||
}
|
||||
actor.sendMessage("");
|
||||
outval[0] = "name";
|
||||
outval[1] = val[0];
|
||||
showQuestMenu(target, actor, outval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
131
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShutdown.java
vendored
Normal file
131
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminShutdown.java
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.GameTimeController;
|
||||
import com.l2jserver.gameserver.Shutdown;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - server_shutdown [sec] = shows menu or shuts down server in sec seconds
|
||||
* @version $Revision: 1.5.2.1.2.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminShutdown implements IAdminCommandHandler
|
||||
{
|
||||
// private static Logger _log = Logger.getLogger(AdminShutdown.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_server_shutdown",
|
||||
"admin_server_restart",
|
||||
"admin_server_abort"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_server_shutdown"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(22);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.valueOf(val), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_shutdown <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_restart"))
|
||||
{
|
||||
try
|
||||
{
|
||||
final String val = command.substring(21);
|
||||
if (Util.isDigit(val))
|
||||
{
|
||||
serverShutdown(activeChar, Integer.parseInt(val), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //server_restart <seconds>");
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_abort"))
|
||||
{
|
||||
serverAbort(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void sendHtmlForm(L2PcInstance activeChar)
|
||||
{
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
int t = GameTimeController.getInstance().getGameTime();
|
||||
int h = t / 60;
|
||||
int m = t % 60;
|
||||
SimpleDateFormat format = new SimpleDateFormat("h:mm a");
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.set(Calendar.HOUR_OF_DAY, h);
|
||||
cal.set(Calendar.MINUTE, m);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "html/admin/shutdown.htm");
|
||||
adminReply.replace("%count%", String.valueOf(L2World.getInstance().getAllPlayersCount()));
|
||||
adminReply.replace("%used%", String.valueOf(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
|
||||
adminReply.replace("%time%", String.valueOf(format.format(cal.getTime())));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void serverShutdown(L2PcInstance activeChar, int seconds, boolean restart)
|
||||
{
|
||||
Shutdown.getInstance().startShutdown(activeChar, seconds, restart);
|
||||
}
|
||||
|
||||
private void serverAbort(L2PcInstance activeChar)
|
||||
{
|
||||
Shutdown.getInstance().abort(activeChar);
|
||||
}
|
||||
|
||||
}
|
||||
589
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSkill.java
vendored
Normal file
589
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSkill.java
vendored
Normal file
@@ -0,0 +1,589 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.ClassListData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.SkillTreesData;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2SkillLearn;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.AcquireSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
String val = command.substring(18);
|
||||
AdminHtml.showAdminHtml(activeChar, "skills/" + val + ".htm");
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_add_skill"))
|
||||
{
|
||||
try
|
||||
{
|
||||
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
|
||||
{
|
||||
String id = command.substring(19);
|
||||
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
|
||||
{
|
||||
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"))
|
||||
{
|
||||
String[] split = command.split(" ");
|
||||
int id = Integer.parseInt(split[1]);
|
||||
int lvl = Integer.parseInt(split[2]);
|
||||
Skill skill = SkillData.getInstance().getSkill(id, lvl);
|
||||
activeChar.addSkill(skill);
|
||||
activeChar.sendSkillList();
|
||||
activeChar.sendMessage("You added yourself skill " + skill.getName() + "(" + id + ") level " + lvl);
|
||||
activeChar.sendPacket(new AcquireSkillList(activeChar));
|
||||
}
|
||||
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()]);
|
||||
|
||||
int maxSkillsPerPage = 10;
|
||||
int maxPages = skills.length / maxSkillsPerPage;
|
||||
if (skills.length > (maxSkillsPerPage * maxPages))
|
||||
{
|
||||
maxPages++;
|
||||
}
|
||||
|
||||
if (page > maxPages)
|
||||
{
|
||||
page = maxPages;
|
||||
}
|
||||
|
||||
int skillsStart = maxSkillsPerPage * page;
|
||||
int skillsEnd = skills.length;
|
||||
if ((skillsEnd - skillsStart) > maxSkillsPerPage)
|
||||
{
|
||||
skillsEnd = skillsStart + maxSkillsPerPage;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(500 + (maxPages * 50) + (((skillsEnd - skillsStart) + 1) * 50), "<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: ", String.valueOf(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++)
|
||||
{
|
||||
int pagenr = x + 1;
|
||||
StringUtil.append(replyMSG, "<td><a action=\"bypass -h admin_remove_skills ", String.valueOf(x), "\">Page ", String.valueOf(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++)
|
||||
{
|
||||
StringUtil.append(replyMSG, "<tr><td width=80><a action=\"bypass -h admin_remove_skill ", String.valueOf(skills[i].getId()), "\">", skills[i].getName(), "</a></td><td width=60>", String.valueOf(skills[i].getLevel()), "</td><td width=40>", String.valueOf(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();
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "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
|
||||
{
|
||||
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
|
||||
{
|
||||
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() != 2)
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
Skill skill = null;
|
||||
try
|
||||
{
|
||||
String id = st.nextToken();
|
||||
String level = st.nextToken();
|
||||
int idval = Integer.parseInt(id);
|
||||
int levelval = Integer.parseInt(level);
|
||||
skill = SkillData.getInstance().getSkill(idval, levelval);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "", e);
|
||||
}
|
||||
if (skill != null)
|
||||
{
|
||||
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.fine("[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();
|
||||
Skill skill = SkillData.getInstance().getSkill(idval, player.getSkillLevel(idval));
|
||||
if (skill != null)
|
||||
{
|
||||
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.fine("[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;
|
||||
}
|
||||
|
||||
String skillname = skill.getName();
|
||||
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;
|
||||
}
|
||||
}
|
||||
513
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSpawn.java
vendored
Normal file
513
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSpawn.java
vendored
Normal file
@@ -0,0 +1,513 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.data.xml.impl.NpcData;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.DayNightSpawnManager;
|
||||
import com.l2jserver.gameserver.instancemanager.InstanceManager;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jserver.gameserver.model.AutoSpawnHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.templates.L2NpcTemplate;
|
||||
import com.l2jserver.gameserver.model.entity.Instance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
|
||||
* @version $Revision: 1.2.2.5.2.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminSpawn implements IAdminCommandHandler
|
||||
{
|
||||
private static final Logger _log = Logger.getLogger(AdminSpawn.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_show_spawns",
|
||||
"admin_spawn",
|
||||
"admin_spawn_monster",
|
||||
"admin_spawn_index",
|
||||
"admin_unspawnall",
|
||||
"admin_respawnall",
|
||||
"admin_spawn_reload",
|
||||
"admin_npc_index",
|
||||
"admin_spawn_once",
|
||||
"admin_show_npcs",
|
||||
"admin_spawnnight",
|
||||
"admin_spawnday",
|
||||
"admin_instance_spawns",
|
||||
"admin_list_spawns",
|
||||
"admin_list_positions",
|
||||
"admin_spawn_debug_menu",
|
||||
"admin_spawn_debug_print",
|
||||
"admin_spawn_debug_print_menu"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_show_spawns"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_debug_menu"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_debug_print"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2Npc)
|
||||
{
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
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"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
int instance = Integer.parseInt(st.nextToken());
|
||||
if (instance >= 300000)
|
||||
{
|
||||
final StringBuilder html = StringUtil.startAppend(500 + 1000, "<html><table width=\"100%\"><tr><td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td width=180><center>", "<font color=\"LEVEL\">Spawns for " + String.valueOf(instance) + "</font>", "</td><td width=45><button value=\"Back\" action=\"bypass -h admin_current_player\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table><br>", "<table width=\"100%\"><tr><td width=200>NpcName</td><td width=70>Action</td></tr>");
|
||||
int counter = 0;
|
||||
int skiped = 0;
|
||||
Instance inst = InstanceManager.getInstance().getInstance(instance);
|
||||
if (inst != null)
|
||||
{
|
||||
for (L2Npc npc : inst.getNpcs())
|
||||
{
|
||||
if (!npc.isDead())
|
||||
{
|
||||
// Only 50 because of client html limitation
|
||||
if (counter < 50)
|
||||
{
|
||||
StringUtil.append(html, "<tr><td>" + npc.getName() + "</td><td>", "<a action=\"bypass -h admin_move_to " + npc.getX() + " " + npc.getY() + " " + npc.getZ() + "\">Go</a>", "</td></tr>");
|
||||
counter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
skiped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
StringUtil.append(html, "<tr><td>Skipped:</td><td>" + String.valueOf(skiped) + "</td></tr></table></body></html>");
|
||||
final NpcHtmlMessage ms = new NpcHtmlMessage();
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Cannot find instance " + instance);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Invalid instance number.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage //instance_spawns <instance_number>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unspawnall"))
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.THE_NPC_SERVER_IS_NOT_OPERATING_AT_THIS_TIME));
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
DayNightSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Unspawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_spawnday"))
|
||||
{
|
||||
DayNightSpawnManager.getInstance().spawnDayCreatures();
|
||||
}
|
||||
else if (command.startsWith("admin_spawnnight"))
|
||||
{
|
||||
DayNightSpawnManager.getInstance().spawnNightCreatures();
|
||||
}
|
||||
else if (command.startsWith("admin_respawnall") || command.startsWith("admin_spawn_reload"))
|
||||
{
|
||||
// make sure all spawns are deleted
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
DayNightSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
// now respawn all
|
||||
NpcData.getInstance().load();
|
||||
SpawnTable.getInstance().load();
|
||||
RaidBossSpawnManager.getInstance().load();
|
||||
AutoSpawnHandler.getInstance().reload();
|
||||
QuestManager.getInstance().reloadAllScripts();
|
||||
AdminData.getInstance().broadcastMessageToGMs("NPC Respawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_spawn_monster") || command.startsWith("admin_spawn"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
try
|
||||
{
|
||||
String cmd = st.nextToken();
|
||||
String id = st.nextToken();
|
||||
int respawnTime = 60; // default is set to 60 seconds
|
||||
int mobCount = 1;
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
mobCount = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
respawnTime = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
if (cmd.equalsIgnoreCase("admin_spawn_once"))
|
||||
{
|
||||
spawnMonster(activeChar, id, respawnTime, mobCount, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
spawnMonster(activeChar, id, respawnTime, mobCount, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{ // Case of wrong or missing monster data
|
||||
AdminHtml.showAdminHtml(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_list_spawns") || command.startsWith("admin_list_positions"))
|
||||
{
|
||||
int npcId = 0;
|
||||
int teleportIndex = -1;
|
||||
try
|
||||
{ // admin_list_spawns x[xxxx] x[xx]
|
||||
String[] params = command.split(" ");
|
||||
Pattern pattern = Pattern.compile("[0-9]*");
|
||||
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++;
|
||||
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)
|
||||
{
|
||||
int i = target.getId();
|
||||
int x = target.getSpawn().getX();
|
||||
int y = target.getSpawn().getY();
|
||||
int z = target.getSpawn().getZ();
|
||||
int h = target.getSpawn().getHeading();
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
_log.info("('',1," + i + "," + x + "," + y + "," + z + ",0,0," + h + ",60,0,0),");
|
||||
break;
|
||||
case 1:
|
||||
_log.info("<spawn npcId=\"" + i + "\" x=\"" + x + "\" y=\"" + y + "\" z=\"" + z + "\" heading=\"" + h + "\" respawn=\"0\" />");
|
||||
break;
|
||||
case 2:
|
||||
_log.info("{ " + i + ", " + x + ", " + y + ", " + z + ", " + h + " },");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnMonster(L2PcInstance activeChar, String monsterId, int respawnTime, int mobCount, boolean permanent)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target == null)
|
||||
{
|
||||
target = activeChar;
|
||||
}
|
||||
|
||||
L2NpcTemplate template;
|
||||
if (monsterId.matches("[0-9]*"))
|
||||
{
|
||||
// First parameter was an ID number
|
||||
template = NpcData.getInstance().getTemplate(Integer.parseInt(monsterId));
|
||||
}
|
||||
else
|
||||
{
|
||||
// First parameter wasn't just numbers so go by name not ID
|
||||
template = NpcData.getInstance().getTemplateByName(monsterId.replace('_', ' '));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
final L2Spawn spawn = new L2Spawn(template);
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
{
|
||||
spawn.setCustom(true);
|
||||
}
|
||||
spawn.setX(target.getX());
|
||||
spawn.setY(target.getY());
|
||||
spawn.setZ(target.getZ());
|
||||
spawn.setAmount(mobCount);
|
||||
spawn.setHeading(activeChar.getHeading());
|
||||
spawn.setRespawnDelay(respawnTime);
|
||||
if (activeChar.getInstanceId() > 0)
|
||||
{
|
||||
spawn.setInstanceId(activeChar.getInstanceId());
|
||||
permanent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
spawn.setInstanceId(0);
|
||||
}
|
||||
// TODO add checks for GrandBossSpawnManager
|
||||
if (RaidBossSpawnManager.getInstance().isDefined(spawn.getId()))
|
||||
{
|
||||
activeChar.sendMessage("You cannot spawn another instance of " + template.getName() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (template.isType("L2RaidBoss"))
|
||||
{
|
||||
spawn.setRespawnMinDelay(43200);
|
||||
spawn.setRespawnMaxDelay(129600);
|
||||
RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template.getBaseHpMax(), template.getBaseMpMax(), permanent);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, permanent);
|
||||
spawn.init();
|
||||
}
|
||||
if (!permanent)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
}
|
||||
activeChar.sendMessage("Created " + template.getName() + " on " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMonsters(L2PcInstance activeChar, int level, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllMonstersOfLevel(level);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "<html><title>Spawn Monster:</title><body><p> Level : ", Integer.toString(level), "<br>Total Npc's : ", Integer.toString(mobsCount), "<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs.get(i).getId()), "\">", mobs.get(i).getName(), "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(tb, "<br><center><button value=\"Next\" action=\"bypass -h admin_spawn_index ", Integer.toString(level), " ", Integer.toString(i), "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_spawns\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(tb.toString()));
|
||||
}
|
||||
|
||||
private void showNpcs(L2PcInstance activeChar, String starting, int from)
|
||||
{
|
||||
final List<L2NpcTemplate> mobs = NpcData.getInstance().getAllNpcStartingWith(starting);
|
||||
final int mobsCount = mobs.size();
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + (mobsCount * 80), "<html><title>Spawn Monster:</title><body><p> There are ", Integer.toString(mobsCount), " Npcs whose name starts with ", starting, ":<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; (i < mobsCount) && (j < 50); i++, j++)
|
||||
{
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs.get(i).getId()), "\">", mobs.get(i).getName(), "</a><br1>");
|
||||
}
|
||||
|
||||
if (i == mobsCount)
|
||||
{
|
||||
tb.append("<br><center><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(tb, "<br><center><button value=\"Next\" action=\"bypass -h admin_npc_index ", starting, " ", Integer.toString(i), "\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back\" action=\"bypass -h admin_show_npcs\" width=40 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></center></body></html>");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new NpcHtmlMessage(tb.toString()));
|
||||
}
|
||||
}
|
||||
97
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSummon.java
vendored
Normal file
97
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminSummon.java
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.data.xml.impl.AdminData;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.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;
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
72
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTarget.java
vendored
Normal file
72
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTarget.java
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
String targetName = command.substring(13);
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
73
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTargetSay.java
vendored
Normal file
73
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTargetSay.java
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.enums.ChatType;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
636
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTeleport.java
vendored
Normal file
636
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTeleport.java
vendored
Normal file
@@ -0,0 +1,636 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Spawn;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2GrandBossInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2RaidBossInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 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_teleto"))
|
||||
{
|
||||
activeChar.setTeleMode(1);
|
||||
}
|
||||
if (command.equals("admin_instant_move"))
|
||||
{
|
||||
activeChar.sendMessage("Instant move ready. Click where you want to go.");
|
||||
activeChar.setTeleMode(1);
|
||||
}
|
||||
if (command.equals("admin_teleto r"))
|
||||
{
|
||||
activeChar.setTeleMode(2);
|
||||
}
|
||||
if (command.equals("admin_teleto end"))
|
||||
{
|
||||
activeChar.setTeleMode(0);
|
||||
}
|
||||
if (command.equals("admin_show_moves"))
|
||||
{
|
||||
AdminHtml.showAdminHtml(activeChar, "teleports.htm");
|
||||
}
|
||||
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
|
||||
{
|
||||
String val = command.substring(11);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
int x = Integer.parseInt(st.nextToken());
|
||||
int y = Integer.parseInt(st.nextToken());
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
String targetName = command.substring(17);
|
||||
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 = (int) Float.parseFloat(st.nextToken());
|
||||
|
||||
activeChar.teleToLocation(x, y, z);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Wrong coordinates!");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall "))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] param = command.split(" ");
|
||||
if (param.length != 2)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //recall <playername>");
|
||||
return false;
|
||||
}
|
||||
String targetName = param[1];
|
||||
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
|
||||
{
|
||||
String val = command.substring(8);
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
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"))
|
||||
{
|
||||
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);
|
||||
player.setInstanceId(0);
|
||||
}
|
||||
|
||||
private void teleportTo(L2PcInstance activeChar, String Coords)
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(Coords);
|
||||
String x1 = st.nextToken();
|
||||
int x = Integer.parseInt(x1);
|
||||
String y1 = st.nextToken();
|
||||
int y = Integer.parseInt(y1);
|
||||
String z1 = st.nextToken();
|
||||
int z = Integer.parseInt(z1);
|
||||
|
||||
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)
|
||||
{
|
||||
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();
|
||||
|
||||
final String replyMSG = StringUtil.concat("<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 ", String.valueOf(activeChar.getX()), " ", String.valueOf(activeChar.getY()), " ", String.valueOf(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)
|
||||
{
|
||||
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
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(Cords);
|
||||
String x1 = st.nextToken();
|
||||
int x = Integer.parseInt(x1);
|
||||
String y1 = st.nextToken();
|
||||
int y = Integer.parseInt(y1);
|
||||
String z1 = st.nextToken();
|
||||
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
|
||||
{
|
||||
// Set player to same instance as GM teleporting.
|
||||
if ((activeChar != null) && (activeChar.getInstanceId() >= 0))
|
||||
{
|
||||
player.setInstanceId(activeChar.getInstanceId());
|
||||
activeChar.sendMessage("You have recalled " + player.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setInstanceId(0);
|
||||
}
|
||||
player.sendMessage("Admin is teleporting you.");
|
||||
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
player.teleToLocation(loc, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
// move to targets instance
|
||||
activeChar.setInstanceId(target.getInstanceId());
|
||||
|
||||
int x = player.getX();
|
||||
int y = player.getY();
|
||||
int z = player.getZ();
|
||||
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
activeChar.teleToLocation(new Location(x, y, z), true);
|
||||
|
||||
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 = L2DatabaseFactory.getInstance().getConnection())
|
||||
{
|
||||
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();
|
||||
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)
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if ((obj instanceof L2Npc) && !((L2Npc) obj).isMinion() && !(obj instanceof L2RaidBossInstance) && !(obj instanceof L2GrandBossInstance))
|
||||
{
|
||||
L2Npc target = (L2Npc) obj;
|
||||
L2Spawn spawn = target.getSpawn();
|
||||
if (spawn == null)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect monster spawn.");
|
||||
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
|
||||
return;
|
||||
}
|
||||
int respawnTime = spawn.getRespawnDelay() / 1000;
|
||||
|
||||
target.deleteMe();
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
|
||||
try
|
||||
{
|
||||
spawn = new L2Spawn(target.getTemplate().getId());
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
{
|
||||
spawn.setCustom(true);
|
||||
}
|
||||
spawn.setX(activeChar.getX());
|
||||
spawn.setY(activeChar.getY());
|
||||
spawn.setZ(activeChar.getZ());
|
||||
spawn.setAmount(1);
|
||||
spawn.setHeading(activeChar.getHeading());
|
||||
spawn.setRespawnDelay(respawnTime);
|
||||
if (activeChar.getInstanceId() >= 0)
|
||||
{
|
||||
spawn.setInstanceId(activeChar.getInstanceId());
|
||||
}
|
||||
else
|
||||
{
|
||||
spawn.setInstanceId(0);
|
||||
}
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, true);
|
||||
spawn.init();
|
||||
|
||||
activeChar.sendMessage("Created " + target.getTemplate().getName() + " on " + target.getObjectId() + ".");
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("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)
|
||||
{
|
||||
L2RaidBossInstance target = (L2RaidBossInstance) obj;
|
||||
L2Spawn spawn = target.getSpawn();
|
||||
double curHP = target.getCurrentHp();
|
||||
double curMP = target.getCurrentMp();
|
||||
if (spawn == null)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect raid spawn.");
|
||||
_log.warning("ERROR: NPC Id" + target.getId() + " has a 'null' spawn.");
|
||||
return;
|
||||
}
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
try
|
||||
{
|
||||
final L2Spawn spawnDat = new L2Spawn(target.getId());
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
{
|
||||
spawn.setCustom(true);
|
||||
}
|
||||
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);
|
||||
|
||||
RaidBossSpawnManager.getInstance().addNewSpawn(spawnDat, 0, curHP, curMP, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOUR_TARGET_CANNOT_BE_FOUND);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
130
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTest.java
vendored
Normal file
130
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTest.java
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.datatables.SkillData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.skills.Skill;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
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;
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (!(target instanceof L2Character))
|
||||
{
|
||||
caster = activeChar;
|
||||
}
|
||||
else
|
||||
{
|
||||
caster = (L2Character) target;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
112
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
vendored
Normal file
112
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminTvTEvent.java
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.TvTEvent;
|
||||
import com.l2jserver.gameserver.model.entity.TvTEventTeleporter;
|
||||
import com.l2jserver.gameserver.model.entity.TvTManager;
|
||||
|
||||
/**
|
||||
* @author HorridoJoho
|
||||
*/
|
||||
public class AdminTvTEvent implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_tvt_add",
|
||||
"admin_tvt_remove",
|
||||
"admin_tvt_advance"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_tvt_add"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You should select a player!");
|
||||
return true;
|
||||
}
|
||||
|
||||
add(activeChar, (L2PcInstance) target);
|
||||
}
|
||||
else if (command.equals("admin_tvt_remove"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendMessage("You should select a player!");
|
||||
return true;
|
||||
}
|
||||
|
||||
remove(activeChar, (L2PcInstance) target);
|
||||
}
|
||||
else if (command.equals("admin_tvt_advance"))
|
||||
{
|
||||
TvTManager.getInstance().skipDelay();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void add(L2PcInstance activeChar, L2PcInstance playerInstance)
|
||||
{
|
||||
if (playerInstance.isOnEvent())
|
||||
{
|
||||
activeChar.sendMessage("Player already participated in the event!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TvTEvent.addParticipant(playerInstance))
|
||||
{
|
||||
activeChar.sendMessage("Player instance could not be added, it seems to be null!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TvTEvent.isStarted())
|
||||
{
|
||||
new TvTEventTeleporter(playerInstance, TvTEvent.getParticipantTeamCoordinates(playerInstance.getObjectId()), true, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void remove(L2PcInstance activeChar, L2PcInstance playerInstance)
|
||||
{
|
||||
if (!TvTEvent.removeParticipant(playerInstance.getObjectId()))
|
||||
{
|
||||
activeChar.sendMessage("Player is not part of the event!");
|
||||
return;
|
||||
}
|
||||
|
||||
new TvTEventTeleporter(playerInstance, Config.TVT_EVENT_PARTICIPATION_NPC_COORDINATES, true, true);
|
||||
}
|
||||
}
|
||||
77
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminUnblockIp.java
vendored
Normal file
77
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminUnblockIp.java
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
111
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminVitality.java
vendored
Normal file
111
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminVitality.java
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.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;
|
||||
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
String cmd = st.nextToken();
|
||||
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance target;
|
||||
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;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new AdminVitality();
|
||||
}
|
||||
}
|
||||
178
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminZone.java
vendored
Normal file
178
trunk/dist/game/data_classic/scripts/handlers/admincommandhandlers/AdminZone.java
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.MapRegionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ZoneManager;
|
||||
import com.l2jserver.gameserver.model.L2World;
|
||||
import com.l2jserver.gameserver.model.L2WorldRegion;
|
||||
import com.l2jserver.gameserver.model.Location;
|
||||
import com.l2jserver.gameserver.model.TeleportWhereType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.zone.L2ZoneType;
|
||||
import com.l2jserver.gameserver.model.zone.ZoneId;
|
||||
import com.l2jserver.gameserver.model.zone.type.NpcSpawnTerritory;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Small typo fix by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminZone implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_zone_check",
|
||||
"admin_zone_visual",
|
||||
"admin_zone_visual_clear"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
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"))
|
||||
{
|
||||
String next = st.nextToken();
|
||||
if (next.equalsIgnoreCase("all"))
|
||||
{
|
||||
for (L2ZoneType zone : ZoneManager.getInstance().getZones(activeChar))
|
||||
{
|
||||
zone.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
territory.visualizeZone(activeChar.getZ());
|
||||
}
|
||||
showHtml(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
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(), "html/admin/zone.htm");
|
||||
final NpcHtmlMessage adminReply = new NpcHtmlMessage();
|
||||
adminReply.setHtml(htmContent);
|
||||
adminReply.replace("%PEACE%", (activeChar.isInsideZone(ZoneId.PEACE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%PVP%", (activeChar.isInsideZone(ZoneId.PVP) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%SIEGE%", (activeChar.isInsideZone(ZoneId.SIEGE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%TOWN%", (activeChar.isInsideZone(ZoneId.TOWN) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%CASTLE%", (activeChar.isInsideZone(ZoneId.CASTLE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%FORT%", (activeChar.isInsideZone(ZoneId.FORT) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%HQ%", (activeChar.isInsideZone(ZoneId.HQ) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%CLANHALL%", (activeChar.isInsideZone(ZoneId.CLAN_HALL) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%LAND%", (activeChar.isInsideZone(ZoneId.LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOLAND%", (activeChar.isInsideZone(ZoneId.NO_LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOSUMMON%", (activeChar.isInsideZone(ZoneId.NO_SUMMON_FRIEND) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%WATER%", (activeChar.isInsideZone(ZoneId.WATER) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%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"));
|
||||
StringBuilder zones = new StringBuilder(100);
|
||||
L2WorldRegion region = L2World.getInstance().getRegion(activeChar.getX(), activeChar.getY());
|
||||
for (L2ZoneType zone : region.getZones())
|
||||
{
|
||||
if (zone.isCharacterInZone(activeChar))
|
||||
{
|
||||
if (zone.getName() != null)
|
||||
{
|
||||
StringUtil.append(zones, zone.getName() + "<br1>");
|
||||
if (zone.getId() < 300000)
|
||||
{
|
||||
StringUtil.append(zones, "(", String.valueOf(zone.getId()), ")");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StringUtil.append(zones, String.valueOf(zone.getId()));
|
||||
}
|
||||
StringUtil.append(zones, " ");
|
||||
}
|
||||
}
|
||||
for (NpcSpawnTerritory territory : ZoneManager.getInstance().getSpawnTerritories(activeChar))
|
||||
{
|
||||
StringUtil.append(zones, territory.getName() + "<br1>");
|
||||
}
|
||||
adminReply.replace("%ZLIST%", zones.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private static void getGeoRegionXY(L2PcInstance activeChar)
|
||||
{
|
||||
int worldX = activeChar.getX();
|
||||
int worldY = activeChar.getY();
|
||||
int geoX = ((((worldX - (-327680)) >> 4) >> 11) + 10);
|
||||
int geoY = ((((worldY - (-262144)) >> 4) >> 11) + 10);
|
||||
activeChar.sendMessage("GeoRegion: " + geoX + "_" + geoY + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
57
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ArcanCityMovie.java
vendored
Normal file
57
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ArcanCityMovie.java
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2NpcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class ArcanCityMovie implements IBypassHandler
|
||||
{
|
||||
// Npc
|
||||
private static final int MUMU = 32900;
|
||||
// Others
|
||||
private static final int ARCAN_ENTER_MOVIE = 104;
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"ArcanCityMovie"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc() || (((L2NpcInstance) target).getId() != MUMU))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.showQuestMovie(ARCAN_ENTER_MOVIE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
68
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/Augment.java
vendored
Normal file
68
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/Augment.java
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowVariationCancelWindow;
|
||||
import com.l2jserver.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;
|
||||
}
|
||||
}
|
||||
69
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/Buy.java
vendored
Normal file
69
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/Buy.java
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jserver.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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
71
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/BuyShadowItem.java
vendored
Normal file
71
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/BuyShadowItem.java
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class BuyShadowItem implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"BuyShadowItem"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc) target).getObjectId());
|
||||
if (activeChar.getLevel() < 40)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item-lowlevel.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 40) && (activeChar.getLevel() < 46))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_d.htm");
|
||||
}
|
||||
else if ((activeChar.getLevel() >= 46) && (activeChar.getLevel() < 52))
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_c.htm");
|
||||
}
|
||||
else if (activeChar.getLevel() >= 52)
|
||||
{
|
||||
html.setFile(activeChar.getHtmlPrefix(), "html/common/shadow_item_b.htm");
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
71
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ChatLink.java
vendored
Normal file
71
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ChatLink.java
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.events.EventDispatcher;
|
||||
import com.l2jserver.gameserver.model.events.EventType;
|
||||
import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcFirstTalk;
|
||||
|
||||
public class ChatLink implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Chat"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (Exception ioobe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
if ((val == 0) && npc.hasListener(EventType.ON_NPC_FIRST_TALK))
|
||||
{
|
||||
EventDispatcher.getInstance().notifyEventAsync(new OnNpcFirstTalk(npc, activeChar), npc);
|
||||
}
|
||||
else
|
||||
{
|
||||
npc.showChatWindow(activeChar, val);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
178
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ClanWarehouse.java
vendored
Normal file
178
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/ClanWarehouse.java
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.ClanPrivilege;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ClanHallManagerInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2WarehouseInstance;
|
||||
import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SortedWareHouseWithdrawalList.WarehouseListType;
|
||||
import com.l2jserver.gameserver.network.serverpackets.WareHouseDepositList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.WareHouseWithdrawalList;
|
||||
|
||||
public class ClanWarehouse implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"withdrawc",
|
||||
"withdrawsortedc",
|
||||
"depositc"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2WarehouseInstance) && !(target instanceof L2ClanHallManagerInstance))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.hasItemRequest())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.getClan() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.getClan().getLevel() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.ONLY_CLANS_OF_CLAN_LEVEL_1_OR_ABOVE_CAN_USE_A_CLAN_WAREHOUSE);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
|
||||
{
|
||||
if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN)
|
||||
{
|
||||
final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "html/mods/WhSortedC.htm");
|
||||
msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
|
||||
activeChar.sendPacket(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
showWithdrawWindow(activeChar, null, (byte) 0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // WithdrawSortedC
|
||||
{
|
||||
final String param[] = command.split(" ");
|
||||
|
||||
if (param.length > 2)
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.getOrder(param[2]));
|
||||
}
|
||||
else if (param.length > 1)
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.valueOf(param[1]), SortedWareHouseWithdrawalList.A2Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
showWithdrawWindow(activeChar, WarehouseListType.ALL, SortedWareHouseWithdrawalList.A2Z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[2])) // DepositC
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.setActiveWarehouse(activeChar.getClan().getWarehouse());
|
||||
activeChar.setInventoryBlockingStatus(true);
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Source: L2WarehouseInstance.java; Player: " + activeChar.getName() + "; Command: showDepositWindowClan; Message: Showing items to deposit.");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new WareHouseDepositList(activeChar, WareHouseDepositList.CLAN));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final void showWithdrawWindow(L2PcInstance player, WarehouseListType itemtype, byte sortorder)
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
if (!player.hasClanPrivilege(ClanPrivilege.CL_VIEW_WAREHOUSE))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_THE_CLAN_WAREHOUSE);
|
||||
return;
|
||||
}
|
||||
|
||||
player.setActiveWarehouse(player.getClan().getWarehouse());
|
||||
|
||||
if (player.getActiveWarehouse().getSize() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_HAVE_NOT_DEPOSITED_ANY_ITEMS_IN_YOUR_WAREHOUSE);
|
||||
return;
|
||||
}
|
||||
|
||||
for (L2ItemInstance i : player.getActiveWarehouse().getItems())
|
||||
{
|
||||
if (i.isTimeLimitedItem() && (i.getRemainingTime() <= 0))
|
||||
{
|
||||
player.getActiveWarehouse().destroyItem("L2ItemInstance", i, player, null);
|
||||
}
|
||||
}
|
||||
if (itemtype != null)
|
||||
{
|
||||
player.sendPacket(new SortedWareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN, itemtype, sortorder));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendPacket(new WareHouseWithdrawalList(player, WareHouseWithdrawalList.CLAN));
|
||||
}
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Source: L2WarehouseInstance.java; Player: " + player.getName() + "; Command: showRetrieveWindowClan; Message: Showing stored items.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
69
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/EventEngine.java
vendored
Normal file
69
trunk/dist/game/data_classic/scripts/handlers/bypasshandlers/EventEngine.java
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 L2J DataPack
|
||||
*
|
||||
* This file is part of L2J DataPack.
|
||||
*
|
||||
* L2J DataPack is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* L2J DataPack is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should 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.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.entity.L2Event;
|
||||
|
||||
public class EventEngine implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"event_participate",
|
||||
"event_unregister"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!target.isNpc())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.equalsIgnoreCase("event_participate"))
|
||||
{
|
||||
L2Event.registerPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
else if (command.equalsIgnoreCase("event_unregister"))
|
||||
{
|
||||
L2Event.removeAndResetPlayer(activeChar);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user