actual freya branch
This commit is contained in:
@@ -0,0 +1,571 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.L2DoorInstanceActionShift;
|
||||
import handlers.actionhandlers.L2ItemInstanceAction;
|
||||
import handlers.actionhandlers.L2ItemInstanceActionShift;
|
||||
import handlers.actionhandlers.L2NpcAction;
|
||||
import handlers.actionhandlers.L2NpcActionShift;
|
||||
import handlers.actionhandlers.L2PcInstanceAction;
|
||||
import handlers.actionhandlers.L2PcInstanceActionShift;
|
||||
import handlers.actionhandlers.L2PetInstanceAction;
|
||||
import handlers.actionhandlers.L2StaticObjectInstanceAction;
|
||||
import handlers.actionhandlers.L2StaticObjectInstanceActionShift;
|
||||
import handlers.actionhandlers.L2SummonAction;
|
||||
import handlers.actionhandlers.L2SummonActionShift;
|
||||
import handlers.actionhandlers.L2TrapAction;
|
||||
import handlers.admincommandhandlers.AdminAdmin;
|
||||
import handlers.admincommandhandlers.AdminAnnouncements;
|
||||
import handlers.admincommandhandlers.AdminBBS;
|
||||
import handlers.admincommandhandlers.AdminBan;
|
||||
import handlers.admincommandhandlers.AdminBuffs;
|
||||
import handlers.admincommandhandlers.AdminCache;
|
||||
import handlers.admincommandhandlers.AdminCamera;
|
||||
import handlers.admincommandhandlers.AdminChangeAccessLevel;
|
||||
import handlers.admincommandhandlers.AdminClan;
|
||||
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.AdminEditNpc;
|
||||
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.AdminGeoEditor;
|
||||
import handlers.admincommandhandlers.AdminGeodata;
|
||||
import handlers.admincommandhandlers.AdminGm;
|
||||
import handlers.admincommandhandlers.AdminGmChat;
|
||||
import handlers.admincommandhandlers.AdminGraciaSeeds;
|
||||
import handlers.admincommandhandlers.AdminHeal;
|
||||
import handlers.admincommandhandlers.AdminHelpPage;
|
||||
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.AdminMammon;
|
||||
import handlers.admincommandhandlers.AdminManor;
|
||||
import handlers.admincommandhandlers.AdminMenu;
|
||||
import handlers.admincommandhandlers.AdminMessages;
|
||||
import handlers.admincommandhandlers.AdminMobGroup;
|
||||
import handlers.admincommandhandlers.AdminMonsterRace;
|
||||
import handlers.admincommandhandlers.AdminPForge;
|
||||
import handlers.admincommandhandlers.AdminPathNode;
|
||||
import handlers.admincommandhandlers.AdminPetition;
|
||||
import handlers.admincommandhandlers.AdminPledge;
|
||||
import handlers.admincommandhandlers.AdminPolymorph;
|
||||
import handlers.admincommandhandlers.AdminQuest;
|
||||
import handlers.admincommandhandlers.AdminRepairChar;
|
||||
import handlers.admincommandhandlers.AdminRes;
|
||||
import handlers.admincommandhandlers.AdminRide;
|
||||
import handlers.admincommandhandlers.AdminShop;
|
||||
import handlers.admincommandhandlers.AdminShowQuests;
|
||||
import handlers.admincommandhandlers.AdminShutdown;
|
||||
import handlers.admincommandhandlers.AdminSiege;
|
||||
import handlers.admincommandhandlers.AdminSkill;
|
||||
import handlers.admincommandhandlers.AdminSpawn;
|
||||
import handlers.admincommandhandlers.AdminSummon;
|
||||
import handlers.admincommandhandlers.AdminTarget;
|
||||
import handlers.admincommandhandlers.AdminTeleport;
|
||||
import handlers.admincommandhandlers.AdminTerritoryWar;
|
||||
import handlers.admincommandhandlers.AdminTest;
|
||||
import handlers.admincommandhandlers.AdminTvTEvent;
|
||||
import handlers.admincommandhandlers.AdminUnblockIp;
|
||||
import handlers.admincommandhandlers.AdminVitality;
|
||||
import handlers.admincommandhandlers.AdminZone;
|
||||
import handlers.bypasshandlers.Augment;
|
||||
import handlers.bypasshandlers.Buy;
|
||||
import handlers.bypasshandlers.BuyShadowItem;
|
||||
import handlers.bypasshandlers.CPRecovery;
|
||||
import handlers.bypasshandlers.ChatLink;
|
||||
import handlers.bypasshandlers.ClanWarehouse;
|
||||
import handlers.bypasshandlers.DrawHenna;
|
||||
import handlers.bypasshandlers.Festival;
|
||||
import handlers.bypasshandlers.FortSiege;
|
||||
import handlers.bypasshandlers.ItemAuctionLink;
|
||||
import handlers.bypasshandlers.Link;
|
||||
import handlers.bypasshandlers.Loto;
|
||||
import handlers.bypasshandlers.ManorManager;
|
||||
import handlers.bypasshandlers.Multisell;
|
||||
import handlers.bypasshandlers.Observation;
|
||||
import handlers.bypasshandlers.OlympiadObservation;
|
||||
import handlers.bypasshandlers.OlympiadManagerLink;
|
||||
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.RemoveDeathPenalty;
|
||||
import handlers.bypasshandlers.RemoveHennaList;
|
||||
import handlers.bypasshandlers.RentPet;
|
||||
import handlers.bypasshandlers.RideWyvern;
|
||||
import handlers.bypasshandlers.Rift;
|
||||
import handlers.bypasshandlers.SkillList;
|
||||
import handlers.bypasshandlers.SupportBlessing;
|
||||
import handlers.bypasshandlers.SupportMagic;
|
||||
import handlers.bypasshandlers.TerritoryStatus;
|
||||
import handlers.bypasshandlers.TerritoryWar;
|
||||
import handlers.bypasshandlers.VoiceCommand;
|
||||
import handlers.bypasshandlers.Wear;
|
||||
import handlers.chathandlers.ChatAll;
|
||||
import handlers.chathandlers.ChatAlliance;
|
||||
import handlers.chathandlers.ChatBattlefield;
|
||||
import handlers.chathandlers.ChatClan;
|
||||
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.ChatTell;
|
||||
import handlers.chathandlers.ChatTrade;
|
||||
import handlers.itemhandlers.BeastSoulShot;
|
||||
import handlers.itemhandlers.BeastSpice;
|
||||
import handlers.itemhandlers.BeastSpiritShot;
|
||||
import handlers.itemhandlers.BlessedSpiritShot;
|
||||
import handlers.itemhandlers.Book;
|
||||
import handlers.itemhandlers.Disguise;
|
||||
import handlers.itemhandlers.Elixir;
|
||||
import handlers.itemhandlers.EnchantAttribute;
|
||||
import handlers.itemhandlers.EnchantScrolls;
|
||||
import handlers.itemhandlers.EnergyStarStone;
|
||||
import handlers.itemhandlers.EventItem;
|
||||
import handlers.itemhandlers.ExtractableItems;
|
||||
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.PaganKeys;
|
||||
import handlers.itemhandlers.PetFood;
|
||||
import handlers.itemhandlers.Recipes;
|
||||
import handlers.itemhandlers.RollingDice;
|
||||
import handlers.itemhandlers.ScrollOfResurrection;
|
||||
import handlers.itemhandlers.Seed;
|
||||
import handlers.itemhandlers.SevenSignsRecord;
|
||||
import handlers.itemhandlers.SoulShots;
|
||||
import handlers.itemhandlers.SpecialXMas;
|
||||
import handlers.itemhandlers.SpiritShot;
|
||||
import handlers.itemhandlers.SummonItems;
|
||||
import handlers.itemhandlers.TeleportBookmark;
|
||||
import handlers.skillhandlers.BalanceLife;
|
||||
import handlers.skillhandlers.BallistaBomb;
|
||||
import handlers.skillhandlers.BeastSkills;
|
||||
import handlers.skillhandlers.Blow;
|
||||
import handlers.skillhandlers.Cancel;
|
||||
import handlers.skillhandlers.Charge;
|
||||
import handlers.skillhandlers.CombatPointHeal;
|
||||
import handlers.skillhandlers.Continuous;
|
||||
import handlers.skillhandlers.CpDam;
|
||||
import handlers.skillhandlers.CpDamPercent;
|
||||
import handlers.skillhandlers.Craft;
|
||||
import handlers.skillhandlers.DeluxeKey;
|
||||
import handlers.skillhandlers.Detection;
|
||||
import handlers.skillhandlers.Disablers;
|
||||
import handlers.skillhandlers.Dummy;
|
||||
import handlers.skillhandlers.Extractable;
|
||||
import handlers.skillhandlers.Fishing;
|
||||
import handlers.skillhandlers.FishingSkill;
|
||||
import handlers.skillhandlers.GetPlayer;
|
||||
import handlers.skillhandlers.GiveReco;
|
||||
import handlers.skillhandlers.GiveSp;
|
||||
import handlers.skillhandlers.GiveVitality;
|
||||
import handlers.skillhandlers.Harvest;
|
||||
import handlers.skillhandlers.Heal;
|
||||
import handlers.skillhandlers.HealPercent;
|
||||
import handlers.skillhandlers.InstantJump;
|
||||
import handlers.skillhandlers.ManaHeal;
|
||||
import handlers.skillhandlers.Manadam;
|
||||
import handlers.skillhandlers.Mdam;
|
||||
import handlers.skillhandlers.NornilsPower;
|
||||
import handlers.skillhandlers.Pdam;
|
||||
import handlers.skillhandlers.RefuelAirShip;
|
||||
import handlers.skillhandlers.Resurrect;
|
||||
import handlers.skillhandlers.ShiftTarget;
|
||||
import handlers.skillhandlers.Soul;
|
||||
import handlers.skillhandlers.Sow;
|
||||
import handlers.skillhandlers.Spoil;
|
||||
import handlers.skillhandlers.StealBuffs;
|
||||
import handlers.skillhandlers.StrSiegeAssault;
|
||||
import handlers.skillhandlers.SummonFriend;
|
||||
import handlers.skillhandlers.Sweep;
|
||||
import handlers.skillhandlers.TakeCastle;
|
||||
import handlers.skillhandlers.TakeFort;
|
||||
import handlers.skillhandlers.TransformDispel;
|
||||
import handlers.skillhandlers.Trap;
|
||||
import handlers.skillhandlers.Unlock;
|
||||
import handlers.usercommandhandlers.Birthday;
|
||||
import handlers.usercommandhandlers.ChannelDelete;
|
||||
import handlers.usercommandhandlers.ChannelLeave;
|
||||
import handlers.usercommandhandlers.ChannelListUpdate;
|
||||
import handlers.usercommandhandlers.ClanPenalty;
|
||||
import handlers.usercommandhandlers.ClanWarsList;
|
||||
import handlers.usercommandhandlers.DisMount;
|
||||
import handlers.usercommandhandlers.Escape;
|
||||
import handlers.usercommandhandlers.InstanceZone;
|
||||
import handlers.usercommandhandlers.Loc;
|
||||
import handlers.usercommandhandlers.Mount;
|
||||
import handlers.usercommandhandlers.OlympiadStat;
|
||||
import handlers.usercommandhandlers.PartyInfo;
|
||||
import handlers.usercommandhandlers.Time;
|
||||
import handlers.voicedcommandhandlers.Banking;
|
||||
import handlers.voicedcommandhandlers.ChatAdmin;
|
||||
import handlers.voicedcommandhandlers.Debug;
|
||||
import handlers.voicedcommandhandlers.Lang;
|
||||
import handlers.voicedcommandhandlers.TvTVoicedInfo;
|
||||
import handlers.voicedcommandhandlers.Wedding;
|
||||
import handlers.voicedcommandhandlers.stats;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.ActionHandler;
|
||||
import com.l2jserver.gameserver.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.BypassHandler;
|
||||
import com.l2jserver.gameserver.handler.ChatHandler;
|
||||
import com.l2jserver.gameserver.handler.ItemHandler;
|
||||
import com.l2jserver.gameserver.handler.SkillHandler;
|
||||
import com.l2jserver.gameserver.handler.UserCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.VoicedCommandHandler;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nBd
|
||||
*/
|
||||
public class MasterHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(MasterHandler.class.getName());
|
||||
|
||||
private static void loadActionHandlers()
|
||||
{
|
||||
ActionHandler.getInstance().registerActionHandler(new L2ArtefactInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2DecoyAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2DoorInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2ItemInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2NpcAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2PcInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2PetInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2StaticObjectInstanceAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2SummonAction());
|
||||
ActionHandler.getInstance().registerActionHandler(new L2TrapAction());
|
||||
_log.config("Loaded " + ActionHandler.getInstance().size() + " ActionHandlers");
|
||||
}
|
||||
|
||||
private static void loadActionShiftHandlers()
|
||||
{
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2DoorInstanceActionShift());
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2ItemInstanceActionShift());
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2NpcActionShift());
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2PcInstanceActionShift());
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2StaticObjectInstanceActionShift());
|
||||
ActionHandler.getInstance().registerActionShiftHandler(new L2SummonActionShift());
|
||||
_log.config("Loaded " + ActionHandler.getInstance().sizeShift() + " ActionShiftHandlers");
|
||||
}
|
||||
|
||||
private static void loadAdminHandlers()
|
||||
{
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminAdmin());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminAnnouncements());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBan());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBBS());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminBuffs());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCache());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCamera());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminChangeAccessLevel());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminClan());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCreateItem());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminCursedWeapons());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDebug());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDelete());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDisconnect());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminDoorControl());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEditChar());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEditNpc());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEffects());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminElement());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEnchant());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEventEngine());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminEvents());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminExpSp());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminFightCalculator());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminFortSiege());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGeodata());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGeoEditor());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGm());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGmChat());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminGraciaSeeds());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminHeal());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminHelpPage());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminInstance());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminInstanceZone());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminInvul());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKick());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminKill());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLevel());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminLogin());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMammon());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminManor());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMenu());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMessages());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMobGroup());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminMonsterRace());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPathNode());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPetition());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPForge());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPledge());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminPolymorph());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminQuest());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRepairChar());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRes());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminRide());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShop());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShowQuests());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminShutdown());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSiege());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSkill());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSpawn());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminSummon());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTarget());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTeleport());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTerritoryWar());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTest());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminTvTEvent());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminUnblockIp());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminVitality());
|
||||
AdminCommandHandler.getInstance().registerAdminCommandHandler(new AdminZone());
|
||||
_log.config("Loaded " + AdminCommandHandler.getInstance().size() + " AdminCommandHandlers");
|
||||
}
|
||||
|
||||
private static void loadBypassHandlers()
|
||||
{
|
||||
BypassHandler.getInstance().registerBypassHandler(new Augment());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Buy());
|
||||
BypassHandler.getInstance().registerBypassHandler(new BuyShadowItem());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ChatLink());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ClanWarehouse());
|
||||
BypassHandler.getInstance().registerBypassHandler(new CPRecovery());
|
||||
BypassHandler.getInstance().registerBypassHandler(new DrawHenna());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Festival());
|
||||
BypassHandler.getInstance().registerBypassHandler(new FortSiege());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ItemAuctionLink());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Link());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Loto());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ManorManager());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Multisell());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Observation());
|
||||
BypassHandler.getInstance().registerBypassHandler(new OlympiadObservation());
|
||||
BypassHandler.getInstance().registerBypassHandler(new OlympiadManagerLink());
|
||||
BypassHandler.getInstance().registerBypassHandler(new QuestLink());
|
||||
BypassHandler.getInstance().registerBypassHandler(new PlayerHelp());
|
||||
BypassHandler.getInstance().registerBypassHandler(new PrivateWarehouse());
|
||||
BypassHandler.getInstance().registerBypassHandler(new QuestList());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ReceivePremium());
|
||||
BypassHandler.getInstance().registerBypassHandler(new ReleaseAttribute());
|
||||
BypassHandler.getInstance().registerBypassHandler(new RemoveDeathPenalty());
|
||||
BypassHandler.getInstance().registerBypassHandler(new RemoveHennaList());
|
||||
BypassHandler.getInstance().registerBypassHandler(new RentPet());
|
||||
BypassHandler.getInstance().registerBypassHandler(new RideWyvern());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Rift());
|
||||
BypassHandler.getInstance().registerBypassHandler(new SkillList());
|
||||
BypassHandler.getInstance().registerBypassHandler(new SupportBlessing());
|
||||
BypassHandler.getInstance().registerBypassHandler(new SupportMagic());
|
||||
BypassHandler.getInstance().registerBypassHandler(new TerritoryStatus());
|
||||
BypassHandler.getInstance().registerBypassHandler(new TerritoryWar());
|
||||
BypassHandler.getInstance().registerBypassHandler(new VoiceCommand());
|
||||
BypassHandler.getInstance().registerBypassHandler(new Wear());
|
||||
_log.config("Loaded " + BypassHandler.getInstance().size() + " BypassHandlers");
|
||||
}
|
||||
|
||||
private static void loadChatHandlers()
|
||||
{
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatAll());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatAlliance());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatBattlefield());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatClan());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatHeroVoice());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatParty());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatPartyMatchRoom());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatPartyRoomAll());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatPartyRoomCommander());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatPetition());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatShout());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatTell());
|
||||
ChatHandler.getInstance().registerChatHandler(new ChatTrade());
|
||||
_log.config("Loaded " + ChatHandler.getInstance().size() + " ChatHandlers");
|
||||
}
|
||||
|
||||
private static void loadItemHandlers()
|
||||
{
|
||||
ItemHandler.getInstance().registerItemHandler(new ScrollOfResurrection());
|
||||
ItemHandler.getInstance().registerItemHandler(new SoulShots());
|
||||
ItemHandler.getInstance().registerItemHandler(new SpiritShot());
|
||||
ItemHandler.getInstance().registerItemHandler(new BlessedSpiritShot());
|
||||
ItemHandler.getInstance().registerItemHandler(new BeastSoulShot());
|
||||
ItemHandler.getInstance().registerItemHandler(new BeastSpiritShot());
|
||||
ItemHandler.getInstance().registerItemHandler(new PaganKeys());
|
||||
ItemHandler.getInstance().registerItemHandler(new Maps());
|
||||
ItemHandler.getInstance().registerItemHandler(new NicknameColor());
|
||||
ItemHandler.getInstance().registerItemHandler(new Recipes());
|
||||
ItemHandler.getInstance().registerItemHandler(new RollingDice());
|
||||
ItemHandler.getInstance().registerItemHandler(new EnchantAttribute());
|
||||
ItemHandler.getInstance().registerItemHandler(new EnchantScrolls());
|
||||
ItemHandler.getInstance().registerItemHandler(new ExtractableItems());
|
||||
ItemHandler.getInstance().registerItemHandler(new Book());
|
||||
ItemHandler.getInstance().registerItemHandler(new SevenSignsRecord());
|
||||
ItemHandler.getInstance().registerItemHandler(new ItemSkills());
|
||||
ItemHandler.getInstance().registerItemHandler(new ItemSkillsTemplate());
|
||||
ItemHandler.getInstance().registerItemHandler(new Seed());
|
||||
ItemHandler.getInstance().registerItemHandler(new Harvester());
|
||||
ItemHandler.getInstance().registerItemHandler(new MercTicket());
|
||||
ItemHandler.getInstance().registerItemHandler(new FishShots());
|
||||
ItemHandler.getInstance().registerItemHandler(new PetFood());
|
||||
ItemHandler.getInstance().registerItemHandler(new SpecialXMas());
|
||||
ItemHandler.getInstance().registerItemHandler(new SummonItems());
|
||||
ItemHandler.getInstance().registerItemHandler(new BeastSpice());
|
||||
ItemHandler.getInstance().registerItemHandler(new TeleportBookmark());
|
||||
ItemHandler.getInstance().registerItemHandler(new Elixir());
|
||||
ItemHandler.getInstance().registerItemHandler(new Disguise());
|
||||
ItemHandler.getInstance().registerItemHandler(new ManaPotion());
|
||||
ItemHandler.getInstance().registerItemHandler(new EnergyStarStone());
|
||||
ItemHandler.getInstance().registerItemHandler(new EventItem());
|
||||
_log.config("Loaded " + ItemHandler.getInstance().size() + " ItemHandlers");
|
||||
}
|
||||
|
||||
private static void loadSkillHandlers()
|
||||
{
|
||||
SkillHandler.getInstance().registerSkillHandler(new Blow());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Pdam());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Mdam());
|
||||
SkillHandler.getInstance().registerSkillHandler(new CpDam());
|
||||
SkillHandler.getInstance().registerSkillHandler(new CpDamPercent());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Manadam());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Heal());
|
||||
SkillHandler.getInstance().registerSkillHandler(new HealPercent());
|
||||
SkillHandler.getInstance().registerSkillHandler(new CombatPointHeal());
|
||||
SkillHandler.getInstance().registerSkillHandler(new ManaHeal());
|
||||
SkillHandler.getInstance().registerSkillHandler(new BalanceLife());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Charge());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Continuous());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Detection());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Resurrect());
|
||||
SkillHandler.getInstance().registerSkillHandler(new ShiftTarget());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Spoil());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Sweep());
|
||||
SkillHandler.getInstance().registerSkillHandler(new StrSiegeAssault());
|
||||
SkillHandler.getInstance().registerSkillHandler(new SummonFriend());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Disablers());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Cancel());
|
||||
SkillHandler.getInstance().registerSkillHandler(new StealBuffs());
|
||||
SkillHandler.getInstance().registerSkillHandler(new BallistaBomb());
|
||||
SkillHandler.getInstance().registerSkillHandler(new TakeCastle());
|
||||
SkillHandler.getInstance().registerSkillHandler(new TakeFort());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Unlock());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Craft());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Fishing());
|
||||
SkillHandler.getInstance().registerSkillHandler(new FishingSkill());
|
||||
SkillHandler.getInstance().registerSkillHandler(new BeastSkills());
|
||||
SkillHandler.getInstance().registerSkillHandler(new DeluxeKey());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Sow());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Soul());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Harvest());
|
||||
SkillHandler.getInstance().registerSkillHandler(new GetPlayer());
|
||||
SkillHandler.getInstance().registerSkillHandler(new TransformDispel());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Trap());
|
||||
SkillHandler.getInstance().registerSkillHandler(new GiveSp());
|
||||
SkillHandler.getInstance().registerSkillHandler(new GiveReco());
|
||||
SkillHandler.getInstance().registerSkillHandler(new GiveVitality());
|
||||
SkillHandler.getInstance().registerSkillHandler(new InstantJump());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Dummy());
|
||||
SkillHandler.getInstance().registerSkillHandler(new Extractable());
|
||||
SkillHandler.getInstance().registerSkillHandler(new RefuelAirShip());
|
||||
SkillHandler.getInstance().registerSkillHandler(new NornilsPower());
|
||||
_log.config("Loaded " + SkillHandler.getInstance().size() + " SkillHandlers");
|
||||
}
|
||||
|
||||
private static void loadUserHandlers()
|
||||
{
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new ClanPenalty());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new ClanWarsList());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new DisMount());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new Escape());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new InstanceZone());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new Loc());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new Mount());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new PartyInfo());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new Time());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new OlympiadStat());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelLeave());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelDelete());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new ChannelListUpdate());
|
||||
UserCommandHandler.getInstance().registerUserCommandHandler(new Birthday());
|
||||
_log.config("Loaded " + UserCommandHandler.getInstance().size() + " UserHandlers");
|
||||
}
|
||||
|
||||
private static void loadVoicedHandlers()
|
||||
{
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new stats());
|
||||
if (Config.L2JMOD_ALLOW_WEDDING)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Wedding());
|
||||
if (Config.BANKING_SYSTEM_ENABLED)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Banking());
|
||||
if (Config.TVT_ALLOW_VOICED_COMMAND)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new TvTVoicedInfo());
|
||||
if (Config.L2JMOD_CHAT_ADMIN)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new ChatAdmin());
|
||||
if (Config.L2JMOD_MULTILANG_ENABLE && Config.L2JMOD_MULTILANG_VOICED_ALLOW)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Lang());
|
||||
if (Config.L2JMOD_DEBUG_VOICE_COMMAND)
|
||||
VoicedCommandHandler.getInstance().registerVoicedCommandHandler(new Debug());
|
||||
_log.config("Loaded " + VoicedCommandHandler.getInstance().size() + " VoicedHandlers");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
_log.config("Loading Handlers...");
|
||||
loadActionHandlers();
|
||||
loadActionShiftHandlers();
|
||||
loadAdminHandlers();
|
||||
loadBypassHandlers();
|
||||
loadChatHandlers();
|
||||
loadItemHandlers();
|
||||
loadSkillHandlers();
|
||||
loadUserHandlers();
|
||||
loadVoicedHandlers();
|
||||
_log.config("Handlers Loaded...");
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
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>
|
||||
*/
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (!((L2Npc)target).canTarget(activeChar))
|
||||
return false;
|
||||
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), 0);
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
// Send a Server->Client packet ValidateLocation to correct the L2ArtefactInstance position and heading on the client
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)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;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ArtefactInstance;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class L2DecoyAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- ((L2Character)target).getLevel()));
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Decoy;
|
||||
}
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.network.serverpackets.ConfirmDlg;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StaticObject;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
public class L2DoorInstanceAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
|
||||
StaticObject su;
|
||||
// send HP amount if doors are inside castle/fortress zone
|
||||
// TODO: needed to be added here doors from conquerable clanhalls
|
||||
if ((((L2DoorInstance)target).getCastle() != null
|
||||
&& ((L2DoorInstance)target).getCastle().getCastleId() > 0)
|
||||
|| (((L2DoorInstance)target).getFort() != null
|
||||
&& ((L2DoorInstance)target).getFort().getFortId() > 0
|
||||
&& !((L2DoorInstance)target).getIsCommanderDoor()))
|
||||
su = new StaticObject((L2DoorInstance)target, true);
|
||||
else
|
||||
su = new StaticObject((L2DoorInstance)target, false);
|
||||
|
||||
activeChar.sendPacket(su);
|
||||
|
||||
// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// MyTargetSelected my = new MyTargetSelected(getObjectId(), activeChar.getLevel());
|
||||
// activeChar.sendPacket(my);
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Math.abs(activeChar.getZ() - target.getZ()) < 400) // this max heigth difference might need some tweaking
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
}
|
||||
else if (activeChar.getClan() != null
|
||||
&& ((L2DoorInstance)target).getClanHall() != null
|
||||
&& activeChar.getClanId() == ((L2DoorInstance)target).getClanHall().getOwnerId())
|
||||
{
|
||||
if (!((L2Character)target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.gatesRequest((L2DoorInstance)target);
|
||||
if (!((L2DoorInstance)target).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).isUnlockable()
|
||||
&& !((L2DoorInstance)target).getFort().getSiege().getIsInProgress())
|
||||
{
|
||||
if (!((L2Character)target).isInsideRadius(activeChar, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.gatesRequest((L2DoorInstance)target);
|
||||
if (!((L2DoorInstance)target).getOpen())
|
||||
activeChar.sendPacket(new ConfirmDlg(1140));
|
||||
else
|
||||
activeChar.sendPacket(new ConfirmDlg(1141));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StaticObject;
|
||||
|
||||
public class L2DoorInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()));
|
||||
|
||||
StaticObject su;
|
||||
// send HP amount if doors are inside castle/fortress zone
|
||||
// TODO: needed to be added here doors from conquerable clanhalls
|
||||
if ((((L2DoorInstance)target).getCastle() != null
|
||||
&& ((L2DoorInstance)target).getCastle().getCastleId() > 0)
|
||||
|| (((L2DoorInstance)target).getFort() != null
|
||||
&& ((L2DoorInstance)target).getFort().getFortId() > 0
|
||||
&& !((L2DoorInstance)target).getIsCommanderDoor()))
|
||||
su = new StaticObject((L2DoorInstance)target, true);
|
||||
else
|
||||
su = new StaticObject((L2DoorInstance)target, false);
|
||||
|
||||
activeChar.sendPacket(su);
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/doorinfo.htm");
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%hp%", String.valueOf((int)((L2Character)target).getCurrentHp()));
|
||||
html.replace("%hpmax%", String.valueOf(((L2Character)target).getMaxHp()));
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%doorid%", String.valueOf(((L2DoorInstance)target).getDoorId()));
|
||||
|
||||
html.replace("%minx%", String.valueOf(((L2DoorInstance)target).getXMin()));
|
||||
html.replace("%miny%", String.valueOf(((L2DoorInstance)target).getYMin()));
|
||||
html.replace("%minz%", String.valueOf(((L2DoorInstance)target).getZMin()));
|
||||
|
||||
html.replace("%maxx%", String.valueOf(((L2DoorInstance)target).getXMax()));
|
||||
html.replace("%maxy%", String.valueOf(((L2DoorInstance)target).getYMax()));
|
||||
html.replace("%maxz%", String.valueOf(((L2DoorInstance)target).getZMax()));
|
||||
html.replace("%unlock%", ((L2DoorInstance)target).isUnlockable() ? "<font color=00FF00>YES<font>" : "<font color=FF0000>NO</font>");
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2DoorInstance;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.MercTicketManager;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
public class L2ItemInstanceAction implements IActionHandler
|
||||
{
|
||||
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(((L2ItemInstance)target).getItemId());
|
||||
|
||||
if (castleId > 0 && (!activeChar.isCastleLord(castleId) || activeChar.isInParty()))
|
||||
{
|
||||
if (activeChar.isInParty()) //do not allow owner who is in party to pick tickets up
|
||||
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()) // cannot pickup
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_PICK_UP, target);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2ItemInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
|
||||
final String html1 = 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(((L2ItemInstance)target).getItemId()),
|
||||
"</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>"
|
||||
);
|
||||
html.setHtml(html1);
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2ItemInstance;
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.quest.Quest;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
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
|
||||
*
|
||||
*/
|
||||
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
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
// The activeChar.getLevel() - getLevel() permit to display the correct color in the select window
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
// Send a Server->Client packet StatusUpdate of the L2Npc to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), 0);
|
||||
activeChar.sendPacket(my);
|
||||
}
|
||||
|
||||
// Send a Server->Client packet ValidateLocation to correct the L2Npc position and heading on the client
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
// 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
|
||||
{
|
||||
if (((L2Npc)target).hasRandomAnimation())
|
||||
((L2Npc)target).onRandomAnimation(Rnd.get(8));
|
||||
|
||||
// Open a chat window on client with the text of the L2Npc
|
||||
if (((L2Npc)target).isEventMob)
|
||||
{
|
||||
L2Event.showEventHtml(activeChar, String.valueOf(target.getObjectId()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Quest[] qlsa = ((L2Npc)target).getTemplate().getEventQuests(Quest.QuestEventType.QUEST_START);
|
||||
if ((qlsa != null) && qlsa.length > 0)
|
||||
activeChar.setLastQuestNpcObject(target.getObjectId());
|
||||
Quest[] qlst = ((L2Npc)target).getTemplate().getEventQuests(Quest.QuestEventType.ON_FIRST_TALK);
|
||||
if ((qlst != null) && qlst.length == 1)
|
||||
qlst[0].notifyFirstTalk((L2Npc)target, activeChar);
|
||||
else
|
||||
((L2Npc)target).showChatWindow(activeChar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2DropCategory;
|
||||
import com.l2jserver.gameserver.model.L2DropData;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.L2MerchantInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jserver.gameserver.skills.BaseStats;
|
||||
import com.l2jserver.gameserver.skills.Stats;
|
||||
import com.l2jserver.gameserver.templates.item.L2Item;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2NpcActionShift implements IActionHandler
|
||||
{
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
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);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
// The activeChar.getLevel() - getLevel() permit to display the correct color in the select window
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
// Check if the activeChar is attackable (without a forced attack)
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
// Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int)((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npcinfo.htm");
|
||||
|
||||
html.replace("%objid%", String.valueOf(target.getObjectId()));
|
||||
html.replace("%class%", target.getClass().getSimpleName());
|
||||
html.replace("%id%", String.valueOf(((L2Npc)target).getTemplate().npcId));
|
||||
html.replace("%lvl%", String.valueOf(((L2Npc)target).getTemplate().level));
|
||||
html.replace("%name%", String.valueOf(((L2Npc)target).getTemplate().name));
|
||||
html.replace("%tmplid%",String.valueOf(((L2Npc)target).getTemplate().npcId));
|
||||
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(((L2Character)target).getRunSpeed()));
|
||||
html.replace("%aspd%", String.valueOf(((L2Character)target).getPAtkSpd()));
|
||||
html.replace("%cspd%", String.valueOf(((L2Character)target).getMAtkSpd()));
|
||||
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("%dist%", String.valueOf((int)Math.sqrt(activeChar.getDistanceSq(target))));
|
||||
|
||||
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("%spawn%", ((L2Npc)target).getSpawn().getLocx()+" "+((L2Npc)target).getSpawn().getLocy()+" "+((L2Npc)target).getSpawn().getLocz());
|
||||
html.replace("%loc2d%", String.valueOf((int)Math.sqrt(((L2Character)target).getPlanDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy()))));
|
||||
html.replace("%loc3d%", String.valueOf((int)Math.sqrt(((L2Character)target).getDistanceSq(((L2Npc)target).getSpawn().getLocx(), ((L2Npc)target).getSpawn().getLocy(), ((L2Npc)target).getSpawn().getLocz()))));
|
||||
html.replace("%resp%", String.valueOf(((L2Npc)target).getSpawn().getRespawnDelay() / 1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%spawn%", "<font color=FF0000>null</font>");
|
||||
html.replace("%loc2d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%loc3d%", "<font color=FF0000>--</font>");
|
||||
html.replace("%resp%", "<font color=FF0000>--</font>");
|
||||
}
|
||||
|
||||
if (((L2Npc)target).hasAI())
|
||||
{
|
||||
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>"+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getClan())+" "+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getClanRange())+"</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>Enemy & Range:</font></td><td align=right width=170>"+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getEnemyClan())+" "+String.valueOf(((L2Npc)target).getTemplate().getAIDataStatic().getEnemyRange())+"</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%", "");
|
||||
}
|
||||
|
||||
if (target instanceof L2MerchantInstance)
|
||||
{
|
||||
html.replace("%butt%","<button value=\"Shop\" action=\"bypass -h admin_showShop "+String.valueOf(((L2Npc)target).getTemplate().npcId)+"\" width=60 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace("%butt%","");
|
||||
}
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if (Config.ALT_GAME_VIEWNPC)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
// The activeChar.getLevel() - getLevel() permit to display the correct color in the select window
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
// Check if the activeChar is attackable (without a forced attack)
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
// Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
int hpMul = Math.round((float)(((L2Character)target).getStat().calcStat(Stats.MAX_HP, 1, (L2Character)target, null) / BaseStats.CON.calcBonus((L2Character)target)));
|
||||
if (hpMul == 0)
|
||||
hpMul = 1;
|
||||
final StringBuilder html1 = StringUtil.startAppend(
|
||||
1000,
|
||||
"<html><body>" +
|
||||
"<br><center><font color=\"LEVEL\">[Combat Stats]</font></center>" +
|
||||
"<table border=0 width=\"100%\">" +
|
||||
"<tr><td>Max.HP</td><td>",
|
||||
String.valueOf(((L2Character)target).getMaxHp() / hpMul),
|
||||
"*",
|
||||
String.valueOf(hpMul),
|
||||
"</td><td>Max.MP</td><td>",
|
||||
String.valueOf(((L2Character)target).getMaxMp()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>P.Atk.</td><td>",
|
||||
String.valueOf(((L2Character)target).getPAtk(null)),
|
||||
"</td><td>M.Atk.</td><td>",
|
||||
String.valueOf(((L2Character)target).getMAtk(null, null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>P.Def.</td><td>",
|
||||
String.valueOf(((L2Character)target).getPDef(null)),
|
||||
"</td><td>M.Def.</td><td>",
|
||||
String.valueOf(((L2Character)target).getMDef(null, null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Accuracy</td><td>",
|
||||
String.valueOf(((L2Character)target).getAccuracy()),
|
||||
"</td><td>Evasion</td><td>",
|
||||
String.valueOf(((L2Character)target).getEvasionRate(null)),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Critical</td><td>",
|
||||
String.valueOf(((L2Character)target).getCriticalHit(null, null)),
|
||||
"</td><td>Speed</td><td>",
|
||||
String.valueOf(((L2Character)target).getRunSpeed()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Atk.Speed</td><td>",
|
||||
String.valueOf(((L2Character)target).getPAtkSpd()),
|
||||
"</td><td>Cast.Speed</td><td>",
|
||||
String.valueOf(((L2Character)target).getMAtkSpd()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>Race</td><td>",
|
||||
((L2Npc)target).getTemplate().getRace().toString(),
|
||||
"</td><td></td><td></td></tr>" +
|
||||
"</table>" +
|
||||
"<br><center><font color=\"LEVEL\">[Basic Stats]</font></center>" +
|
||||
"<table border=0 width=\"100%\">" +
|
||||
"<tr><td>STR</td><td>",
|
||||
String.valueOf(((L2Character)target).getSTR()),
|
||||
"</td><td>DEX</td><td>",
|
||||
String.valueOf(((L2Character)target).getDEX()),
|
||||
"</td><td>CON</td><td>",
|
||||
String.valueOf(((L2Character)target).getCON()),
|
||||
"</td></tr>" +
|
||||
"<tr><td>INT</td><td>",
|
||||
String.valueOf(((L2Character)target).getINT()),
|
||||
"</td><td>WIT</td><td>",
|
||||
String.valueOf(((L2Character)target).getWIT()),
|
||||
"</td><td>MEN</td><td>",
|
||||
String.valueOf(((L2Character)target).getMEN()),
|
||||
"</td></tr>" +
|
||||
"</table>"
|
||||
);
|
||||
|
||||
if (((L2Npc)target).getTemplate().getDropData() != null)
|
||||
{
|
||||
StringUtil.append(html1,
|
||||
"<br><center><font color=\"LEVEL\">[Drop Info]</font></center>" +
|
||||
"<br>Rates legend: <font color=\"ff0000\">50%+</font> <font color=\"00ff00\">30%+</font> <font color=\"0000ff\">less than 30%</font>" +
|
||||
"<table border=0 width=\"100%\">"
|
||||
);
|
||||
for (L2DropCategory cat : ((L2Npc)target).getTemplate().getDropData())
|
||||
{
|
||||
for (L2DropData drop : cat.getAllDrops())
|
||||
{
|
||||
final L2Item item = ItemTable.getInstance().getTemplate(drop.getItemId());
|
||||
if (item == null)
|
||||
continue;
|
||||
|
||||
final String color;
|
||||
|
||||
if (drop.getChance() >= 500000)
|
||||
color = "ff0000";
|
||||
else if (drop.getChance() >= 300000)
|
||||
color = "00ff00";
|
||||
else
|
||||
color = "0000ff";
|
||||
|
||||
StringUtil.append(html1,
|
||||
"<tr><td><font color=\"",
|
||||
color,
|
||||
"\">",
|
||||
item.getName(),
|
||||
"</font></td><td>",
|
||||
(drop.isQuestDrop() ? "Quest" : (cat.isSweep() ? "Sweep" : "Drop")),
|
||||
"</td></tr>"
|
||||
);
|
||||
}
|
||||
}
|
||||
html1.append("</table>");
|
||||
}
|
||||
html1.append("</body></html>");
|
||||
|
||||
html.setHtml(html1.toString());
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Npc;
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the activeChar already target this L2PcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the activeChar
|
||||
// The color to display in the select window is White
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
if (activeChar != target) activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
// Check if this L2PcInstance has a Private Store
|
||||
if (((L2PcInstance)target).getPrivateStoreType() != 0)
|
||||
{
|
||||
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 (Config.GEODATA > 0)
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (Config.GEODATA > 0)
|
||||
{
|
||||
if(GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
else
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
public class L2PcInstanceActionShift implements IActionHandler
|
||||
{
|
||||
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);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
}
|
||||
|
||||
// Send a Server->Client packet ValidateLocation to correct the L2PcInstance position and heading on the client
|
||||
if (activeChar != target)
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
|
||||
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler("admin_character_info");
|
||||
if (ach != null)
|
||||
ach.useAdminCommand("admin_character_info " + target.getName(), activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PcInstance;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetStatusShow;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
public class L2PetInstanceAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean isOwner = activeChar.getObjectId() == ((L2PetInstance)target).getOwner().getObjectId();
|
||||
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
if(isOwner && activeChar != ((L2PetInstance)target).getOwner())
|
||||
((L2PetInstance)target).updateRefOwner(activeChar);
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
_log.fine("new target selected:" + target.getObjectId());
|
||||
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel()));
|
||||
|
||||
// Send a Server->Client packet StatusUpdate of the L2PetInstance to the L2PcInstance to update its HP bar
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
// Check if the pet is attackable (without a forced attack) and isn't dead
|
||||
if (target.isAutoAttackable(activeChar) && !isOwner)
|
||||
{
|
||||
if (Config.GEODATA > 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else if (!((L2Character)target).isInsideRadius(activeChar, 150, false, false))
|
||||
{
|
||||
if (Config.GEODATA > 0)
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isOwner)
|
||||
activeChar.sendPacket(new PetStatusShow((L2PetInstance)target));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2PetInstance;
|
||||
}
|
||||
}
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class L2StaticObjectInstanceAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if(((L2StaticObjectInstance)target).getType() < 0)
|
||||
_log.info("L2StaticObjectInstance: StaticObject with invalid type! StaticObjectId: "+((L2StaticObjectInstance)target).getStaticObjectId());
|
||||
|
||||
// Check if the L2PcInstance already target the L2NpcInstance
|
||||
if (activeChar.getTarget() != target)
|
||||
{
|
||||
// Set the target of the L2PcInstance activeChar
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
|
||||
// Calculate the distance between the L2PcInstance and the L2NpcInstance
|
||||
if (!activeChar.isInsideRadius(target, L2Npc.INTERACTION_DISTANCE, false, false))
|
||||
{
|
||||
// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(((L2StaticObjectInstance)target).getType() == 2)
|
||||
{
|
||||
String filename = "data/html/signboard.htm";
|
||||
String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), filename);
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
|
||||
|
||||
if (content == null)
|
||||
html.setHtml("<html><body>Signboard is missing:<br>"+filename+"</body></html>");
|
||||
else
|
||||
html.setHtml(content);
|
||||
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
else if(((L2StaticObjectInstance)target).getType() == 0)
|
||||
activeChar.sendPacket(((L2StaticObjectInstance)target).getMap());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2StaticObjectInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StaticObject;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class L2StaticObjectInstanceActionShift implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
if (activeChar.getAccessLevel().isGm())
|
||||
{
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), activeChar.getLevel()));
|
||||
|
||||
StaticObject su = new StaticObject((L2StaticObjectInstance)target);
|
||||
activeChar.sendPacket(su);
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(target.getObjectId());
|
||||
final String html1 = 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(((L2StaticObjectInstance)target).getStaticObjectId()),
|
||||
"</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>"
|
||||
);
|
||||
html.setHtml(html1);
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2StaticObjectInstance;
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.GeoData;
|
||||
import com.l2jserver.gameserver.ai.CtrlIntention;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PetStatusShow;
|
||||
import com.l2jserver.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
public class L2SummonAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (activeChar == ((L2Summon)target).getOwner() && activeChar.getTarget() == target)
|
||||
{
|
||||
activeChar.sendPacket(new PetStatusShow((L2Summon)target));
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (activeChar.getTarget() != target)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
_log.fine("new target selected:"+target.getObjectId());
|
||||
|
||||
activeChar.setTarget(target);
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel() - ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
|
||||
//sends HP/MP status of the summon to other characters
|
||||
StatusUpdate su = new StatusUpdate(target);
|
||||
su.addAttribute(StatusUpdate.CUR_HP, (int) ((L2Character)target).getCurrentHp());
|
||||
su.addAttribute(StatusUpdate.MAX_HP, ((L2Character)target).getMaxHp());
|
||||
activeChar.sendPacket(su);
|
||||
}
|
||||
else if (interact)
|
||||
{
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
if (target.isAutoAttackable(activeChar))
|
||||
{
|
||||
if (Config.GEODATA > 0)
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
{
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
|
||||
activeChar.onActionRequest();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (Config.GEODATA > 0)
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTarget(activeChar, target))
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
else
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Summon;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.AdminCommandHandler;
|
||||
import com.l2jserver.gameserver.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ValidateLocation;
|
||||
|
||||
public class L2SummonActionShift implements IActionHandler
|
||||
{
|
||||
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);
|
||||
|
||||
// Send a Server->Client packet MyTargetSelected to the L2PcInstance activeChar
|
||||
activeChar.sendPacket(new MyTargetSelected(target.getObjectId(), 0));
|
||||
}
|
||||
|
||||
// Send a Server->Client packet ValidateLocation to correct the L2PcInstance position and heading on the client
|
||||
activeChar.sendPacket(new ValidateLocation((L2Character)target));
|
||||
|
||||
IAdminCommandHandler ach = AdminCommandHandler.getInstance().getAdminCommandHandler("admin_summon_info");
|
||||
if (ach != null)
|
||||
ach.useAdminCommand("admin_summon_info", activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Summon;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.handler.IActionHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Object.InstanceType;
|
||||
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.MyTargetSelected;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class L2TrapAction implements IActionHandler
|
||||
{
|
||||
public boolean action(L2PcInstance activeChar, L2Object target, boolean interact)
|
||||
{
|
||||
// Aggression target lock effect
|
||||
if (activeChar.isLockedTarget() && activeChar.getLockedTarget() != target)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CHANGE_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.setTarget(target);
|
||||
MyTargetSelected my = new MyTargetSelected(target.getObjectId(), activeChar.getLevel()- ((L2Character)target).getLevel());
|
||||
activeChar.sendPacket(my);
|
||||
return true;
|
||||
}
|
||||
|
||||
public InstanceType getInstanceType()
|
||||
{
|
||||
return InstanceType.L2Trap;
|
||||
}
|
||||
}
|
||||
+453
@@ -0,0 +1,453 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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 javolution.text.TextBuilder;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GmListTable;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.datatables.AccessLevels;
|
||||
import com.l2jserver.gameserver.datatables.AdminCommandAccessRights;
|
||||
import com.l2jserver.gameserver.datatables.DoorTable;
|
||||
import com.l2jserver.gameserver.datatables.ItemTable;
|
||||
import com.l2jserver.gameserver.datatables.MultiSell;
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.datatables.NpcWalkerRoutesTable;
|
||||
import com.l2jserver.gameserver.datatables.SkillTable;
|
||||
import com.l2jserver.gameserver.datatables.TeleportLocationTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.Manager;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.olympiad.Olympiad;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 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|instancemanager
|
||||
* - 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 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_admin8",
|
||||
"admin_gmliston",
|
||||
"admin_gmlistoff",
|
||||
"admin_silence",
|
||||
"admin_diet",
|
||||
"admin_tradeoff",
|
||||
"admin_reload",
|
||||
"admin_set",
|
||||
"admin_set_mod",
|
||||
"admin_saveolymp",
|
||||
"admin_manualhero",
|
||||
"admin_sethero",
|
||||
"admin_endolympiad",
|
||||
"admin_setconfig",
|
||||
"admin_config_server"
|
||||
};
|
||||
|
||||
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"))
|
||||
{
|
||||
GmListTable.getInstance().showGm(activeChar);
|
||||
activeChar.sendMessage("Registered into gm list");
|
||||
AdminHelpPage.showHelpPage(activeChar,"gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_gmlistoff"))
|
||||
{
|
||||
GmListTable.getInstance().hideGm(activeChar);
|
||||
activeChar.sendMessage("Removed from gm list");
|
||||
AdminHelpPage.showHelpPage(activeChar,"gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_silence"))
|
||||
{
|
||||
if (activeChar.isSilenceMode()) // already in message refusal mode
|
||||
{
|
||||
activeChar.setSilenceMode(false);
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MESSAGE_ACCEPTANCE_MODE));
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.setSilenceMode(true);
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.MESSAGE_REFUSAL_MODE));
|
||||
}
|
||||
AdminHelpPage.showHelpPage(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_manualhero") || command.startsWith("admin_sethero"))
|
||||
{
|
||||
L2PcInstance target = null;
|
||||
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
target = (L2PcInstance) activeChar.getTarget();
|
||||
target.setHero(target.isHero() ? false : true);
|
||||
}
|
||||
else
|
||||
{
|
||||
target = activeChar;
|
||||
target.setHero(target.isHero() ? false : true);
|
||||
}
|
||||
target.broadcastUserInfo();
|
||||
}
|
||||
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();
|
||||
}
|
||||
AdminHelpPage.showHelpPage(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");
|
||||
}
|
||||
}
|
||||
AdminHelpPage.showHelpPage(activeChar,"gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_reload"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
String type = "";
|
||||
try
|
||||
{
|
||||
type = st.nextToken();
|
||||
if (type.equals("multisell"))
|
||||
{
|
||||
MultiSell.getInstance().reload();
|
||||
activeChar.sendMessage("All Multisells have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("teleport"))
|
||||
{
|
||||
TeleportLocationTable.getInstance().reloadAll();
|
||||
activeChar.sendMessage("Teleport Locations have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("skill"))
|
||||
{
|
||||
SkillTable.getInstance().reload();
|
||||
activeChar.sendMessage("All Skills have been reloaded");
|
||||
}
|
||||
else if (type.equals("npc"))
|
||||
{
|
||||
NpcTable.getInstance().reloadAllNpc();
|
||||
QuestManager.getInstance().reloadAllQuests();
|
||||
activeChar.sendMessage("All NPCs have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("htm"))
|
||||
{
|
||||
HtmCache.getInstance().reload();
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " megabytes on " + HtmCache.getInstance().getLoadedFiles() + " files loaded");
|
||||
}
|
||||
else if (type.startsWith("item"))
|
||||
{
|
||||
ItemTable.getInstance().reload();
|
||||
activeChar.sendMessage("Item Templates have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("config"))
|
||||
{
|
||||
Config.load();
|
||||
activeChar.sendMessage("All Config Settings have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("instancemanager"))
|
||||
{
|
||||
Manager.reloadAll();
|
||||
activeChar.sendMessage("All Instance Manager has been reloaded");
|
||||
}
|
||||
else if (type.startsWith("npcwalkers"))
|
||||
{
|
||||
NpcWalkerRoutesTable.getInstance().load();
|
||||
activeChar.sendMessage("NPC Walker Routes have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("access"))
|
||||
{
|
||||
AccessLevels.getInstance().reloadAccessLevels();
|
||||
AdminCommandAccessRights.getInstance().reloadAdminCommandAccessRights();
|
||||
activeChar.sendMessage("Access Rights have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("quests"))
|
||||
{
|
||||
QuestManager.getInstance().reloadAllQuests();
|
||||
activeChar.sendMessage("All Quests have been reloaded");
|
||||
}
|
||||
else if (type.startsWith("door"))
|
||||
{
|
||||
DoorTable.getInstance().reloadAll();
|
||||
activeChar.sendMessage("All Doors have been reloaded");
|
||||
}
|
||||
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.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("An error occured while reloading " + type + " !");
|
||||
activeChar.sendMessage("Usage: //reload <multisell|teleport|skill|npc|htm|item|config|instancemanager|npcwalkers|access|quests>");
|
||||
_log.warning("An error occured while reloading " + type + ": " + e); //do not mask an exception here
|
||||
}
|
||||
}
|
||||
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"))
|
||||
AdminHelpPage.showHelpPage(activeChar, "mods_menu.htm");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
case 8:
|
||||
filename = "old";
|
||||
break;
|
||||
default:
|
||||
if (Config.GM_ADMIN_MENU_STYLE.equals("modern"))
|
||||
filename = "main";
|
||||
else
|
||||
filename = "classic";
|
||||
break;
|
||||
}
|
||||
AdminHelpPage.showHelpPage(activeChar, filename + "_menu.htm");
|
||||
}
|
||||
|
||||
public void showConfigPage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
TextBuilder replyMSG = new TextBuilder("<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_DROP_SPOIL
|
||||
+ "</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 Weapon</font> = "
|
||||
+ Config.ENCHANT_CHANCE_WEAPON
|
||||
+ "</td><td><edit var=\"param5\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceWeapon $param5\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Armor</font> = "
|
||||
+ Config.ENCHANT_CHANCE_ARMOR
|
||||
+ "</td><td><edit var=\"param6\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceArmor $param6\" width=40 height=25 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
replyMSG.append("<tr><td><font color=\"LEVEL\">Enchant Jewelry</font> = "
|
||||
+ Config.ENCHANT_CHANCE_JEWELRY
|
||||
+ "</td><td><edit var=\"param7\" width=40 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setconfig EnchantChanceJewelry $param7\" 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 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);
|
||||
}
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import javolution.text.TextBuilder;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.Announcements;
|
||||
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.taskmanager.AutoAnnounceTaskManager;
|
||||
import com.l2jserver.gameserver.taskmanager.AutoAnnounceTaskManager.AutoAnnouncement;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - announce text = announces text to all players
|
||||
* - list_announcements = show menu
|
||||
* - reload_announcements = reloads announcements from txt file
|
||||
* - announce_announcements = announce all stored announcements to all players
|
||||
* - add_announcement text = adds text to startup announcements
|
||||
* - del_announcement id = deletes announcement with respective id
|
||||
*
|
||||
* @version $Revision: 1.4.4.5 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminAnnouncements implements IAdminCommandHandler
|
||||
{
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_list_announcements",
|
||||
"admin_reload_announcements",
|
||||
"admin_announce_announcements",
|
||||
"admin_add_announcement",
|
||||
"admin_del_announcement",
|
||||
"admin_announce",
|
||||
"admin_announce_menu",
|
||||
"admin_list_autoann",
|
||||
"admin_reload_autoann",
|
||||
"admin_add_autoann",
|
||||
"admin_del_autoann"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_list_announcements"))
|
||||
{
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_reload_announcements"))
|
||||
{
|
||||
Announcements.getInstance().loadAnnouncements();
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_announce_menu"))
|
||||
{
|
||||
if (Config.GM_ANNOUNCER_NAME && command.length() > 20)
|
||||
command += " ("+activeChar.getName()+")";
|
||||
Announcements.getInstance().handleAnnounce(command, 20);
|
||||
AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.equals("admin_announce_announcements"))
|
||||
{
|
||||
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
|
||||
// synchronized (L2World.getInstance().getAllPlayers())
|
||||
{
|
||||
for (L2PcInstance player : pls)
|
||||
Announcements.getInstance().showAnnouncements(player);
|
||||
}
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_add_announcement"))
|
||||
{
|
||||
// FIXME the player can send only 16 chars (if you try to send more
|
||||
// it sends null), remove this function or not?
|
||||
if (!command.equals("admin_add_announcement"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(23);
|
||||
Announcements.getInstance().addAnnouncement(val);
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}// ignore errors
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_del_announcement"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(command.substring(23));
|
||||
Announcements.getInstance().delAnnouncement(val);
|
||||
Announcements.getInstance().listAnnouncements(activeChar);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Command is admin announce
|
||||
else if (command.startsWith("admin_announce"))
|
||||
{
|
||||
if (Config.GM_ANNOUNCER_NAME && command.length() > 15)
|
||||
command += " ("+activeChar.getName()+")";
|
||||
// Call method from another class
|
||||
Announcements.getInstance().handleAnnounce(command, 15);
|
||||
}
|
||||
else if (command.startsWith("admin_list_autoann"))
|
||||
{
|
||||
listAutoAnnouncements(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_reload_autoann"))
|
||||
{
|
||||
AutoAnnounceTaskManager.getInstance().restore();
|
||||
activeChar.sendMessage("AutoAnnouncement Reloaded.");
|
||||
listAutoAnnouncements(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_add_autoann"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Not enough parameters for adding autoannounce!");
|
||||
return false;
|
||||
}
|
||||
long initial = Long.parseLong(st.nextToken());
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Not enough parameters for adding autoannounce!");
|
||||
return false;
|
||||
}
|
||||
long delay = Long.parseLong(st.nextToken());
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Not enough parameters for adding autoannounce!");
|
||||
return false;
|
||||
}
|
||||
int repeat = Integer.parseInt(st.nextToken());
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Not enough parameters for adding autoannounce!");
|
||||
return false;
|
||||
}
|
||||
TextBuilder memo = new TextBuilder();
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
memo.append(st.nextToken());
|
||||
memo.append(" ");
|
||||
}
|
||||
|
||||
AutoAnnounceTaskManager.getInstance().addAutoAnnounce(initial*1000, delay*1000, repeat, memo.toString().trim());
|
||||
listAutoAnnouncements(activeChar);
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_del_autoann"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
if (!st.hasMoreTokens())
|
||||
{
|
||||
activeChar.sendMessage("Not enough parameters for deleting autoannounce!");
|
||||
return false;
|
||||
}
|
||||
|
||||
AutoAnnounceTaskManager.getInstance().deleteAutoAnnounce(Integer.parseInt(st.nextToken()));
|
||||
listAutoAnnouncements(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void listAutoAnnouncements(L2PcInstance activeChar)
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtmForce(activeChar.getHtmlPrefix(), "data/html/admin/autoannounce.htm");
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(content);
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(500, "<br>");
|
||||
List<AutoAnnouncement> autoannouncements = AutoAnnounceTaskManager.getInstance().getAutoAnnouncements();
|
||||
for (int i = 0; i < autoannouncements.size(); i++)
|
||||
{
|
||||
AutoAnnouncement autoann = autoannouncements.get(i);
|
||||
TextBuilder memo2 = new TextBuilder();
|
||||
for (String memo0 : autoann.getMemo())
|
||||
{
|
||||
memo2.append(memo0);
|
||||
memo2.append("/n");
|
||||
}
|
||||
replyMSG.append("<table width=260><tr><td width=220>");
|
||||
replyMSG.append(memo2.toString().trim());
|
||||
replyMSG.append("</td><td width=40><button value=\"Delete\" action=\"bypass -h admin_del_autoann ");
|
||||
replyMSG.append(i);
|
||||
replyMSG.append("\" width=60 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr></table>");
|
||||
}
|
||||
adminReply.replace("%announces%", replyMSG.toString());
|
||||
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.communitybbs.Manager.AdminBBSManager;
|
||||
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"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
AdminBBSManager.getInstance().parsecmd(command, activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+460
@@ -0,0 +1,460 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.StringTokenizer;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.L2DatabaseFactory;
|
||||
import com.l2jserver.gameserver.LoginServerThread;
|
||||
import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
|
||||
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.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.util.GMAudit;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - ban_acc <account_name> = changes account access level to -100 and logs him off. If no account is specified target's account is used.
|
||||
* - ban_char <char_name> = changes a characters access level to -100 and logs him off. If no character is specified target is used.
|
||||
* - ban_chat <char_name> <duration> = chat bans a character for the specified duration. If no name is specified the target is chat banned indefinitely.
|
||||
* - unban_acc <account_name> = changes account access level to 0.
|
||||
* - unban_char <char_name> = changes specified characters access level to 0.
|
||||
* - unban_chat <char_name> = lifts chat ban from specified player. If no player name is specified current target is used.
|
||||
* - jail charname [penalty_time] = jails character. Time specified in minutes. For ever if no time is specified.
|
||||
* - unjail charname = Unjails player, teleport him to Floran.
|
||||
*
|
||||
* @version $Revision: 1.1.6.3 $ $Date: 2005/04/11 10:06:06 $
|
||||
* con.close() change by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminBan implements IAdminCommandHandler {
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_ban", // returns ban commands
|
||||
"admin_ban_acc",
|
||||
"admin_ban_char",
|
||||
"admin_ban_chat",
|
||||
"admin_unban", // returns unban commands
|
||||
"admin_unban_acc",
|
||||
"admin_unban_char",
|
||||
"admin_unban_chat",
|
||||
"admin_jail",
|
||||
"admin_unjail"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
String player = "";
|
||||
int duration = -1;
|
||||
L2PcInstance targetPlayer = null;
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
player = st.nextToken();
|
||||
targetPlayer = L2World.getInstance().getPlayer(player);
|
||||
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
try
|
||||
{
|
||||
duration = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Invalid number format used: " + nfe);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (activeChar.getTarget() != null && activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
targetPlayer = (L2PcInstance)activeChar.getTarget();
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPlayer != null && targetPlayer.equals(activeChar))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_ban ") || command.equalsIgnoreCase("admin_ban"))
|
||||
{
|
||||
activeChar.sendMessage("Available ban commands: //ban_acc, //ban_char, //ban_chat");
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_ban_acc"))
|
||||
{
|
||||
// May need to check usage in admin_ban_menu as well.
|
||||
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //ban_acc <account_name> (if none, target char's account gets banned)");
|
||||
return false;
|
||||
}
|
||||
else if (targetPlayer == null)
|
||||
{
|
||||
LoginServerThread.getInstance().sendAccessLevel(player, -100);
|
||||
activeChar.sendMessage("Ban request sent for account "+player);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.ACC, 0);
|
||||
activeChar.sendMessage("Account "+targetPlayer.getAccountName()+" banned.");
|
||||
auditAction(command, activeChar, targetPlayer.getAccountName());
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_ban_char"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //ban_char <char_name> (if none, target char is banned)");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
auditAction(command, activeChar, (targetPlayer == null ? player : targetPlayer.getName()));
|
||||
return changeCharAccessLevel(targetPlayer, player, activeChar, -100);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_ban_chat"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //ban_chat <char_name> [penalty_minutes]");
|
||||
return false;
|
||||
}
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
if (targetPlayer.getPunishLevel().value() > 0)
|
||||
{
|
||||
activeChar.sendMessage(targetPlayer.getName()+" is already jailed or banned.");
|
||||
return false;
|
||||
}
|
||||
String banLengthStr = "";
|
||||
|
||||
targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.CHAT, duration);
|
||||
if (duration > 0)
|
||||
banLengthStr = " for " + duration + " minutes";
|
||||
activeChar.sendMessage(targetPlayer.getName() + " is now chat banned" + banLengthStr + ".");
|
||||
auditAction(command, activeChar, targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
banChatOfflinePlayer(activeChar, player, duration, true);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unban_chat"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //unban_chat <char_name>");
|
||||
return false;
|
||||
}
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
if (targetPlayer.isChatBanned())
|
||||
{
|
||||
targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
|
||||
activeChar.sendMessage(targetPlayer.getName() + "'s chat ban has now been lifted.");
|
||||
auditAction(command, activeChar, targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage(targetPlayer.getName() + " is not currently chat banned.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
banChatOfflinePlayer(activeChar, player, 0, false);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unban ") || command.equalsIgnoreCase("admin_unban"))
|
||||
{
|
||||
activeChar.sendMessage("Available unban commands: //unban_acc, //unban_char, //unban_chat");
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_unban_acc"))
|
||||
{
|
||||
// Need to check admin_unban_menu command as well in AdminMenu.java handler.
|
||||
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
activeChar.sendMessage(targetPlayer.getName()+" is currently online so must not be banned.");
|
||||
return false;
|
||||
}
|
||||
else if (!player.equals(""))
|
||||
{
|
||||
LoginServerThread.getInstance().sendAccessLevel(player, 0);
|
||||
activeChar.sendMessage("Unban request sent for account "+player);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //unban_acc <account_name>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unban_char"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //unban_char <char_name>");
|
||||
return false;
|
||||
}
|
||||
else if (targetPlayer != null)
|
||||
{
|
||||
activeChar.sendMessage(targetPlayer.getName()+" is currently online so must not be banned.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
auditAction(command, activeChar, player);
|
||||
return changeCharAccessLevel(null, player, activeChar, 0);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_jail"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //jail <charname> [penalty_minutes] (if no name is given, selected target is jailed indefinitely)");
|
||||
return false;
|
||||
}
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
if (targetPlayer.isFlyingMounted())
|
||||
targetPlayer.untransform();
|
||||
targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.JAIL, duration);
|
||||
activeChar.sendMessage("Character "+targetPlayer.getName()+" jailed for "+(duration>0 ? duration+" minutes." : "ever!"));
|
||||
auditAction(command, activeChar, targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
jailOfflinePlayer(activeChar, player, duration);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unjail"))
|
||||
{
|
||||
if (targetPlayer == null && player.equals(""))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //unjail <charname> (If no name is given target is used)");
|
||||
return false;
|
||||
}
|
||||
else if (targetPlayer != null)
|
||||
{
|
||||
targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
|
||||
activeChar.sendMessage("Character "+targetPlayer.getName()+" removed from jail");
|
||||
auditAction(command, activeChar, targetPlayer.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
unjailOfflinePlayer(activeChar, player);
|
||||
auditAction(command, activeChar, player);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void auditAction(String fullCommand, L2PcInstance activeChar, String target)
|
||||
{
|
||||
if (!Config.GMAUDIT)
|
||||
return;
|
||||
|
||||
String[] command = fullCommand.split(" ");
|
||||
|
||||
GMAudit.auditGMAction(activeChar.getName()+" ["+activeChar.getObjectId()+"]", command[0], (target.equals("") ? "no-target" : target), (command.length > 2 ? command[2] : ""));
|
||||
}
|
||||
|
||||
private void banChatOfflinePlayer(L2PcInstance activeChar, String name, int delay, boolean ban)
|
||||
{
|
||||
Connection con = null;
|
||||
int level = 0;
|
||||
long value = 0;
|
||||
if(ban)
|
||||
{
|
||||
level = L2PcInstance.PunishLevel.CHAT.value();
|
||||
value = (delay > 0 ? delay * 60000L : 60000);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = L2PcInstance.PunishLevel.NONE.value();
|
||||
value = 0;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET punish_level=?, punish_timer=? WHERE char_name=?");
|
||||
statement.setInt(1, level);
|
||||
statement.setLong(2, value);
|
||||
statement.setString(3, name);
|
||||
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
|
||||
if (count == 0)
|
||||
activeChar.sendMessage("Character not found!");
|
||||
else
|
||||
if(ban)
|
||||
activeChar.sendMessage("Character " + name + " chat-banned for " + (delay > 0 ? delay + " minutes." : "ever!"));
|
||||
else
|
||||
activeChar.sendMessage("Character " + name + "'s chat-banned lifted");
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while chat-banning player");
|
||||
if (Config.DEBUG)
|
||||
se.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
|
||||
statement.setInt(1, -114356);
|
||||
statement.setInt(2, -249645);
|
||||
statement.setInt(3, -2984);
|
||||
statement.setInt(4, L2PcInstance.PunishLevel.JAIL.value());
|
||||
statement.setLong(5, (delay > 0 ? delay * 60000L : 0));
|
||||
statement.setString(6, name);
|
||||
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
|
||||
if (count == 0)
|
||||
activeChar.sendMessage("Character not found!");
|
||||
else
|
||||
activeChar.sendMessage("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while jailing player");
|
||||
if (Config.DEBUG)
|
||||
se.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
|
||||
statement.setInt(1, 17836);
|
||||
statement.setInt(2, 170178);
|
||||
statement.setInt(3, -3507);
|
||||
statement.setInt(4, 0);
|
||||
statement.setLong(5, 0);
|
||||
statement.setString(6, name);
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
if (count == 0)
|
||||
activeChar.sendMessage("Character not found!");
|
||||
else
|
||||
activeChar.sendMessage("Character " + name + " removed from jail");
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while jailing player");
|
||||
if (Config.DEBUG)
|
||||
se.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean changeCharAccessLevel(L2PcInstance targetPlayer, String player, L2PcInstance activeChar, int lvl)
|
||||
{
|
||||
if (targetPlayer != null)
|
||||
{
|
||||
targetPlayer.setAccessLevel(lvl);
|
||||
targetPlayer.sendMessage("Your character has been banned. Goodbye.");
|
||||
targetPlayer.logout();
|
||||
RegionBBSManager.getInstance().changeCommunityBoard();
|
||||
activeChar.sendMessage("The character " + targetPlayer.getName() + " has now been banned.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
|
||||
statement.setInt(1, lvl);
|
||||
statement.setString(2, player);
|
||||
statement.execute();
|
||||
int count = statement.getUpdateCount();
|
||||
statement.close();
|
||||
if (count == 0)
|
||||
{
|
||||
activeChar.sendMessage("Character not found or access level unaltered.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage(player + " now has an access level of " + lvl);
|
||||
}
|
||||
catch (SQLException se)
|
||||
{
|
||||
activeChar.sendMessage("SQLException while changing character's access level");
|
||||
if (Config.DEBUG)
|
||||
se.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList() {
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+317
@@ -0,0 +1,317 @@
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Effect;
|
||||
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;
|
||||
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_stopbuff",
|
||||
"admin_stopallbuffs",
|
||||
"admin_areacancel",
|
||||
"admin_removereuse"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.startsWith("admin_getbuffs"))
|
||||
{
|
||||
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)
|
||||
{
|
||||
int page = 1;
|
||||
if (st.hasMoreTokens())
|
||||
page = Integer.parseInt(st.nextToken());
|
||||
showBuffs(activeChar, player, page);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("The player " + playername + " is not online");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2Character))
|
||||
{
|
||||
showBuffs(activeChar, (L2Character) activeChar.getTarget(), 1);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
|
||||
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 instanceof L2PcInstance) && !(knownChar.equals(activeChar)))
|
||||
knownChar.stopAllEffects();
|
||||
}
|
||||
|
||||
activeChar.sendMessage("All effects canceled within raidus " + 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() instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) activeChar.getTarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.TARGET_IS_INCORRECT);
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
player.getReuseTimeStamp().clear();
|
||||
player.getDisabledSkills().clear();
|
||||
player.sendPacket(new SkillCoolTime(player));
|
||||
activeChar.sendMessage("Skill reuse was removed from " + player.getName() + ".");
|
||||
return true;
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
public void showBuffs(L2PcInstance activeChar, L2Character target, int page)
|
||||
{
|
||||
final L2Effect[] effects = target.getAllEffects();
|
||||
|
||||
if (page > effects.length / PAGE_LIMIT + 1 || page < 1)
|
||||
return;
|
||||
|
||||
int max = effects.length / PAGE_LIMIT;
|
||||
if (effects.length > PAGE_LIMIT * max)
|
||||
max++;
|
||||
|
||||
final StringBuilder html = StringUtil.startAppend(500 + effects.length * 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.length);
|
||||
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
L2Effect e = effects[i];
|
||||
if (e != null)
|
||||
{
|
||||
StringUtil.append(html,
|
||||
"<tr><td>",
|
||||
e.getSkill().getName(),
|
||||
"</td><td>",
|
||||
e.getSkill().isToggle() ? "toggle" : e.getAbnormalTime() - e.getTime() + "s",
|
||||
"</td><td><button value=\"Remove\" action=\"bypass -h admin_stopbuff ",
|
||||
Integer.toString(target.getObjectId()),
|
||||
" ",
|
||||
String.valueOf(e.getSkill().getId()),
|
||||
"\" width=60 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
|
||||
}
|
||||
}
|
||||
|
||||
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 ");
|
||||
html.append(target.getName());
|
||||
html.append(" ");
|
||||
html.append(x + 1);
|
||||
html.append("\"> Page ");
|
||||
html.append(pagenr);
|
||||
html.append(" </a></td>");
|
||||
}
|
||||
}
|
||||
|
||||
html.append("</tr></table>");
|
||||
|
||||
StringUtil.append(html, "<br><center><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\"></html>");
|
||||
|
||||
NpcHtmlMessage ms = new NpcHtmlMessage(1);
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
|
||||
if (Config.GMAUDIT)
|
||||
GMAudit.auditGMAction(activeChar.getName()+" ["+activeChar.getObjectId()+"]", "getbuffs", target.getName() + " (" + Integer.toString(target.getObjectId()) + ")", "");
|
||||
}
|
||||
|
||||
private 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))
|
||||
{
|
||||
L2Effect[] effects = target.getAllEffects();
|
||||
|
||||
for (L2Effect e : effects)
|
||||
{
|
||||
if ((e != null) && (e.getSkill().getId() == skillId))
|
||||
{
|
||||
e.exit();
|
||||
activeChar.sendMessage("Removed " + e.getSkill().getName() + " level " + e.getSkill().getLevel() + " from " + target.getName() + " (" + objId + ")");
|
||||
}
|
||||
}
|
||||
showBuffs(activeChar, target, 1);
|
||||
if (Config.GMAUDIT)
|
||||
GMAudit.auditGMAction(activeChar.getName()+" ["+activeChar.getObjectId()+"]", "stopbuff", target.getName() + " (" + objId + ")", Integer.toString(skillId));
|
||||
}
|
||||
}
|
||||
|
||||
private 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);
|
||||
if (Config.GMAUDIT)
|
||||
GMAudit.auditGMAction(activeChar.getName()+" ["+activeChar.getObjectId()+"]", "stopallbuffs", target.getName() + " (" + objId + ")", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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 com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.cache.CrestCache;
|
||||
import com.l2jserver.gameserver.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
|
||||
/**
|
||||
* @author Layanere
|
||||
*
|
||||
*/
|
||||
public class AdminCache implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_cache_htm_rebuild",
|
||||
"admin_cache_htm_reload",
|
||||
"admin_cache_reload_path",
|
||||
"admin_cache_reload_file",
|
||||
"admin_cache_crest_rebuild",
|
||||
"admin_cache_crest_reload",
|
||||
"admin_cache_crest_fix"
|
||||
};
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.startsWith("admin_cache_htm_rebuild") || command.equals("admin_cache_htm_reload"))
|
||||
{
|
||||
HtmCache.getInstance().reload(Config.DATAPACK_ROOT);
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " MB on " + HtmCache.getInstance().getLoadedFiles() + " file(s) loaded.");
|
||||
}
|
||||
else if (command.startsWith("admin_cache_reload_path "))
|
||||
{
|
||||
try
|
||||
{
|
||||
String path = command.split(" ")[1];
|
||||
HtmCache.getInstance().reloadPath(new File(Config.DATAPACK_ROOT, path));
|
||||
activeChar.sendMessage("Cache[HTML]: " + HtmCache.getInstance().getMemoryUsage() + " MB in " + HtmCache.getInstance().getLoadedFiles() + " file(s) loaded.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cache_reload_path <path>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_cache_reload_file "))
|
||||
{
|
||||
try
|
||||
{
|
||||
String path = command.split(" ")[1];
|
||||
if (HtmCache.getInstance().loadFile(new File(Config.DATAPACK_ROOT, path)) != null)
|
||||
{
|
||||
activeChar.sendMessage("Cache[HTML]: file was loaded");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Cache[HTML]: file can't be loaded");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cache_reload_file <relative_path/file>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_cache_crest_rebuild") || command.startsWith("admin_cache_crest_reload"))
|
||||
{
|
||||
CrestCache.getInstance().reload();
|
||||
activeChar.sendMessage("Cache[Crest]: " + String.format("%.3f", CrestCache.getInstance().getMemoryUsage()) + " megabytes on " + CrestCache.getInstance().getLoadedFiles() + " files loaded");
|
||||
}
|
||||
else if (command.startsWith("admin_cache_crest_fix"))
|
||||
{
|
||||
CrestCache.getInstance().convertOldPedgeFiles();
|
||||
activeChar.sendMessage("Cache[Crest]: crests fixed");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.network.serverpackets.SpecialCamera;
|
||||
|
||||
public class AdminCamera implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_camera"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
final L2Character target = (L2Character)activeChar.getTarget();
|
||||
final String[] com = command.split(" ");
|
||||
|
||||
target.broadcastPacket(new SpecialCamera(target.getObjectId(), 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])));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //camera dist yaw pitch time duration turn rise widescreen unknown");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
Vendored
+137
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.handler.IAdminCommandHandler;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - changelvl = change a character's access level
|
||||
* Can be used for character ban (as opposed to regular //ban that affects accounts)
|
||||
* or to grant mod/GM privileges ingame
|
||||
* @version $Revision: 1.1.2.2.2.3 $ $Date: 2005/04/11 10:06:00 $
|
||||
* con.close() change by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminChangeAccessLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_changelvl"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
handleChangeLevel(command, activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* If no character name is specified, tries to change GM's target access
|
||||
* level. Else if a character name is provided, will try to reach it either
|
||||
* from L2World or from a database connection.
|
||||
*
|
||||
* @param command
|
||||
* @param activeChar
|
||||
*/
|
||||
private void handleChangeLevel(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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param player
|
||||
* @param lvl
|
||||
*/
|
||||
private void onLineChange(L2PcInstance activeChar, L2PcInstance player, int lvl)
|
||||
{
|
||||
player.setAccessLevel(lvl);
|
||||
if (lvl >= 0)
|
||||
player.sendMessage("Your access level has been changed to " + lvl);
|
||||
else
|
||||
{
|
||||
player.sendMessage("Your character has been banned. Bye.");
|
||||
player.logout();
|
||||
}
|
||||
activeChar.sendMessage("Character's access level is now set to " + lvl + ". Effects won't be noticeable until next session.");
|
||||
}
|
||||
}
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.gameserver.cache.HtmCache;
|
||||
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.instancemanager.SiegeManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2ClanMember;
|
||||
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.communityserver.CommunityServerThread;
|
||||
import com.l2jserver.gameserver.network.communityserver.writepackets.WorldInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author ThE_PuNiSHeR a.k.a UnAfraid
|
||||
*/
|
||||
public class AdminClan implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_clan_info",
|
||||
"admin_clan_changeleader"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
String cmd = st.nextToken();
|
||||
if (cmd.startsWith("admin_clan_info"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int objectId = 0;
|
||||
try
|
||||
{
|
||||
objectId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (NoSuchElementException NSEE)
|
||||
{
|
||||
objectId = activeChar.getTargetId();
|
||||
}
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(objectId);
|
||||
if (player != null)
|
||||
{
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
NpcHtmlMessage msg = new NpcHtmlMessage(0);
|
||||
String htm = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/claninfo.htm");
|
||||
msg.setHtml(htm.toString());
|
||||
msg.replace("%clan_name%", clan.getName());
|
||||
msg.replace("%clan_leader%", clan.getLeaderName());
|
||||
msg.replace("%clan_level%", String.valueOf(clan.getLevel()));
|
||||
msg.replace("%clan_has_castle%", clan.getHasCastle() > 0 ? CastleManager.getInstance().getCastleById(clan.getHasCastle()).getName() : "No");
|
||||
msg.replace("%clan_has_clanhall%", clan.getHasHideout() > 0 ? ClanHallManager.getInstance().getClanHallById(clan.getHasHideout()).getName() : "No");
|
||||
msg.replace("%clan_has_fortress%", clan.getHasFort() > 0 ? FortManager.getInstance().getFortById(clan.getHasFort()).getName() : "No");
|
||||
msg.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
|
||||
msg.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
|
||||
msg.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
|
||||
msg.replace("%current_player_objectId%", String.valueOf(objectId));
|
||||
msg.replace("%current_player_name%", player.getName());
|
||||
activeChar.sendPacket(msg);
|
||||
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
npe.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Clan not found.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Player is offline!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("This shouldn't happening");
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (cmd.startsWith("admin_clan_changeleader"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int objectId = Integer.parseInt(st.nextToken());
|
||||
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(objectId);
|
||||
if (player != null)
|
||||
{
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Player don't have clan");
|
||||
return false;
|
||||
}
|
||||
for (L2ClanMember member : clan.getMembers())
|
||||
{
|
||||
if (member.getObjectId() == player.getObjectId())
|
||||
{
|
||||
L2PcInstance exLeader = clan.getLeader().getPlayerInstance();
|
||||
if (exLeader != null)
|
||||
{
|
||||
SiegeManager.getInstance().removeSiegeSkills(exLeader);
|
||||
exLeader.setClan(clan);
|
||||
exLeader.setClanPrivileges(L2Clan.CP_NOTHING);
|
||||
exLeader.broadcastUserInfo();
|
||||
exLeader.setPledgeClass(exLeader.getClan().getClanMember(exLeader.getObjectId()).calculatePledgeClass(exLeader));
|
||||
exLeader.broadcastUserInfo();
|
||||
exLeader.checkItemRestriction();
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: with query?
|
||||
}
|
||||
|
||||
clan.setLeader(member);
|
||||
clan.updateClanInDB();
|
||||
|
||||
L2PcInstance newLeader = member.getPlayerInstance();
|
||||
newLeader.setClan(clan);
|
||||
newLeader.setPledgeClass(member.calculatePledgeClass(newLeader));
|
||||
newLeader.setClanPrivileges(L2Clan.CP_ALL);
|
||||
|
||||
if (clan.getLevel() >= SiegeManager.getInstance().getSiegeClanMinLevel())
|
||||
SiegeManager.getInstance().addSiegeSkills(newLeader);
|
||||
|
||||
newLeader.broadcastUserInfo();
|
||||
|
||||
clan.broadcastClanStatus();
|
||||
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_PRIVILEGES_HAVE_BEEN_TRANSFERRED_TO_C1);
|
||||
sm.addString(newLeader.getName());
|
||||
clan.broadcastToOnlineMembers(sm);
|
||||
activeChar.sendMessage("Clan leader has been changed!");
|
||||
CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, clan, WorldInfo.TYPE_UPDATE_CLAN_DATA));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Player is offline");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+253
@@ -0,0 +1,253 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.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.templates.item.L2Item;
|
||||
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_itemcreate"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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.");
|
||||
}
|
||||
AdminHelpPage.showHelpPage(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.");
|
||||
}
|
||||
AdminHelpPage.showHelpPage(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.");
|
||||
}
|
||||
AdminHelpPage.showHelpPage(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;
|
||||
}
|
||||
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
|
||||
{
|
||||
for (L2PcInstance onlinePlayer : pls)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.gameserver.network.serverpackets.SystemMessage;
|
||||
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;
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.FRIEND_LIST_FOOTER));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final Collection<CursedWeapon> cws = cwm.getCursedWeapons();
|
||||
final StringBuilder replyMSG =
|
||||
new StringBuilder(cws.size() * 300);
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/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);
|
||||
if (cw == null)
|
||||
{
|
||||
activeChar.sendMessage("Unknown cursed weapon ID.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cw_remove|//cw_goto|//cw_add <itemid|name>");
|
||||
}
|
||||
|
||||
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 == null)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //cw_add <itemid|name>");
|
||||
return false;
|
||||
}
|
||||
else 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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
|
||||
public class AdminDebug implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_debug"
|
||||
};
|
||||
|
||||
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.sendMessage("Player not found.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
target = activeChar.getTarget();
|
||||
|
||||
if (target instanceof L2Character)
|
||||
setDebug(activeChar, (L2Character)target);
|
||||
else
|
||||
setDebug(activeChar, activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_delete"))
|
||||
handleDelete(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
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.getNpcid()))
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
else
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
|
||||
activeChar.sendMessage("Deleted " + target.getName() + " from " + target.getObjectId() + ".");
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("Incorrect target.");
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_character_disconnect"))
|
||||
{
|
||||
disconnectCharacter(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.DoorTable;
|
||||
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 DoorTable _doorTable = DoorTable.getInstance();
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_open",
|
||||
"admin_close",
|
||||
"admin_openall",
|
||||
"admin_closeall"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+1459
File diff suppressed because it is too large
Load Diff
+1771
File diff suppressed because it is too large
Load Diff
+826
@@ -0,0 +1,826 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.communitybbs.Manager.RegionBBSManager;
|
||||
import com.l2jserver.gameserver.datatables.SkillTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.Earthquake;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
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.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SSQInfo;
|
||||
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.SystemMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
import com.l2jserver.gameserver.skills.AbnormalEffect;
|
||||
import com.l2jserver.gameserver.util.Broadcast;
|
||||
|
||||
|
||||
/**
|
||||
* 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_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_social_menu",
|
||||
"admin_special",
|
||||
"admin_special_menu",
|
||||
"admin_effect_menu",
|
||||
"admin_abnormal",
|
||||
"admin_abnormal_menu",
|
||||
"admin_play_sounds",
|
||||
"admin_play_sound",
|
||||
"admin_atmosphere",
|
||||
"admin_atmosphere_menu",
|
||||
"admin_set_displayeffect",
|
||||
"admin_set_displayeffect_menu"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
|
||||
if (command.equals("admin_invis_menu"))
|
||||
{
|
||||
if (!activeChar.getAppearance().getInvisible())
|
||||
{
|
||||
activeChar.getAppearance().setInvisible();
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.getAppearance().setVisible();
|
||||
activeChar.broadcastUserInfo();
|
||||
}
|
||||
RegionBBSManager.getInstance().changeCommunityBoard();
|
||||
command = "";
|
||||
AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_invis"))
|
||||
{
|
||||
activeChar.getAppearance().setInvisible();
|
||||
activeChar.broadcastUserInfo();
|
||||
activeChar.decayMe();
|
||||
activeChar.spawnMe();
|
||||
RegionBBSManager.getInstance().changeCommunityBoard();
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_vis"))
|
||||
{
|
||||
activeChar.getAppearance().setVisible();
|
||||
activeChar.broadcastUserInfo();
|
||||
RegionBBSManager.getInstance().changeCommunityBoard();
|
||||
}
|
||||
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>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_play_sounds"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "songs/songs.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_play_sounds"))
|
||||
{
|
||||
try
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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();
|
||||
//synchronized (activeChar.getKnownList().getKnownPlayers())
|
||||
{
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
if (!player.isGM())
|
||||
{
|
||||
player.startAbnormalEffect(AbnormalEffect.HOLD_1);
|
||||
player.setIsParalyzed(true);
|
||||
player.startParalyze();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpara_all"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
//synchronized (activeChar.getKnownList().getKnownPlayers())
|
||||
{
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
player.stopAbnormalEffect(AbnormalEffect.HOLD_1);
|
||||
player.setIsParalyzed(false);
|
||||
player.stopParalyze(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.startAbnormalEffect(AbnormalEffect.HOLD_1);
|
||||
else
|
||||
player.startAbnormalEffect(AbnormalEffect.HOLD_2);
|
||||
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.stopAbnormalEffect(AbnormalEffect.HOLD_1);
|
||||
else
|
||||
player.stopAbnormalEffect(AbnormalEffect.HOLD_2);
|
||||
player.setIsParalyzed(false);
|
||||
player.stopParalyze(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.startAbnormalEffect(AbnormalEffect.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.stopAbnormalEffect(AbnormalEffect.BIG_HEAD);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_gmspeed"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(st.nextToken());
|
||||
boolean sendMessage = activeChar.getFirstEffect(7029) != null;
|
||||
activeChar.stopSkillEffects(7029);
|
||||
if (val == 0 && sendMessage)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.EFFECT_S1_DISAPPEARED).addSkillName(7029));
|
||||
}
|
||||
else if ((val >= 1) && (val <= 4))
|
||||
{
|
||||
L2Skill gmSpeedSkill = SkillTable.getInstance().getInfo(7029, val);
|
||||
activeChar.doSimultaneousCast(gmSpeedSkill);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //gmspeed <value> (0=off...4=max)");
|
||||
}
|
||||
if(command.contains("_menu"))
|
||||
{
|
||||
command="";
|
||||
AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_polyself"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String id = st.nextToken();
|
||||
activeChar.getPoly().setPolyInfo("npc", id);
|
||||
activeChar.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), false);
|
||||
CharInfo info1 = new CharInfo(activeChar);
|
||||
activeChar.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(activeChar);
|
||||
activeChar.sendPacket(info2);
|
||||
activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
|
||||
}
|
||||
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);
|
||||
activeChar.broadcastPacket(new ExBrExtraUserInfo(activeChar));
|
||||
}
|
||||
else if (command.equals("admin_clearteams"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
//synchronized (activeChar.getKnownList().getKnownPlayers())
|
||||
{
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
player.setTeam(0);
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setteam_close"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = st.nextToken();
|
||||
int teamVal = Integer.parseInt(val);
|
||||
Collection<L2PcInstance> plrs = activeChar.getKnownList().getKnownPlayers().values();
|
||||
//synchronized (activeChar.getKnownList().getKnownPlayers())
|
||||
{
|
||||
for (L2PcInstance player : plrs)
|
||||
{
|
||||
if (activeChar.isInsideRadius(player, 400, false, true))
|
||||
{
|
||||
player.setTeam(teamVal);
|
||||
if (teamVal != 0)
|
||||
{
|
||||
player.sendMessage("You have joined team " + teamVal);
|
||||
}
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setteam_close <teamId>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_setteam"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = st.nextToken();
|
||||
int teamVal = Integer.parseInt(val);
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
return false;
|
||||
player.setTeam(teamVal);
|
||||
if (teamVal != 0)
|
||||
{
|
||||
player.sendMessage("You have joined team " + teamVal);
|
||||
}
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //setteam <teamId>");
|
||||
}
|
||||
}
|
||||
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();
|
||||
//synchronized (activeChar.getKnownList().getKnownObjects())
|
||||
{
|
||||
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(SystemMessage.getSystemMessage(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_abnormal"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String target = null;
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String parm = st.nextToken();
|
||||
int abnormal = Integer.decode("0x" + parm);
|
||||
target = st.nextToken();
|
||||
if (target != null)
|
||||
{
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(target);
|
||||
if (player != null)
|
||||
{
|
||||
if (performAbnormal(abnormal, player))
|
||||
activeChar.sendMessage(player.getName() + "'s abnormal status was affected by your request.");
|
||||
else
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(target);
|
||||
Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
//synchronized (activeChar.getKnownList().getKnownObjects())
|
||||
{
|
||||
for (L2Object object : objs)
|
||||
if (activeChar.isInsideRadius(object, radius, false, false))
|
||||
performAbnormal(abnormal, object);
|
||||
activeChar.sendMessage(radius + " units radius affected by your request.");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nbe)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //abnormal <hex_abnormal_mask> [player|radius]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
int abnormal = Integer.decode("0x" + st.nextToken());
|
||||
if (obj == null)
|
||||
obj = activeChar;
|
||||
|
||||
if (performAbnormal(abnormal, obj))
|
||||
activeChar.sendMessage(obj.getName() + "'s abnormal status was affected by your request.");
|
||||
else
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
}
|
||||
else if (!command.contains("menu"))
|
||||
activeChar.sendMessage("Usage: //abnormal <abnormal_mask> [player_name|radius]");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_special"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String target = null;
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (st.countTokens() == 2)
|
||||
{
|
||||
String parm = st.nextToken();
|
||||
int special = Integer.decode("0x" + parm);
|
||||
target = st.nextToken();
|
||||
if (target != null)
|
||||
{
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(target);
|
||||
if (player != null)
|
||||
{
|
||||
if (performSpecial(special, player))
|
||||
activeChar.sendMessage(player.getName() + "'s special status was affected by your request.");
|
||||
else
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int radius = Integer.parseInt(target);
|
||||
Collection<L2Object> objs = activeChar.getKnownList().getKnownObjects().values();
|
||||
//synchronized (activeChar.getKnownList().getKnownObjects())
|
||||
{
|
||||
for (L2Object object : objs)
|
||||
if (activeChar.isInsideRadius(object, radius, false, false))
|
||||
performSpecial(special, object);
|
||||
activeChar.sendMessage(radius + " units radius affected by your request.");
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException nbe)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //special <hex_special_mask> [player|radius]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (st.countTokens() == 1)
|
||||
{
|
||||
int special = Integer.decode("0x" + st.nextToken());
|
||||
if (obj == null)
|
||||
obj = activeChar;
|
||||
|
||||
if (performSpecial(special, obj))
|
||||
activeChar.sendMessage(obj.getName() + "'s special status was affected by your request.");
|
||||
else
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
}
|
||||
else if (!command.contains("menu"))
|
||||
activeChar.sendMessage("Usage: //special <special_mask> [player_name|radius]");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (Config.DEBUG)
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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.INCORRECT_TARGET);
|
||||
return false;
|
||||
}
|
||||
L2Npc npc = (L2Npc) target;
|
||||
try
|
||||
{
|
||||
String type = st.nextToken();
|
||||
int diplayeffect = Integer.parseInt(type);
|
||||
npc.setDisplayEffect(diplayeffect);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //set_displayeffect <id>");
|
||||
}
|
||||
}
|
||||
if (command.contains("menu"))
|
||||
showMainPage(activeChar, command);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action bitmask that should be applied over target's abnormal
|
||||
* @param target
|
||||
* @return <i>true</i> if target's abnormal state was affected , <i>false</i> otherwise.
|
||||
*/
|
||||
private boolean performAbnormal(int action, L2Object target)
|
||||
{
|
||||
if (target instanceof L2Character)
|
||||
{
|
||||
L2Character character = (L2Character) target;
|
||||
if ((character.getAbnormalEffect() & action) == action)
|
||||
character.stopAbnormalEffect(action);
|
||||
else
|
||||
character.startAbnormalEffect(action);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean performSpecial(int action, L2Object target)
|
||||
{
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
L2Character character = (L2Character) target;
|
||||
if ((character.getSpecialEffect() & action) == action)
|
||||
character.stopSpecialEffect(action);
|
||||
else
|
||||
character.startSpecialEffect(action);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean performSocial(int action, L2Object target, L2PcInstance activeChar)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (target instanceof L2Character)
|
||||
{
|
||||
if (target instanceof L2ChestInstance)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
return false;
|
||||
}
|
||||
if ((target instanceof L2Npc) && (action < 1 || action > 3))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
return false;
|
||||
}
|
||||
if ((target instanceof L2PcInstance) && (action < 2 || action > 18 && action != SocialAction.LEVEL_UP))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOTHING_HAPPENED));
|
||||
return false;
|
||||
}
|
||||
L2Character character = (L2Character) target;
|
||||
character.broadcastPacket(new SocialAction(character, action));
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type - atmosphere type (signssky,sky)
|
||||
* @param state - atmosphere state(night,day)
|
||||
* @param duration
|
||||
*/
|
||||
private void adminAtmosphere(String type, String state, int duration, L2PcInstance activeChar)
|
||||
{
|
||||
L2GameServerPacket packet = null;
|
||||
|
||||
if (type.equals("signsky"))
|
||||
{
|
||||
if (state.equals("dawn"))
|
||||
packet = new SSQInfo(2);
|
||||
else if (state.equals("dusk"))
|
||||
packet = new SSQInfo(1);
|
||||
}
|
||||
else if (type.equals("sky"))
|
||||
{
|
||||
if (state.equals("night"))
|
||||
packet = new SunSet();
|
||||
else if (state.equals("day"))
|
||||
packet = new SunRise();
|
||||
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>");
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar, String command)
|
||||
{
|
||||
String filename = "effects_menu";
|
||||
if (command.contains("abnormal"))
|
||||
filename = "abnormal";
|
||||
else if (command.contains("special"))
|
||||
filename = "special";
|
||||
else if (command.contains("social"))
|
||||
filename = "social";
|
||||
AdminHelpPage.showHelpPage(activeChar, filename + ".htm");
|
||||
}
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
||||
* 02111-1307, USA.
|
||||
*
|
||||
* http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
package handlers.admincommandhandlers;
|
||||
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.Elementals;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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 + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.L2ItemInstance;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
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"
|
||||
};
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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));
|
||||
player.broadcastPacket(new ExBrExtraUserInfo(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)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "enchant.htm");
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+816
@@ -0,0 +1,816 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
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.entity.L2Event;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CharInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.PlaySound;
|
||||
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
|
||||
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_prize",
|
||||
"admin_event_control_chatban",
|
||||
"admin_event_control_finish"
|
||||
};
|
||||
|
||||
private static String tempBuffer = "";
|
||||
private static String tempName = "";
|
||||
private static boolean npcsDeleted = false;
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_event"))
|
||||
showMainPage(activeChar);
|
||||
|
||||
else if (command.equals("admin_event_new"))
|
||||
{
|
||||
showNewEventPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_add"))
|
||||
{
|
||||
tempBuffer += command.substring(10);
|
||||
showNewEventPage(activeChar);
|
||||
|
||||
}
|
||||
else if (command.startsWith("admin_event_see"))
|
||||
{
|
||||
String eventName = command.substring(16);
|
||||
try
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("data/events/" + eventName)));
|
||||
BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
final String replyMSG = StringUtil.concat(
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">",
|
||||
eventName,
|
||||
"</font><font color=\"FF0000\"> bY ",
|
||||
inbr.readLine(),
|
||||
"</font></center><br>" +
|
||||
"<br>",
|
||||
inbr.readLine(),
|
||||
"</body></html>"
|
||||
);
|
||||
adminReply.setHtml(replyMSG);
|
||||
activeChar.sendPacket(adminReply);
|
||||
inbr.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (command.startsWith("admin_event_del"))
|
||||
{
|
||||
String eventName = command.substring(16);
|
||||
File file = new File("data/events/" + eventName);
|
||||
file.delete();
|
||||
showMainPage(activeChar);
|
||||
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_event_name"))
|
||||
{
|
||||
tempName += command.substring(17);
|
||||
showNewEventPage(activeChar);
|
||||
|
||||
}
|
||||
|
||||
else if (command.equalsIgnoreCase("admin_delete_buffer"))
|
||||
{
|
||||
try
|
||||
{
|
||||
tempBuffer += tempBuffer.substring(0, tempBuffer.length() - 10);
|
||||
showNewEventPage(activeChar);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
tempBuffer = "";
|
||||
}
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_event_store"))
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
FileOutputStream file = new FileOutputStream("data/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 (command.startsWith("admin_event_set"))
|
||||
{
|
||||
L2Event.eventName = command.substring(16);
|
||||
showEventParameters(activeChar, 2);
|
||||
|
||||
}
|
||||
else if (command.startsWith("admin_event_change_teams_number"))
|
||||
{
|
||||
showEventParameters(activeChar, Integer.parseInt(command.substring(32)));
|
||||
}
|
||||
else if (command.startsWith("admin_event_panel"))
|
||||
{
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_begin"))
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
L2Event.active = true;
|
||||
L2Event.players.clear();
|
||||
L2Event.connectionLossData.clear();
|
||||
|
||||
for (int j = 0; j < L2Event.teamsNumber; j++)
|
||||
{
|
||||
LinkedList<String> link = new LinkedList<String>();
|
||||
L2Event.players.put(j + 1, link);
|
||||
|
||||
}
|
||||
int i = 0;
|
||||
|
||||
while (!L2Event.participatingPlayers.isEmpty())
|
||||
{
|
||||
String target = getMaxLeveledPlayer();
|
||||
|
||||
if (!target.isEmpty())
|
||||
{
|
||||
|
||||
L2Event.players.get(i + 1).add(target);
|
||||
i = (i + 1) % L2Event.teamsNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
destroyEventNpcs();
|
||||
npcsDeleted = true;
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_teleport"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(29), "-");
|
||||
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
teleportTeam(activeChar, Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_event_control_sit"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(24), "-");
|
||||
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
sitTeam(Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_kill"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(25), "-");
|
||||
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
killTeam(activeChar, Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_res"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(24), "-");
|
||||
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
resTeam(Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_poly"))
|
||||
{
|
||||
StringTokenizer st0 = new StringTokenizer(command.substring(25));
|
||||
StringTokenizer st = new StringTokenizer(st0.nextToken(), "-");
|
||||
String id = st0.nextToken();
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
polyTeam(Integer.parseInt(st.nextToken()), id);
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_unpoly"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(27), "-");
|
||||
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
unpolyTeam(Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_prize"))
|
||||
{
|
||||
StringTokenizer st0 = new StringTokenizer(command.substring(26));
|
||||
StringTokenizer st = new StringTokenizer(st0.nextToken(), "-");
|
||||
String n = st0.nextToken();
|
||||
StringTokenizer st1 = new StringTokenizer(n, "*");
|
||||
n = st1.nextToken();
|
||||
String type = "";
|
||||
if (st1.hasMoreElements())
|
||||
type = st1.nextToken();
|
||||
|
||||
String id = st0.nextToken();
|
||||
while (st.hasMoreElements())
|
||||
{
|
||||
regardTeam(activeChar, Integer.parseInt(st.nextToken()), Integer.parseInt(n), Integer.parseInt(id), type);
|
||||
}
|
||||
showEventControl(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_event_control_finish"))
|
||||
{
|
||||
for (int i = 0; i < L2Event.teamsNumber; i++)
|
||||
{
|
||||
telePlayersBack(i + 1);
|
||||
}
|
||||
|
||||
L2Event.eventName = "";
|
||||
L2Event.teamsNumber = 0;
|
||||
L2Event.names.clear();
|
||||
L2Event.participatingPlayers.clear();
|
||||
L2Event.players.clear();
|
||||
L2Event.id = 12760;
|
||||
L2Event.npcs.clear();
|
||||
L2Event.active = false;
|
||||
npcsDeleted = false;
|
||||
|
||||
}
|
||||
|
||||
else if (command.startsWith("admin_event_announce"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command.substring(21));
|
||||
L2Event.id = 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.names.put(i++, temp2.substring(1, temp2.length() - 1));
|
||||
}
|
||||
}
|
||||
|
||||
L2Event.participatingPlayers.clear();
|
||||
|
||||
muestraNpcConInfoAPlayers(activeChar, L2Event.id);
|
||||
|
||||
PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
|
||||
activeChar.sendPacket(_snd);
|
||||
activeChar.broadcastPacket(_snd);
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
final String replyMSG = StringUtil.concat(
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">[ L2J EVENT ENGINE</font></center><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);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
String showStoredEvents()
|
||||
{
|
||||
File dir = new File("data/events");
|
||||
String[] files = dir.list();
|
||||
|
||||
if (files == null) {
|
||||
return "No 'data/events' directory!";
|
||||
}
|
||||
|
||||
final StringBuilder result = new StringBuilder(files.length * 500);
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
final File file = new File("data/events/" + files[i]);
|
||||
final String fileName = file.getName();
|
||||
StringUtil.append(result,
|
||||
"<font color=\"LEVEL\">",
|
||||
fileName,
|
||||
" </font><br><button value=\"select\" action=\"bypass -h admin_event_set ",
|
||||
fileName,
|
||||
"\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"ver\" action=\"bypass -h admin_event_see ",
|
||||
fileName,
|
||||
"\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"delete\" action=\"bypass -h admin_event_del ",
|
||||
fileName,
|
||||
"\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>"
|
||||
);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
final String replyMSG = StringUtil.concat(
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>" +
|
||||
"<br><center><button value=\"Create NEW event \" action=\"bypass -h admin_event_new\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" +
|
||||
"<center><br>Stored Events<br></center>",
|
||||
showStoredEvents(),
|
||||
"</body></html>"
|
||||
);
|
||||
adminReply.setHtml(replyMSG);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public void showNewEventPage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(500,
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>" +
|
||||
"<br><center>Event's Title <br><font color=\"LEVEL\">"
|
||||
);
|
||||
|
||||
if (tempName.isEmpty())
|
||||
replyMSG.append("Use //event_name text to insert a new title");
|
||||
else
|
||||
replyMSG.append(tempName);
|
||||
replyMSG.append("</font></center><br><br>Event's description<br>");
|
||||
if (tempBuffer.isEmpty())
|
||||
replyMSG.append("Use //add text o //delete_buffer to modify this text field");
|
||||
else
|
||||
replyMSG.append(tempBuffer);
|
||||
|
||||
if (!(tempName.isEmpty() && tempBuffer.isEmpty()))
|
||||
replyMSG.append("<br><button value=\"Crear\" action=\"bypass -h admin_event_store\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
|
||||
|
||||
replyMSG.append("</body></html>");
|
||||
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public void showEventParameters(L2PcInstance activeChar, int teamnumbers)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(
|
||||
1000 + teamnumbers * 150,
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br>" +
|
||||
"<center><font color=\"LEVEL\">",
|
||||
L2Event.eventName,
|
||||
"</font></center><br>" +
|
||||
"<br><center><button value=\"Change number of teams to\" action=\"bypass -h admin_event_change_teams_number $event_teams_number\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"> <edit var=\"event_teams_number\" width=100 height=20><br><br>" +
|
||||
"<font color=\"LEVEL\">Team's Names</font><br>"
|
||||
);
|
||||
|
||||
for (int i = 0; i < teamnumbers; i++) {
|
||||
StringUtil.append(replyMSG,
|
||||
String.valueOf(i + 1),
|
||||
".- <edit var=\"event_teams_name",
|
||||
String.valueOf(i + 1),
|
||||
"\" width=100 height=20><br>");
|
||||
}
|
||||
|
||||
StringUtil.append(replyMSG,
|
||||
"<br><br>Announcer NPC id<edit var=\"event_npcid\" width=100 height=20><br><br><button value=\"Announce Event!!\" action=\"bypass -h admin_event_announce $event_npcid ",
|
||||
String.valueOf(teamnumbers),
|
||||
" ");
|
||||
|
||||
for (int i = 0; i < teamnumbers; i++) {
|
||||
StringUtil.append(replyMSG,
|
||||
"$event_teams_name",
|
||||
String.valueOf(i + 1),
|
||||
" - ");
|
||||
}
|
||||
replyMSG.append("\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" +
|
||||
"</body></html>");
|
||||
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
void muestraNpcConInfoAPlayers(L2PcInstance activeChar, int id)
|
||||
{
|
||||
L2Event.npcs.clear();
|
||||
LinkedList<L2PcInstance> temp = new LinkedList<L2PcInstance>();
|
||||
temp.clear();
|
||||
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
|
||||
//synchronized (L2World.getInstance().getAllPlayers())
|
||||
{
|
||||
for (L2PcInstance player : pls)
|
||||
{
|
||||
if (!temp.contains(player))
|
||||
{
|
||||
L2Event.spawn(player, id);
|
||||
temp.add(player);
|
||||
}
|
||||
Collection<L2PcInstance> plrs = player.getKnownList().getKnownPlayers().values();
|
||||
//synchronized (player.getKnownList().getKnownPlayers())
|
||||
{
|
||||
for (L2PcInstance playertemp : plrs)
|
||||
{
|
||||
if ((Math.abs(playertemp.getX() - player.getX()) < 500) && (Math.abs(playertemp.getY() - player.getY()) < 500) && (Math.abs(playertemp.getZ() - player.getZ()) < 500))
|
||||
temp.add(playertemp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
L2Event.announceAllPlayers(activeChar.getName() + " wants to make an event !!! (you'll find a npc with the details around)");
|
||||
}
|
||||
|
||||
void showEventControl(L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(1000,
|
||||
"<html><body>" +
|
||||
"<center><font color=\"LEVEL\">[ L2J EVENT ENGINE ]</font></center><br><font color=\"LEVEL\">",
|
||||
L2Event.eventName,
|
||||
"</font><br><br><table width=200>" +
|
||||
"<tr><td>Apply this command to teams number </td><td><edit var=\"team_number\" width=100 height=15></td></tr>" +
|
||||
"<tr><td> </td></tr>"
|
||||
);
|
||||
if (!npcsDeleted) {
|
||||
replyMSG.append("<tr><td><button value=\"Start\" action=\"bypass -h admin_event_control_begin\" width=90 height=15 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>");
|
||||
}
|
||||
|
||||
replyMSG.append(
|
||||
"<tr><td> </td></tr>" +
|
||||
"<tr><td><button value=\"Teleport\" action=\"bypass -h admin_event_control_teleport $team_number\" width=90 height=15 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\" action=\"bypass -h admin_event_control_sit $team_number\" width=90 height=15 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=90 height=15 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=90 height=15 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><button value=\"Polymorph\" action=\"bypass -h admin_event_control_poly $team_number $poly_id\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><edit var=\"poly_id\" width=100 height=15><font color=\"LEVEL\">Polymorphs the team into the NPC with the id specified</font></td></tr>" +
|
||||
"<tr><td> </td></tr>" +
|
||||
"<tr><td><button value=\"UnPolymorph\" action=\"bypass -h admin_event_control_unpoly $team_number\" width=90 height=15 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> </td></tr>" +
|
||||
"<tr><td><button value=\"Give Item\" action=\"bypass -h admin_event_control_prize $team_number $n $id\" width=90 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"> number <edit var=\"n\" width=100 height=15> item id <edit var=\"id\" width=100 height=15></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><button value=\"End\" action=\"bypass -h admin_event_control_finish\" width=90 height=15 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>" +
|
||||
"</table></body></html>");
|
||||
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
String getMaxLeveledPlayer()
|
||||
{
|
||||
L2PcInstance pc = null;
|
||||
int max = 0;
|
||||
String name = "";
|
||||
for (String tempName2: L2Event.participatingPlayers)
|
||||
{
|
||||
try
|
||||
{
|
||||
pc = L2World.getInstance().getPlayer(tempName2);
|
||||
if (max < pc.getLevel())
|
||||
{
|
||||
max = pc.getLevel();
|
||||
name = tempName2;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
L2Event.participatingPlayers.remove(tempName2);
|
||||
}
|
||||
}
|
||||
L2Event.participatingPlayers.remove(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
void destroyEventNpcs()
|
||||
{
|
||||
L2Npc npc;
|
||||
while (!L2Event.npcs.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
npc = (L2Npc) L2World.getInstance().findObject(Integer.parseInt(L2Event.npcs.getFirst()));
|
||||
|
||||
L2Spawn spawn = npc.getSpawn();
|
||||
|
||||
if (spawn != null)
|
||||
{
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
}
|
||||
npc.deleteMe();
|
||||
L2Event.npcs.removeFirst();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
L2Event.npcs.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void teleportTeam(L2PcInstance activeChar, int team)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance pc = L2World.getInstance().getPlayer(it.next());
|
||||
pc.setTitle(L2Event.names.get(team));
|
||||
pc.teleToLocation(activeChar.getX(), activeChar.getY(), activeChar.getZ(), true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sitTeam(int team)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance pc = L2World.getInstance().getPlayer(it.next());
|
||||
pc.eventSitForced = !pc.eventSitForced;
|
||||
if (pc.eventSitForced)
|
||||
pc.sitDown();
|
||||
else
|
||||
pc.standUp();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void killTeam(L2PcInstance activeChar, int team)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(it.next());
|
||||
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void resTeam(int team)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
L2PcInstance character = L2World.getInstance().getPlayer(it.next());
|
||||
if (character == null || !character.isDead())
|
||||
continue;
|
||||
character.restoreExp(100.0);
|
||||
character.doRevive();
|
||||
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
|
||||
character.setCurrentCp(character.getMaxCp());
|
||||
}
|
||||
}
|
||||
|
||||
void polyTeam(int team, String id)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(it.next());
|
||||
target.getPoly().setPolyInfo("npc", id);
|
||||
target.teleToLocation(target.getX(), target.getY(), target.getZ(), true);
|
||||
CharInfo info1 = new CharInfo(target);
|
||||
target.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(target);
|
||||
target.sendPacket(info2);
|
||||
target.broadcastPacket(new ExBrExtraUserInfo(target));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void unpolyTeam(int team)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(it.next());
|
||||
|
||||
target.getPoly().setPolyInfo(null, "1");
|
||||
target.decayMe();
|
||||
target.spawnMe(target.getX(), target.getY(), target.getZ());
|
||||
CharInfo info1 = new CharInfo(target);
|
||||
target.broadcastPacket(info1);
|
||||
UserInfo info2 = new UserInfo(target);
|
||||
target.sendPacket(info2);
|
||||
target.broadcastPacket(new ExBrExtraUserInfo(target));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createItem(L2PcInstance activeChar, L2PcInstance player, int id, int num)
|
||||
{
|
||||
player.getInventory().addItem("Event", id, num, player, activeChar);
|
||||
ItemList il = new ItemList(player, true);
|
||||
player.sendPacket(il);
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(
|
||||
"<html><body>" +
|
||||
"CONGRATULATIONS, you should have a present in your inventory" +
|
||||
"</body></html>");
|
||||
player.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
void regardTeam(L2PcInstance activeChar, int team, int n, int id, String type)
|
||||
{
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
int temp = n;
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(it.next());
|
||||
if (type.equalsIgnoreCase("level"))
|
||||
temp = n * target.getLevel();
|
||||
else if (type.equalsIgnoreCase("kills"))
|
||||
temp = n * target.kills.size();
|
||||
else
|
||||
temp = n;
|
||||
createItem(activeChar, target, id, temp);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void telePlayersBack(int team)
|
||||
{
|
||||
resTeam(team);
|
||||
unpolyTeam(team);
|
||||
LinkedList<String> linked = L2Event.players.get(team);
|
||||
Iterator<String> it = linked.iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2PcInstance target = L2World.getInstance().getPlayer(it.next());
|
||||
target.setTitle(target.eventTitle);
|
||||
target.setKarma(target.eventkarma);
|
||||
target.setPvpKills(target.eventpvpkills);
|
||||
target.setPkKills(target.eventpkkills);
|
||||
target.teleToLocation(target.eventX, target.eventY, target.eventZ, true);
|
||||
target.kills.clear();
|
||||
target.eventSitForced = false;
|
||||
target.atEvent = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
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.sendMessage("Event '"+_event_name+"' started.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("There is problem with 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/gm_events.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (Quest event : QuestManager.getInstance().getAllManagedScripts())
|
||||
{
|
||||
if (event instanceof Event && event.getName().startsWith("eventmod"))
|
||||
{
|
||||
StringUtil.append(cList,"<font color=\"LEVEL\">"+event.getName()+":</font>",
|
||||
"<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);
|
||||
}
|
||||
}
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/expsp.htm");
|
||||
adminReply.replace("%name%", player.getName());
|
||||
adminReply.replace("%level%", String.valueOf(player.getLevel()));
|
||||
adminReply.replace("%xp%", String.valueOf(player.getExp()));
|
||||
adminReply.replace("%sp%", String.valueOf(player.getSp()));
|
||||
adminReply.replace("%class%", player.getTemplate().className);
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return false;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return false;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(ExpSp);
|
||||
if (st.countTokens() != 2)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
Vendored
+459
@@ -0,0 +1,459 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.NpcTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.skills.Formulas;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
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 = NpcTable.getInstance().getTemplate(mid1);
|
||||
L2NpcTemplate npc2 = null;
|
||||
if (mid2 != 0)
|
||||
npc2 = NpcTable.getInstance().getTemplate(mid2);
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
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.npcId),
|
||||
"</td><td>id ",
|
||||
String.valueOf(npc2.npcId),
|
||||
"</td></tr>" +
|
||||
"<tr><td>",
|
||||
String.valueOf(npc1.name),
|
||||
"</td><td>",
|
||||
npc2.name,
|
||||
"</td></tr>" +
|
||||
"</table>" +
|
||||
"<center><br><br><br>" +
|
||||
"<button value=\"OK\" action=\"bypass -h admin_fight_calculator_show ",
|
||||
String.valueOf(npc1.npcId),
|
||||
" ",
|
||||
String.valueOf(npc2.npcId),
|
||||
"\" width=100 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">" +
|
||||
"</center>" +
|
||||
"</body></html>"
|
||||
);
|
||||
} else if (lvl1 != 0 && npc1 == null) {
|
||||
L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl1);
|
||||
final StringBuilder sb = StringUtil.startAppend(
|
||||
50 + npcs.length * 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.npcId),
|
||||
" mid2 ",
|
||||
String.valueOf(mid2),
|
||||
"\">",
|
||||
n.name,
|
||||
"</a></td></tr>"
|
||||
);
|
||||
}
|
||||
|
||||
sb.append("</table></body></html>");
|
||||
replyMSG = sb.toString();
|
||||
} else if (lvl2 != 0 && npc2 == null) {
|
||||
L2NpcTemplate[] npcs = NpcTable.getInstance().getAllOfLevel(lvl2);
|
||||
final StringBuilder sb = StringUtil.startAppend(
|
||||
50 + npcs.length * 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.npcId),
|
||||
"\">",
|
||||
String.valueOf(n.name),
|
||||
"</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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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(IdFactory.getInstance().getNextId(), NpcTable.getInstance().getTemplate(mid1));
|
||||
npc2 = new L2MonsterInstance(IdFactory.getInstance().getNextId(), NpcTable.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), npc2);
|
||||
if (_crit1)
|
||||
crit1++;
|
||||
|
||||
double _patk1 = npc1.getPAtk(npc2);
|
||||
_patk1 += npc1.getRandomDamageMultiplier();
|
||||
patk1 += _patk1;
|
||||
|
||||
double _pdef1 = npc1.getPDef(npc2);
|
||||
pdef1 += _pdef1;
|
||||
|
||||
if (!_miss1)
|
||||
{
|
||||
npc1.setAttackingBodypart();
|
||||
double _dmg1 = Formulas.calcPhysDam(npc1, npc2, null, _shld1, _crit1, false, 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), npc1);
|
||||
if (_crit2)
|
||||
crit2++;
|
||||
|
||||
double _patk2 = npc2.getPAtk(npc1);
|
||||
_patk2 *= npc2.getRandomDamageMultiplier();
|
||||
patk2 += _patk2;
|
||||
|
||||
double _pdef2 = npc2.getPDef(npc1);
|
||||
pdef2 += _pdef2;
|
||||
|
||||
if (!_miss2)
|
||||
{
|
||||
npc2.setAttackingBodypart();
|
||||
double _dmg2 = Formulas.calcPhysDam(npc2, npc1, null, _shld2, _crit2, false, 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));
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
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()).name,
|
||||
"</td><td width=70>",
|
||||
((L2NpcTemplate) npc2.getTemplate()).name,
|
||||
"</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()).npcId),
|
||||
" ",
|
||||
String.valueOf(((L2NpcTemplate) npc2.getTemplate()).npcId),
|
||||
"\" 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else
|
||||
{
|
||||
if (fort.getSiege().checkIfCanRegister(player))
|
||||
fort.getSiege().registerAttacker(player, true);
|
||||
}
|
||||
}
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else
|
||||
fort.setOwner(player.getClan(), false);
|
||||
}
|
||||
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;
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/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.getFortId()),
|
||||
"\">",
|
||||
fort.getName(),
|
||||
" id: ",
|
||||
String.valueOf(fort.getFortId()),
|
||||
"</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)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/fort.htm");
|
||||
adminReply.replace("%fortName%", fort.getName());
|
||||
adminReply.replace("%fortId%", String.valueOf(fort.getFortId()));
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.geoeditorcon.GeoEditorListener;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
|
||||
/**
|
||||
* @author Luno, Dezmond
|
||||
*/
|
||||
public class AdminGeoEditor implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_ge_status",
|
||||
"admin_ge_mode",
|
||||
"admin_ge_join",
|
||||
"admin_ge_leave"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (!Config.ACCEPT_GEOEDITOR_CONN)
|
||||
{
|
||||
activeChar.sendMessage("Server do not accepts geoeditor connections now.");
|
||||
return true;
|
||||
}
|
||||
if (command.startsWith("admin_ge_status"))
|
||||
{
|
||||
activeChar.sendMessage(GeoEditorListener.getInstance().getStatus());
|
||||
}
|
||||
else if (command.startsWith("admin_ge_mode"))
|
||||
{
|
||||
if (GeoEditorListener.getInstance().getThread() == null)
|
||||
{
|
||||
activeChar.sendMessage("Geoeditor not connected.");
|
||||
return true;
|
||||
}
|
||||
try
|
||||
{
|
||||
String val = command.substring("admin_ge_mode".length());
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
|
||||
if (st.countTokens() < 1)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //ge_mode X");
|
||||
activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
|
||||
activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
|
||||
activeChar.sendMessage("Mode 2: Send coordinates each second.");
|
||||
return true;
|
||||
}
|
||||
int m;
|
||||
m = Integer.parseInt(st.nextToken());
|
||||
GeoEditorListener.getInstance().getThread().setMode(m);
|
||||
activeChar.sendMessage("Geoeditor connection mode set to " + m + ".");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //ge_mode X");
|
||||
activeChar.sendMessage("Mode 0: Don't send coordinates to geoeditor.");
|
||||
activeChar.sendMessage("Mode 1: Send coordinates at ValidatePosition from clients.");
|
||||
activeChar.sendMessage("Mode 2: Send coordinates each second.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (command.equals("admin_ge_join"))
|
||||
{
|
||||
if (GeoEditorListener.getInstance().getThread() == null)
|
||||
{
|
||||
activeChar.sendMessage("Geoeditor not connected.");
|
||||
return true;
|
||||
}
|
||||
GeoEditorListener.getInstance().getThread().addGM(activeChar);
|
||||
activeChar.sendMessage("You added to list for geoeditor.");
|
||||
}
|
||||
else if (command.equals("admin_ge_leave"))
|
||||
{
|
||||
if (GeoEditorListener.getInstance().getThread() == null)
|
||||
{
|
||||
activeChar.sendMessage("Geoeditor not connected.");
|
||||
return true;
|
||||
}
|
||||
GeoEditorListener.getInstance().getThread().removeGM(activeChar);
|
||||
activeChar.sendMessage("You removed from list for geoeditor.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.GeoData;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author -Nemesiss-
|
||||
*/
|
||||
public class AdminGeodata implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_geo_z",
|
||||
"admin_geo_type",
|
||||
"admin_geo_nswe",
|
||||
"admin_geo_los",
|
||||
"admin_geo_position",
|
||||
"admin_geo_bug",
|
||||
"admin_geo_load",
|
||||
"admin_geo_unload"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (Config.GEODATA < 1)
|
||||
{
|
||||
activeChar.sendMessage("Geo Engine is Turned Off!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (command.equals("admin_geo_z"))
|
||||
activeChar.sendMessage("GeoEngine: Geo_Z = " + GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ()) + " Loc_Z = " + activeChar.getZ());
|
||||
else if (command.equals("admin_geo_type"))
|
||||
{
|
||||
short type = GeoData.getInstance().getType(activeChar.getX(), activeChar.getY());
|
||||
activeChar.sendMessage("GeoEngine: Geo_Type = " + type);
|
||||
short height = GeoData.getInstance().getHeight(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
activeChar.sendMessage("GeoEngine: height = " + height);
|
||||
}
|
||||
else if (command.equals("admin_geo_nswe"))
|
||||
{
|
||||
String result = "";
|
||||
short nswe = GeoData.getInstance().getNSWE(activeChar.getX(), activeChar.getY(), activeChar.getZ());
|
||||
if ((nswe & 8) == 0)
|
||||
result += " N";
|
||||
if ((nswe & 4) == 0)
|
||||
result += " S";
|
||||
if ((nswe & 2) == 0)
|
||||
result += " W";
|
||||
if ((nswe & 1) == 0)
|
||||
result += " E";
|
||||
activeChar.sendMessage("GeoEngine: Geo_NSWE -> " + nswe + "->" + result);
|
||||
}
|
||||
else if (command.equals("admin_geo_los"))
|
||||
{
|
||||
if (activeChar.getTarget() != null)
|
||||
{
|
||||
if (GeoData.getInstance().canSeeTargetDebug(activeChar, activeChar.getTarget()))
|
||||
activeChar.sendMessage("GeoEngine: Can See Target");
|
||||
else
|
||||
activeChar.sendMessage("GeoEngine: Can't See Target");
|
||||
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("None Target!");
|
||||
}
|
||||
else if (command.equals("admin_geo_position"))
|
||||
{
|
||||
activeChar.sendMessage("GeoEngine: Your current position: ");
|
||||
activeChar.sendMessage(".... world coords: x: " + activeChar.getX() + " y: " + activeChar.getY() + " z: " + activeChar.getZ());
|
||||
activeChar.sendMessage(".... geo position: " + GeoData.getInstance().geoPosition(activeChar.getX(), activeChar.getY()));
|
||||
}
|
||||
else if (command.startsWith("admin_geo_load"))
|
||||
{
|
||||
String[] v = command.substring(15).split(" ");
|
||||
if (v.length != 2)
|
||||
activeChar.sendMessage("Usage: //admin_geo_load <regionX> <regionY>");
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
byte rx = Byte.parseByte(v[0]);
|
||||
byte ry = Byte.parseByte(v[1]);
|
||||
|
||||
boolean result = GeoData.loadGeodataFile(rx, ry);
|
||||
|
||||
if (result)
|
||||
activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] loaded succesfuly");
|
||||
else
|
||||
activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] couldn't be loaded");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_geo_unload"))
|
||||
{
|
||||
String[] v = command.substring(17).split(" ");
|
||||
if (v.length != 2)
|
||||
activeChar.sendMessage("Usage: //admin_geo_unload <regionX> <regionY>");
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
byte rx = Byte.parseByte(v[0]);
|
||||
byte ry = Byte.parseByte(v[1]);
|
||||
|
||||
GeoData.unloadGeodata(rx, ry);
|
||||
activeChar.sendMessage("GeoEngine: File for region [" + rx + "," + ry + "] unloaded.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("You have to write numbers of regions <regionX> <regionY>");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_geo_bug"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String comment = command.substring(14);
|
||||
GeoData.getInstance().addGeoDataBug(activeChar, comment);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //admin_geo_bug you coments here");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.GmListTable;
|
||||
import com.l2jserver.gameserver.datatables.AccessLevels;
|
||||
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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.equals("admin_gm"))
|
||||
handleGm(activeChar);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void handleGm(L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar.isGM())
|
||||
{
|
||||
GmListTable.getInstance().deleteGm(activeChar);
|
||||
activeChar.setAccessLevel(AccessLevels._userAccessLevelNum);
|
||||
activeChar.sendMessage("You no longer have GM status.");
|
||||
|
||||
if (Config.DEBUG)
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") turned his GM status off");
|
||||
}
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.GmListTable;
|
||||
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.clientpackets.Say2;
|
||||
import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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"))
|
||||
AdminHelpPage.showHelpPage(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(SystemMessage.getSystemMessage(SystemMessageId.SELECT_TARGET));
|
||||
return;
|
||||
}
|
||||
if (!(target instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
L2PcInstance player = (L2PcInstance) target;
|
||||
player.addSnooper(activeChar);
|
||||
activeChar.addSnooped(player);
|
||||
}
|
||||
|
||||
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, Say2.ALLIANCE, activeChar.getName(), text);
|
||||
GmListTable.broadcastToGMs(cs);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
// empty message.. ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
|
||||
*
|
||||
* $Author: luisantonioa $
|
||||
* $Date: 25/07/2005 17:15:21 $
|
||||
* $Revision: 1 $
|
||||
* $Log: AdminTest.java,v $
|
||||
* Revision 1 25/07/2005 17:15:21 luisantonioa
|
||||
* Added copyright notice
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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)
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(0);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/graciaseeds.htm");
|
||||
html.replace("%sodstate%", String.valueOf(GraciaSeedsManager.getInstance().getSoDState()));
|
||||
html.replace("%sodtiatkill%", String.valueOf(GraciaSeedsManager.getInstance().getSoDTiatKilled()));
|
||||
if (GraciaSeedsManager.getInstance().getSoDTimeForNextStateChange() > 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
//synchronized (activeChar.getKnownList().getKnownObjects())
|
||||
{
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.cache.HtmCache;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - help path = shows /data/html/admin/path file to char, should not be used by GM's directly
|
||||
*
|
||||
* @version $Revision: 1.2.4.3 $ $Date: 2005/04/11 10:06:02 $
|
||||
*/
|
||||
public class AdminHelpPage implements IAdminCommandHandler
|
||||
{
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_help"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.startsWith("admin_help"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(11);
|
||||
showHelpPage(activeChar, val);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
//case of empty filename
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
//FIXME: implement method to send html to player in L2PcInstance directly
|
||||
//PUBLIC & STATIC so other classes from package can include it directly
|
||||
public static void showHelpPage(L2PcInstance targetChar, String filename)
|
||||
{
|
||||
String content = HtmCache.getInstance().getHtmForce(targetChar.getHtmlPrefix(), "data/html/admin/" + filename);
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(content);
|
||||
targetChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
+170
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
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 < 2)
|
||||
{
|
||||
activeChar.sendMessage("Example: //createinstance <id> <templatefile> - ids => 300000 are reserved for dynamic instances");
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Integer.parseInt(parts[1]);
|
||||
if (InstanceManager.getInstance().createInstanceFromTemplate(id, parts[2]) && id < 300000)
|
||||
{
|
||||
activeChar.sendMessage("Instance created");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Failed to create instance");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Failed loading: " + 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;
|
||||
}
|
||||
else
|
||||
{
|
||||
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.getX(), player.getY(), player.getZ());
|
||||
L2Summon pet = player.getPet();
|
||||
if (pet != null)
|
||||
{
|
||||
pet.setInstanceId(val);
|
||||
pet.teleToLocation(pet.getX(), pet.getY(), pet.getZ());
|
||||
player.sendMessage("Admin set " + pet.getName() + "'s instance to:" + val);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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>");
|
||||
|
||||
NpcHtmlMessage ms = new NpcHtmlMessage(1);
|
||||
ms.setHtml(html.toString());
|
||||
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.equals("admin_invul"))
|
||||
{
|
||||
handleInvul(activeChar);
|
||||
AdminHelpPage.showHelpPage(activeChar, "gm_menu.htm");
|
||||
}
|
||||
if (command.equals("admin_setinvul"))
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
handleInvul((L2PcInstance) target);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.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"
|
||||
};
|
||||
|
||||
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;
|
||||
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
|
||||
//synchronized (L2World.getInstance().getAllPlayers())
|
||||
{
|
||||
for (L2PcInstance player : pls)
|
||||
if (!player.isGM())
|
||||
{
|
||||
counter++;
|
||||
player.logout();
|
||||
}
|
||||
}
|
||||
activeChar.sendMessage("Kicked " + counter + " players");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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());
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
|
||||
*
|
||||
* $Author: luisantonioa $
|
||||
* $Date: 25/07/2005 17:15:21 $
|
||||
* $Revision: 1 $
|
||||
* $Log: AdminTest.java,v $
|
||||
* Revision 1 25/07/2005 17:15:21 luisantonioa
|
||||
* Added copyright notice
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.L2Object;
|
||||
import com.l2jserver.gameserver.model.actor.L2Playable;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.base.Experience;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
public class AdminLevel implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_add_level",
|
||||
"admin_set_level"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!(targetChar instanceof L2PcInstance))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT)); // incorrect target!
|
||||
return false;
|
||||
}
|
||||
L2PcInstance targetPlayer = (L2PcInstance) targetChar;
|
||||
|
||||
byte lvl = Byte.parseByte(val);
|
||||
if (lvl >= 1 && lvl <= Experience.MAX_LEVEL)
|
||||
{
|
||||
long pXp = targetPlayer.getExp();
|
||||
long tXp = Experience.LEVEL[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 " + Experience.MAX_LEVEL + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("You must specify level between 1 and " + Experience.MAX_LEVEL + ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(1);
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/login.htm");
|
||||
html.replace("%server_name%", LoginServerThread.getInstance().getServerName());
|
||||
html.replace("%status%", LoginServerThread.getInstance().getStatusString());
|
||||
html.replace("%clock%", getServerTypeName(Config.SERVER_LIST_TYPE));
|
||||
html.replace("%brackets%", String.valueOf(Config.SERVER_LIST_BRACKET));
|
||||
html.replace("%max_players%", String.valueOf(LoginServerThread.getInstance().getMaxPlayer()));
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
|
||||
private String getServerTypeName(int serverType)
|
||||
{
|
||||
String nameType = "";
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.SevenSigns;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.AutoSpawnHandler;
|
||||
import com.l2jserver.gameserver.model.AutoSpawnHandler.AutoSpawnInstance;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* Admin Command Handler for Mammon NPCs
|
||||
* @author Tempy, Zoey76
|
||||
*/
|
||||
public class AdminMammon implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS = { "admin_mammon_find", "admin_mammon_respawn", };
|
||||
|
||||
private boolean _isSealValidation = SevenSigns.getInstance().isSealValidationPeriod();
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
int teleportIndex = -1;
|
||||
final AutoSpawnInstance blackSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_BLACKSMITH_ID, false);
|
||||
final AutoSpawnInstance merchSpawnInst = AutoSpawnHandler.getInstance().getAutoSpawnInstance(SevenSigns.MAMMON_MERCHANT_ID, false);
|
||||
|
||||
if (command.startsWith("admin_mammon_find"))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (command.length() > 17)
|
||||
{
|
||||
teleportIndex = Integer.parseInt(command.substring(18));
|
||||
}
|
||||
}
|
||||
catch (Exception NumberFormatException)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //mammon_find [teleportIndex] (where 1 = Blacksmith, 2 = Merchant)");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_isSealValidation)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (blackSpawnInst != null)
|
||||
{
|
||||
final L2Npc[] blackInst = blackSpawnInst.getNPCInstanceList();
|
||||
if (blackInst.length > 0)
|
||||
{
|
||||
final int x1 = blackInst[0].getX(), y1 = blackInst[0].getY(), z1 = blackInst[0].getZ();
|
||||
activeChar.sendMessage("Blacksmith of Mammon: " + x1 + " " + y1 + " " + z1);
|
||||
if (teleportIndex == 1)
|
||||
{
|
||||
activeChar.teleToLocation(x1, y1, z1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
|
||||
}
|
||||
|
||||
if (merchSpawnInst != null)
|
||||
{
|
||||
final L2Npc[] merchInst = merchSpawnInst.getNPCInstanceList();
|
||||
if (merchInst.length > 0)
|
||||
{
|
||||
final int x2 = merchInst[0].getX(), y2 = merchInst[0].getY(), z2 = merchInst[0].getZ();
|
||||
activeChar.sendMessage("Merchant of Mammon: " + x2 + " " + y2 + " " + z2);
|
||||
if (teleportIndex == 2)
|
||||
{
|
||||
activeChar.teleToLocation(x2, y2, z2, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_mammon_respawn"))
|
||||
{
|
||||
if (!_isSealValidation)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessageId.SSQ_COMPETITION_UNDERWAY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (merchSpawnInst != null)
|
||||
{
|
||||
long merchRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(merchSpawnInst);
|
||||
activeChar.sendMessage("The Merchant of Mammon will respawn in " + (merchRespawn / 60000) + " minute(s).");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Merchant of Mammon isn't registered for spawn.");
|
||||
}
|
||||
|
||||
if (blackSpawnInst != null)
|
||||
{
|
||||
long blackRespawn = AutoSpawnHandler.getInstance().getTimeToNextSpawn(blackSpawnInst);
|
||||
activeChar.sendMessage("The Blacksmith of Mammon will respawn in " + (blackRespawn / 60000) + " minute(s).");
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Blacksmith of Mammon isn't registered for spawn.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.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.util.StringUtil;
|
||||
|
||||
/**
|
||||
* Admin comand handler for Manor System
|
||||
* This class handles following admin commands:
|
||||
* - manor_info = shows info about current manor state
|
||||
* - manor_approve = approves settings for the next manor period
|
||||
* - manor_setnext = changes manor settings to the next day's
|
||||
* - manor_reset castle = resets all manor data for specified castle (or all)
|
||||
* - manor_setmaintenance = sets manor system under maintenance mode
|
||||
* - manor_save = saves all manor data into database
|
||||
* - manor_disable = disables manor system
|
||||
*
|
||||
* @author l3x
|
||||
*/
|
||||
public class AdminManor implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] _adminCommands =
|
||||
{
|
||||
"admin_manor",
|
||||
"admin_manor_approve",
|
||||
"admin_manor_setnext",
|
||||
"admin_manor_reset",
|
||||
"admin_manor_setmaintenance",
|
||||
"admin_manor_save",
|
||||
"admin_manor_disable"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
command = st.nextToken();
|
||||
|
||||
if (command.equals("admin_manor"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_setnext"))
|
||||
{
|
||||
CastleManorManager.getInstance().setNextPeriod();
|
||||
CastleManorManager.getInstance().setNewManorRefresh();
|
||||
CastleManorManager.getInstance().updateManorRefresh();
|
||||
activeChar.sendMessage("Manor System: set to next period");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_approve"))
|
||||
{
|
||||
CastleManorManager.getInstance().approveNextPeriod();
|
||||
CastleManorManager.getInstance().setNewPeriodApprove();
|
||||
CastleManorManager.getInstance().updatePeriodApprove();
|
||||
activeChar.sendMessage("Manor System: next period approved");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_reset"))
|
||||
{
|
||||
int castleId = 0;
|
||||
try
|
||||
{
|
||||
castleId = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
if (castleId > 0)
|
||||
{
|
||||
Castle castle = CastleManager.getInstance().getCastleById(castleId);
|
||||
castle.resetManor();
|
||||
activeChar.sendMessage("Manor data for " + castle.getName() + " was nulled");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Castle castle : CastleManager.getInstance().getCastles())
|
||||
{
|
||||
castle.resetManor();
|
||||
}
|
||||
activeChar.sendMessage("Manor data was nulled");
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_setmaintenance"))
|
||||
{
|
||||
boolean mode = CastleManorManager.getInstance().isUnderMaintenance();
|
||||
CastleManorManager.getInstance().setUnderMaintenance(!mode);
|
||||
if (mode)
|
||||
activeChar.sendMessage("Manor System: not under maintenance");
|
||||
else
|
||||
activeChar.sendMessage("Manor System: under maintenance");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_save"))
|
||||
{
|
||||
CastleManorManager.getInstance().save();
|
||||
activeChar.sendMessage("Manor System: all data saved");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_manor_disable"))
|
||||
{
|
||||
boolean mode = CastleManorManager.getInstance().isDisabled();
|
||||
CastleManorManager.getInstance().setDisabled(!mode);
|
||||
if (mode)
|
||||
activeChar.sendMessage("Manor System: enabled");
|
||||
else
|
||||
activeChar.sendMessage("Manor System: disabled");
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return _adminCommands;
|
||||
}
|
||||
|
||||
private String formatTime(long millis)
|
||||
{
|
||||
String s = "";
|
||||
int secs = (int) millis / 1000;
|
||||
int mins = secs / 60;
|
||||
secs -= mins * 60;
|
||||
int hours = mins / 60;
|
||||
mins -= hours * 60;
|
||||
|
||||
if (hours > 0)
|
||||
s += hours + ":";
|
||||
s += mins + ":";
|
||||
s += secs;
|
||||
return s;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
final List<Castle> castles = CastleManager.getInstance().getCastles();
|
||||
final StringBuilder replyMSG = StringUtil.startAppend(
|
||||
1000 + castles.size() * 50,
|
||||
"<html><body>" +
|
||||
"<center><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>Manor Info</center></td>"+
|
||||
"<td width=45><button value=\"Back\" action=\"bypass -h admin_admin2\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>"+
|
||||
"</tr></table><font color=\"LEVEL\"> [Manor System] </font></center><br>"+
|
||||
"<table width=\"100%\"><tr><td>" +
|
||||
"Disabled: ",
|
||||
CastleManorManager.getInstance().isDisabled() ? "yes" : "no",
|
||||
"</td><td>" +
|
||||
"Under Maintenance: ",
|
||||
CastleManorManager.getInstance().isUnderMaintenance() ? "yes" : "no",
|
||||
"</td></tr><tr><td>" +
|
||||
"Time to refresh: ",
|
||||
formatTime(CastleManorManager.getInstance().getMillisToManorRefresh()),
|
||||
"</td><td>" +
|
||||
"Time to approve: ",
|
||||
formatTime(CastleManorManager.getInstance().getMillisToNextPeriodApprove()),
|
||||
"</td></tr>" +
|
||||
"</table>" +
|
||||
"<center><table><tr><td>" +
|
||||
"<button value=\"Set Next\" action=\"bypass -h admin_manor_setnext\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" +
|
||||
"<button value=\"Approve Next\" action=\"bypass -h admin_manor_approve\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td>" +
|
||||
"<button value=\"",
|
||||
CastleManorManager.getInstance().isUnderMaintenance() ? "Set normal" : "Set mainteance",
|
||||
"\" action=\"bypass -h admin_manor_setmaintenance\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" +
|
||||
"<button value=\"",
|
||||
CastleManorManager.getInstance().isDisabled() ? "Enable" : "Disable",
|
||||
"\" action=\"bypass -h admin_manor_disable\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td>" +
|
||||
"<button value=\"Refresh\" action=\"bypass -h admin_manor\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" +
|
||||
"<button value=\"Back\" action=\"bypass -h admin_admin\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" +
|
||||
"</table></center>" +
|
||||
"<br><center>Castle Information:<table width=\"100%\">" +
|
||||
"<tr><td></td><td>Current Period</td><td>Next Period</td></tr>"
|
||||
);
|
||||
|
||||
for (Castle c : CastleManager.getInstance().getCastles()) {
|
||||
StringUtil.append(replyMSG,
|
||||
"<tr><td>",
|
||||
c.getName(),
|
||||
"</td>" +
|
||||
"<td>",
|
||||
String.valueOf(c.getManorCost(CastleManorManager.PERIOD_CURRENT)),
|
||||
"a</td>" +
|
||||
"<td>",
|
||||
String.valueOf(c.getManorCost(CastleManorManager.PERIOD_NEXT)),
|
||||
"a</td>" +
|
||||
"</tr>");
|
||||
}
|
||||
|
||||
replyMSG.append(
|
||||
"</table><br>" +
|
||||
"</body></html>");
|
||||
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
}
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.datatables.AdminCommandAccessRights;
|
||||
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.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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, 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.getX(), activeChar.getY(), activeChar.getZ(), activeChar, "Admin is teleporting you.");
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_recall_party_menu"))
|
||||
{
|
||||
int x = activeChar.getX(), y = activeChar.getY(), z = activeChar.getZ();
|
||||
try
|
||||
{
|
||||
String targetName = command.substring(24);
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return true;
|
||||
}
|
||||
if (!player.isInParty())
|
||||
{
|
||||
activeChar.sendMessage("Player is not in party.");
|
||||
teleportCharacter(player, x, y, z, activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
for (L2PcInstance pm : player.getParty().getPartyMembers())
|
||||
teleportCharacter(pm, x, y, z, 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"))
|
||||
{
|
||||
int x = activeChar.getX(), y = activeChar.getY(), z = activeChar.getZ();
|
||||
try
|
||||
{
|
||||
String targetName = command.substring(23);
|
||||
L2PcInstance player = L2World.getInstance().getPlayer(targetName);
|
||||
if (player == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return true;
|
||||
}
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
{
|
||||
activeChar.sendMessage("Player is not in a clan.");
|
||||
teleportCharacter(player, x, y, z, activeChar, "Admin is teleporting you.");
|
||||
return true;
|
||||
}
|
||||
L2PcInstance[] members = clan.getOnlineMembers(0);
|
||||
for (L2PcInstance member: members)
|
||||
teleportCharacter(member, x, y, z, 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 (!AdminCommandAccessRights.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().getAdminCommandHandler(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 (!AdminCommandAccessRights.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().getAdminCommandHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand+command.substring(16), activeChar);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
AdminHelpPage.showHelpPage(activeChar, filename);
|
||||
}
|
||||
|
||||
private void teleportCharacter(L2PcInstance player, int x, int y, int z, L2PcInstance activeChar, String message)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
player.sendMessage(message);
|
||||
player.teleToLocation(x, y, z, true);
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
|
||||
else
|
||||
{
|
||||
activeChar.setInstanceId(player.getInstanceId());
|
||||
activeChar.teleToLocation(player.getX(), player.getY(), player.getZ(), true);
|
||||
activeChar.sendMessage("You're teleporting yourself to character " + player.getName());
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "charmanage.htm");
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
|
||||
/**
|
||||
* @author Zoey76
|
||||
*/
|
||||
public class AdminMessages implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_msg"
|
||||
};
|
||||
|
||||
@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>");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+574
@@ -0,0 +1,574 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.NpcTable;
|
||||
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.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SetupGauge;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
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"
|
||||
};
|
||||
|
||||
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
|
||||
*/
|
||||
private void showMainPage(L2PcInstance activeChar, String command)
|
||||
{
|
||||
String filename = "mobgroup.htm";
|
||||
AdminHelpPage.showHelpPage(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 = NpcTable.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), 2250000/*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().npcId + " (" + mobGroup.getStatus() + ")");
|
||||
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FRIEND_LIST_FOOTER));
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equalsIgnoreCase("admin_mons"))
|
||||
{
|
||||
handleSendPacket(activeChar);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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.MONSRACE_RACE_START);
|
||||
sm.addNumber(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 int[][] codes;
|
||||
private L2PcInstance activeChar;
|
||||
|
||||
public RunRace(int[][] pCodes, L2PcInstance pActiveChar)
|
||||
{
|
||||
codes = pCodes;
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
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 L2PcInstance activeChar;
|
||||
|
||||
public RunEnd(L2PcInstance pActiveChar)
|
||||
{
|
||||
activeChar = pActiveChar;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.StringTokenizer;
|
||||
|
||||
import org.mmocore.network.NioNetStringBuffer;
|
||||
|
||||
import com.l2jserver.gameserver.GameServer;
|
||||
import com.l2jserver.gameserver.ThreadPoolManager;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
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;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles commands for gm to forge packets
|
||||
*
|
||||
* @author Maktakien
|
||||
*
|
||||
*/
|
||||
public class AdminPForge implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_forge",
|
||||
"admin_forge2",
|
||||
"admin_forge3"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_forge"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.startsWith("admin_forge2"))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
String format = st.nextToken();
|
||||
showPage2(activeChar, format);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
activeChar.sendMessage("Usage: //forge2 format");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_forge3"))
|
||||
{
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken();
|
||||
String format = st.nextToken();
|
||||
boolean broadcast = false;
|
||||
boolean client = false;
|
||||
ByteBuffer buf = null;
|
||||
if (format.toLowerCase().equals("broadcast"))
|
||||
{
|
||||
format = st.nextToken();
|
||||
broadcast = true;
|
||||
}
|
||||
else if (format.toLowerCase().equals("client"))
|
||||
{
|
||||
format = st.nextToken();
|
||||
client = true;
|
||||
buf = ByteBuffer.allocate(65533);
|
||||
}
|
||||
AdminForgePacket sp = new AdminForgePacket();
|
||||
for (int i = 0; i < format.length(); i++)
|
||||
{
|
||||
String val = st.nextToken();
|
||||
if (val.toLowerCase().equals("$objid"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getObjectId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$tobjid"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getTarget().getObjectId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$bobjid"))
|
||||
{
|
||||
if (activeChar.getBoat() != null)
|
||||
{
|
||||
val = String.valueOf(activeChar.getBoat().getObjectId());
|
||||
}
|
||||
}
|
||||
else if (val.toLowerCase().equals("$clanid"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getClanId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$allyid"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getAllyId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$tclanid"))
|
||||
{
|
||||
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getClanId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$tallyid"))
|
||||
{
|
||||
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getAllyId());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$x"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getX());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$y"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getY());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$z"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getZ());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$heading"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getHeading());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$tx"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getTarget().getX());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$ty"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getTarget().getY());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$tz"))
|
||||
{
|
||||
val = String.valueOf(activeChar.getTarget().getZ());
|
||||
}
|
||||
else if (val.toLowerCase().equals("$theading"))
|
||||
{
|
||||
val = String.valueOf(((L2PcInstance) activeChar.getTarget()).getHeading());
|
||||
}
|
||||
|
||||
if (!client)
|
||||
sp.addPart(format.getBytes()[i], val);
|
||||
else
|
||||
write(format.getBytes()[i], val, buf);
|
||||
}
|
||||
if (broadcast)
|
||||
{
|
||||
activeChar.broadcastPacket(sp);
|
||||
}
|
||||
else if (client)
|
||||
{
|
||||
buf.flip();
|
||||
L2GameClientPacket p = (L2GameClientPacket) GameServer.gameServer.getL2GamePacketHandler().handlePacket(buf, activeChar.getClient());
|
||||
if (p != null)
|
||||
{
|
||||
p.setBuffers(buf, activeChar.getClient(), new NioNetStringBuffer(2000));
|
||||
if (p.read())
|
||||
ThreadPoolManager.getInstance().executePacket(p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(sp);
|
||||
}
|
||||
showPage3(activeChar, format, command);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "pforge1.htm");
|
||||
}
|
||||
|
||||
private void showPage2(L2PcInstance activeChar, String format)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/pforge2.htm");
|
||||
adminReply.replace("%format%", format);
|
||||
|
||||
final StringBuilder replyMSG =
|
||||
new StringBuilder(format.length() * 40);
|
||||
|
||||
for (int i = 0; i < format.length(); i++)
|
||||
StringUtil.append(replyMSG,
|
||||
String.valueOf(format.charAt(i)),
|
||||
" : <edit var=\"v",
|
||||
String.valueOf(i),
|
||||
"\" width=100><br1>");
|
||||
adminReply.replace("%valueditors%", replyMSG.toString());
|
||||
replyMSG.setLength(0);
|
||||
|
||||
for (int i = 0; i < format.length(); i++)
|
||||
replyMSG.append(" $v" + i);
|
||||
adminReply.replace("%send%", replyMSG.toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showPage3(L2PcInstance activeChar, String format, String command)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/pforge3.htm");
|
||||
adminReply.replace("%format%", format);
|
||||
adminReply.replace("%command%", command);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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",
|
||||
};
|
||||
|
||||
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.GEODATA < 2)
|
||||
{
|
||||
activeChar.sendMessage("PathFinding has not been enabled.");
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.ONLY_ONE_ACTIVE_PETITION_AT_TIME));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PetitionManager.getInstance().isPetitionInProcess(petitionId))
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETITION_UNDER_PROCESS));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PetitionManager.getInstance().acceptPetition(activeChar, petitionId))
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_UNDER_PETITION_CONSULTATION));
|
||||
}
|
||||
else if (command.startsWith("admin_reject_petition"))
|
||||
{
|
||||
if (!PetitionManager.getInstance().rejectPetition(activeChar, petitionId))
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.FAILED_CANCEL_PETITION_TRY_LATER));
|
||||
PetitionManager.getInstance().sendPendingPetitionList(activeChar);
|
||||
}
|
||||
else if (command.equals("admin_reset_petitions"))
|
||||
{
|
||||
if (PetitionManager.getInstance().isPetitionInProcess())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.PETITION_UNDER_PROCESS));
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.gameserver.datatables.ClanTable;
|
||||
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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
String name = player.getName();
|
||||
if (command.startsWith("admin_pledge"))
|
||||
{
|
||||
String action = null;
|
||||
String parameter = null;
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
action = st.nextToken(); // create|info|dismiss|setlevel|rep
|
||||
parameter = st.nextToken(); // clanname|nothing|nothing|level|rep_points
|
||||
}
|
||||
catch (NoSuchElementException nse)
|
||||
{
|
||||
}
|
||||
if (action.equals("create"))
|
||||
{
|
||||
long cet = player.getClanCreateExpiryTime();
|
||||
player.setClanCreateExpiryTime(0);
|
||||
L2Clan clan = ClanTable.getInstance().createClan(player, parameter);
|
||||
if (clan != null)
|
||||
activeChar.sendMessage("Clan " + parameter + " created. Leader: " + player.getName());
|
||||
else
|
||||
{
|
||||
player.setClanCreateExpiryTime(cet);
|
||||
activeChar.sendMessage("There was a problem while creating the clan.");
|
||||
}
|
||||
}
|
||||
else if (!player.isClanLeader())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER).addString(name));
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
else if (action.equals("dismiss"))
|
||||
{
|
||||
ClanTable.getInstance().destroyClan(player.getClanId());
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan == null)
|
||||
activeChar.sendMessage("Clan disbanded.");
|
||||
else
|
||||
activeChar.sendMessage("There was a problem while destroying the clan.");
|
||||
}
|
||||
else if (action.equals("info"))
|
||||
{
|
||||
activeChar.sendPacket(new GMViewPledgeInfo(player.getClan(), player));
|
||||
}
|
||||
else if (parameter == null)
|
||||
activeChar.sendMessage("Usage: //pledge <setlevel|rep> <number>");
|
||||
else if (action.equals("setlevel"))
|
||||
{
|
||||
int level = Integer.parseInt(parameter);
|
||||
if (level >= 0 && level < 12)
|
||||
{
|
||||
player.getClan().changeLevel(level);
|
||||
activeChar.sendMessage("You set level " + level + " for clan " + player.getClan().getName());
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("Level incorrect.");
|
||||
}
|
||||
else if (action.startsWith("rep"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int points = Integer.parseInt(parameter);
|
||||
L2Clan clan = player.getClan();
|
||||
if (clan.getLevel() < 5)
|
||||
{
|
||||
activeChar.sendMessage("Only clans of level 5 or above may receive reputation points.");
|
||||
showMainPage(activeChar);
|
||||
return false;
|
||||
}
|
||||
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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "game_menu.htm");
|
||||
}
|
||||
|
||||
}
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.TransformationManager;
|
||||
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.network.serverpackets.SystemMessage;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands: polymorph
|
||||
*
|
||||
* @version $Revision: 1.2.2.1.2.4 $ $Date: 2007/07/31 10:05:56 $
|
||||
*/
|
||||
public class AdminPolymorph implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_polymorph",
|
||||
"admin_unpolymorph",
|
||||
"admin_polymorph_menu",
|
||||
"admin_unpolymorph_menu",
|
||||
"admin_transform",
|
||||
"admin_untransform",
|
||||
"admin_transform_menu",
|
||||
"admin_untransform_menu",
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (activeChar.isMounted())
|
||||
{
|
||||
activeChar.sendMessage("You can't transform while mounted, please dismount and try again.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_untransform"))
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2Character)
|
||||
{
|
||||
((L2Character) obj).stopTransformation(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_transform"))
|
||||
{
|
||||
L2Object obj = activeChar.getTarget();
|
||||
if (obj instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance cha = (L2PcInstance) obj;
|
||||
|
||||
String[] parts = command.split(" ");
|
||||
if (parts.length >= 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Integer.parseInt(parts[1]);
|
||||
if (!TransformationManager.getInstance().transformPlayer(id, cha))
|
||||
{
|
||||
cha.sendMessage("Unknow transformation id: " + id);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //transform <id>");
|
||||
}
|
||||
}
|
||||
else if (parts.length == 1)
|
||||
cha.untransform();
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Usage: //transform <id>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
}
|
||||
if (command.startsWith("admin_polymorph"))
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
L2Object target = activeChar.getTarget();
|
||||
try
|
||||
{
|
||||
st.nextToken();
|
||||
String p1 = st.nextToken();
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
String p2 = st.nextToken();
|
||||
doPolymorph(activeChar, target, p2, p1);
|
||||
}
|
||||
else
|
||||
doPolymorph(activeChar, target, p1, "npc");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //polymorph [type] <id>");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_unpolymorph"))
|
||||
{
|
||||
doUnpoly(activeChar, activeChar.getTarget());
|
||||
}
|
||||
if (command.contains("_menu"))
|
||||
{
|
||||
showMainPage(activeChar, command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param target
|
||||
* @param id
|
||||
* @param type
|
||||
*/
|
||||
private 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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param activeChar
|
||||
* @param target
|
||||
*/
|
||||
private void doUnpoly(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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar, String command)
|
||||
{
|
||||
if (command.contains("transform"))
|
||||
AdminHelpPage.showHelpPage(activeChar, "transform.htm");
|
||||
else if (command.contains("abnormal"))
|
||||
AdminHelpPage.showHelpPage(activeChar, "abnormal.htm");
|
||||
else
|
||||
AdminHelpPage.showHelpPage(activeChar, "effects_menu.htm");
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
|
||||
*
|
||||
* $Author: luisantonioa $
|
||||
* $Date: 25/07/2005 17:15:21 $
|
||||
* $Revision: 1 $
|
||||
* $Log: AdminTest.java,v $
|
||||
* Revision 1 25/07/2005 17:15:21 luisantonioa
|
||||
* Added copyright notice
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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 javax.script.ScriptException;
|
||||
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.QuestManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
|
||||
|
||||
|
||||
public class AdminQuest implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_quest_reload",
|
||||
"admin_script_load"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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("Syntax: //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]);
|
||||
if (file.isFile())
|
||||
{
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(file);
|
||||
}
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
handleRepair(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
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=?";
|
||||
java.sql.Connection connection = null;
|
||||
try
|
||||
{
|
||||
connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
PreparedStatement statement = connection.prepareStatement(cmd);
|
||||
statement.setString(1, parts[1]);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
statement = connection.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)
|
||||
{
|
||||
connection.close();
|
||||
return;
|
||||
}
|
||||
|
||||
//connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = connection.prepareStatement("DELETE FROM character_shortcuts WHERE charId=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
//connection = L2DatabaseFactory.getInstance().getConnection();
|
||||
statement = connection.prepareStatement("UPDATE items SET loc=\"INVENTORY\" WHERE owner_id=?");
|
||||
statement.setInt(1, objId);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.log(Level.WARNING, "could not repair char:", e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.network.serverpackets.SystemMessage;
|
||||
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"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_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);
|
||||
|
||||
// If the target is an NPC, then abort it's auto decay and respawn.
|
||||
else
|
||||
DecayTaskManager.getInstance().cancelDecayTask(targetChar);
|
||||
|
||||
targetChar.doRevive();
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.TransformationManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
|
||||
if (command.startsWith("admin_ride"))
|
||||
{
|
||||
if (activeChar.isMounted() || activeChar.getPet() != null)
|
||||
{
|
||||
activeChar.sendMessage("You already have a pet.");
|
||||
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 (activeChar.isTransformed() || activeChar.isInStance())
|
||||
//FIXME: Wrong Message
|
||||
activeChar.sendMessage("You cannot mount a steed while transformed.");
|
||||
else
|
||||
TransformationManager.getInstance().transformPlayer(PURPLE_MANED_HORSE_TRANSFORMATION_ID, activeChar);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (command.startsWith("admin_ride_bike")) // handled using transformation
|
||||
{
|
||||
if (activeChar.isTransformed() || activeChar.isInStance())
|
||||
//FIXME: Wrong Message
|
||||
activeChar.sendMessage("You cannot mount a steed while transformed.");
|
||||
else
|
||||
TransformationManager.getInstance().transformPlayer(JET_BIKE_TRANSFORMATION_ID, activeChar);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Command '" + command + "' not recognized");
|
||||
return false;
|
||||
}
|
||||
|
||||
activeChar.mount(_petRideId, 0, false);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (command.startsWith("admin_unride"))
|
||||
{
|
||||
if (activeChar.getTransformationId() == PURPLE_MANED_HORSE_TRANSFORMATION_ID)
|
||||
activeChar.untransform();
|
||||
|
||||
if (activeChar.getTransformationId() == JET_BIKE_TRANSFORMATION_ID)
|
||||
activeChar.untransform();
|
||||
else
|
||||
activeChar.dismount();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.TradeController;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2TradeList;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.BuyList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExBuySellListPacket;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - gmshop = shows menu
|
||||
* - buy id = shows shop with respective id
|
||||
* @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:06 $
|
||||
*/
|
||||
public class AdminShop implements IAdminCommandHandler
|
||||
{
|
||||
private static Logger _log = Logger.getLogger(AdminShop.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_buy",
|
||||
"admin_gmshop"
|
||||
};
|
||||
|
||||
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"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "gmshops.htm");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
L2TradeList list = TradeController.getInstance().getBuyList(val);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
activeChar.sendPacket(new BuyList(list, activeChar.getAdena(), 0));
|
||||
activeChar.sendPacket(new ExBuySellListPacket(activeChar, list, 0, false));
|
||||
if (Config.DEBUG)
|
||||
_log.fine("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") opened GM shop id " + val);
|
||||
}
|
||||
else
|
||||
{
|
||||
_log.warning("no buylist with id:" + val);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
}
|
||||
+346
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.sql.SQLException;
|
||||
|
||||
import javolution.text.TextBuilder;
|
||||
|
||||
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;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
/**
|
||||
* @author Korvin
|
||||
* con.close() change by Zoey76 24/02/2011
|
||||
*/
|
||||
public class AdminShowQuests implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_charquestmenu",
|
||||
"admin_setcharquest"
|
||||
};
|
||||
|
||||
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 instanceof L2PcInstance)
|
||||
target = (L2PcInstance) targetObject;
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (command.startsWith("admin_charquestmenu"))
|
||||
{
|
||||
if (val[0] != null)
|
||||
try
|
||||
{
|
||||
showquestmenu(target,activeChar,val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
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];
|
||||
try
|
||||
{
|
||||
setquestvar(target,activeChar,val);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
};
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showfirstquestmenu(L2PcInstance target, L2PcInstance actor)
|
||||
{
|
||||
TextBuilder replyMSG = new TextBuilder("<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>");
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
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 void showquestmenu(L2PcInstance target, L2PcInstance actor, String[] val) throws SQLException
|
||||
{
|
||||
Connection con = null;
|
||||
try
|
||||
{
|
||||
ResultSet rs;
|
||||
PreparedStatement req;
|
||||
int ID = target.getObjectId();
|
||||
|
||||
TextBuilder replyMSG = new TextBuilder("<html><body>");
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
con = L2DatabaseFactory.getInstance().getConnection();
|
||||
|
||||
if (val[0].equals("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 +"' 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>");
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
else if (val[0].equals("name"))
|
||||
{
|
||||
String[] states = {"CREATED","STARTED","COMPLETED"};
|
||||
String state = states[target.getQuestState(val[1]).getState()];
|
||||
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;
|
||||
else
|
||||
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 COMLETED 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 COMLETED 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>");
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
else if (val[0].equals("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>");
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
else if (val[0].equals("custom"))
|
||||
{
|
||||
boolean exqdb = true;
|
||||
boolean exqch = true;
|
||||
int qnumber = Integer.parseInt(val[1]);
|
||||
String state = null;
|
||||
String qname = null;
|
||||
QuestState qs = null;
|
||||
String[] states = {"CREATED","STARTED","COMPLETED"};
|
||||
|
||||
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;
|
||||
else
|
||||
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 COMLETED 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 COMLETED 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>");
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
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>");
|
||||
}
|
||||
}
|
||||
adminReply.setHtml(replyMSG.toString());
|
||||
actor.sendPacket(adminReply);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
actor.sendMessage("Error!");
|
||||
//e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
private void setquestvar(L2PcInstance target, L2PcInstance actor, String[] val)
|
||||
{
|
||||
QuestState qs = target.getQuestState(val[0]);
|
||||
String[] outval = new String[3];
|
||||
|
||||
if(val[1].equals("state"))
|
||||
{
|
||||
if(val[2].equals("COMLETED"))
|
||||
{
|
||||
qs.exitQuest((val[3].equals("1")) ? true : false);
|
||||
}
|
||||
else if(val[2].equals("DELETE"))
|
||||
{
|
||||
qs.getQuest();
|
||||
Quest.deleteQuestInDb(qs);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getQuestIntId()));
|
||||
}
|
||||
else if(val[2].equals("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().getQuestIntId()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
}
|
||||
else if(val[2].equals("CC"))
|
||||
{
|
||||
qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
|
||||
qs.exitQuest(false);
|
||||
target.sendPacket(new QuestList());
|
||||
target.sendPacket(new ExShowQuestMark(qs.getQuest().getQuestIntId()));
|
||||
val[0] = qs.getQuest().getName();
|
||||
}
|
||||
}
|
||||
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().getQuestIntId()));
|
||||
}
|
||||
actor.sendMessage("");
|
||||
outval[0] = "name";
|
||||
outval[1] = val[0];
|
||||
try
|
||||
{
|
||||
showquestmenu(target,actor,outval);
|
||||
}
|
||||
catch(Exception e)
|
||||
{};
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.Config;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_server_shutdown"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(command.substring(22));
|
||||
serverShutdown(activeChar, val, false);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_restart"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int val = Integer.parseInt(command.substring(21));
|
||||
serverShutdown(activeChar, val, true);
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{
|
||||
sendHtmlForm(activeChar);
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_server_abort"))
|
||||
{
|
||||
serverAbort(activeChar);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void sendHtmlForm(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
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(), "data/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("%xp%", String.valueOf(Config.RATE_XP));
|
||||
adminReply.replace("%sp%", String.valueOf(Config.RATE_SP));
|
||||
adminReply.replace("%adena%", String.valueOf(Config.RATE_DROP_ITEMS_ID.get(57)));
|
||||
adminReply.replace("%drop%", String.valueOf(Config.RATE_DROP_ITEMS));
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
+365
@@ -0,0 +1,365 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.SevenSigns;
|
||||
import com.l2jserver.gameserver.datatables.ClanTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.AuctionManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.ClanHallManager;
|
||||
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.Castle;
|
||||
import com.l2jserver.gameserver.model.entity.ClanHall;
|
||||
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.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 AdminSiege implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_siege",
|
||||
"admin_add_attacker",
|
||||
"admin_add_defender",
|
||||
"admin_add_guard",
|
||||
"admin_list_siege_clans",
|
||||
"admin_clear_siege_list",
|
||||
"admin_move_defenders",
|
||||
"admin_spawn_doors",
|
||||
"admin_endsiege",
|
||||
"admin_startsiege",
|
||||
"admin_setsiegetime",
|
||||
"admin_setcastle",
|
||||
"admin_removecastle",
|
||||
"admin_clanhall",
|
||||
"admin_clanhallset",
|
||||
"admin_clanhalldel",
|
||||
"admin_clanhallopendoors",
|
||||
"admin_clanhallclosedoors",
|
||||
"admin_clanhallteleportself"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command, " ");
|
||||
command = st.nextToken(); // Get actual command
|
||||
|
||||
// Get castle
|
||||
Castle castle = null;
|
||||
ClanHall clanhall = null;
|
||||
if (st.hasMoreTokens()) {
|
||||
if (command.startsWith("admin_clanhall")) {
|
||||
try
|
||||
{
|
||||
clanhall = ClanHallManager.getInstance().getClanHallById(Integer.parseInt(st.nextToken()));
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
else
|
||||
castle = CastleManager.getInstance().getCastle(st.nextToken());
|
||||
}
|
||||
if ((castle == null || castle.getCastleId() < 0) && clanhall == null)
|
||||
// No castle specified
|
||||
showCastleSelectPage(activeChar);
|
||||
else
|
||||
{
|
||||
String val = "";
|
||||
if (st.hasMoreTokens())
|
||||
val = st.nextToken();
|
||||
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
|
||||
if (command.equalsIgnoreCase("admin_add_attacker"))
|
||||
{
|
||||
if (player == null)
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else
|
||||
castle.getSiege().registerAttacker(player, true);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_add_defender"))
|
||||
{
|
||||
if (player == null)
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else
|
||||
castle.getSiege().registerDefender(player, true);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_add_guard"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int npcId = Integer.parseInt(val);
|
||||
castle.getSiege().getSiegeGuardManager().addSiegeGuard(activeChar, npcId);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_guard castle npcId");
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clear_siege_list"))
|
||||
{
|
||||
castle.getSiege().clearSiegeClan();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_endsiege"))
|
||||
{
|
||||
castle.getSiege().endSiege();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_list_siege_clans"))
|
||||
{
|
||||
castle.getSiege().listRegisterClan(activeChar);
|
||||
return true;
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_move_defenders"))
|
||||
{
|
||||
activeChar.sendMessage("Not implemented yet.");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_setcastle"))
|
||||
{
|
||||
if (player == null || player.getClan() == null)
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else
|
||||
castle.setOwner(player.getClan());
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_removecastle"))
|
||||
{
|
||||
L2Clan clan = ClanTable.getInstance().getClan(castle.getOwnerId());
|
||||
if (clan != null)
|
||||
castle.removeOwner(clan);
|
||||
else
|
||||
activeChar.sendMessage("Unable to remove castle");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_setsiegetime"))
|
||||
{
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
Calendar newAdminSiegeDate = castle.getSiegeDate();
|
||||
if (val.equalsIgnoreCase("day"))
|
||||
newAdminSiegeDate.set(Calendar.DAY_OF_YEAR, Integer.parseInt(st.nextToken()));
|
||||
else if (val.equalsIgnoreCase("hour"))
|
||||
newAdminSiegeDate.set(Calendar.HOUR_OF_DAY, Integer.parseInt(st.nextToken()));
|
||||
else if (val.equalsIgnoreCase("min"))
|
||||
newAdminSiegeDate.set(Calendar.MINUTE, Integer.parseInt(st.nextToken()));
|
||||
|
||||
if (newAdminSiegeDate.getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
|
||||
{
|
||||
activeChar.sendMessage("Unable to change Siege Date");
|
||||
}
|
||||
else if (newAdminSiegeDate.getTimeInMillis() != castle.getSiegeDate().getTimeInMillis())
|
||||
{
|
||||
castle.getSiegeDate().setTimeInMillis(newAdminSiegeDate.getTimeInMillis());
|
||||
castle.getSiege().saveSiegeDate();
|
||||
}
|
||||
}
|
||||
showSiegeTimePage(activeChar,castle);
|
||||
return true;
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clanhallset"))
|
||||
{
|
||||
if (player == null || player.getClan() == null)
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
else if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
|
||||
activeChar.sendMessage("This ClanHall isn't free!");
|
||||
else if (player.getClan().getHasHideout() == 0)
|
||||
{
|
||||
ClanHallManager.getInstance().setOwner(clanhall.getId(), player.getClan());
|
||||
if (AuctionManager.getInstance().getAuction(clanhall.getId()) != null)
|
||||
AuctionManager.getInstance().getAuction(clanhall.getId()).deleteAuctionFromDB();
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("You have already a ClanHall!");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clanhalldel"))
|
||||
{
|
||||
if (!ClanHallManager.getInstance().isFree(clanhall.getId()))
|
||||
{
|
||||
ClanHallManager.getInstance().setFree(clanhall.getId());
|
||||
AuctionManager.getInstance().initNPC(clanhall.getId());
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("This ClanHall is already Free!");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clanhallopendoors"))
|
||||
{
|
||||
clanhall.openCloseDoors(true);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clanhallclosedoors"))
|
||||
{
|
||||
clanhall.openCloseDoors(false);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_clanhallteleportself"))
|
||||
{
|
||||
L2ClanHallZone zone = clanhall.getZone();
|
||||
if (zone != null)
|
||||
{
|
||||
activeChar.teleToLocation(zone.getSpawnLoc(), true);
|
||||
}
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_doors"))
|
||||
{
|
||||
castle.spawnDoor();
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_startsiege"))
|
||||
{
|
||||
castle.getSiege().startSiege();
|
||||
}
|
||||
if (clanhall != null)
|
||||
showClanHallPage(activeChar, clanhall);
|
||||
else
|
||||
showSiegePage(activeChar, castle.getName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void showCastleSelectPage(L2PcInstance activeChar)
|
||||
{
|
||||
int i = 0;
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castles.htm");
|
||||
final StringBuilder cList = new StringBuilder(500);
|
||||
for (Castle castle : CastleManager.getInstance().getCastles()) {
|
||||
if (castle != null) {
|
||||
String name = castle.getName();
|
||||
StringUtil.append(cList,
|
||||
"<td fixwidth=90><a action=\"bypass -h admin_siege ",
|
||||
name,
|
||||
"\">",
|
||||
name,
|
||||
"</a></td>");
|
||||
i++;
|
||||
}
|
||||
if (i > 2) {
|
||||
cList.append("</tr><tr>");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
adminReply.replace("%castles%", 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);
|
||||
}
|
||||
|
||||
private void showSiegePage(L2PcInstance activeChar, String castleName)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castle.htm");
|
||||
adminReply.replace("%castleName%", castleName);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showSiegeTimePage(L2PcInstance activeChar, Castle castle)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/castlesiegetime.htm");
|
||||
adminReply.replace("%castleName%", castle.getName());
|
||||
adminReply.replace("%time%", castle.getSiegeDate().getTime().toString());
|
||||
Calendar newDay = Calendar.getInstance();
|
||||
boolean isSunday = false;
|
||||
if (newDay.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
|
||||
isSunday = true;
|
||||
else
|
||||
newDay.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
|
||||
if (!SevenSigns.getInstance().isDateInSealValidPeriod(newDay))
|
||||
newDay.add(Calendar.DAY_OF_MONTH, 7);
|
||||
|
||||
if (isSunday)
|
||||
{
|
||||
adminReply.replace("%sundaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
|
||||
adminReply.replace("%sunday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
|
||||
newDay.add(Calendar.DAY_OF_MONTH, 13);
|
||||
adminReply.replace("%saturdaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
|
||||
adminReply.replace("%saturday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
|
||||
}
|
||||
else
|
||||
{
|
||||
adminReply.replace("%saturdaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
|
||||
adminReply.replace("%saturday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
|
||||
newDay.add(Calendar.DAY_OF_MONTH, 1);
|
||||
adminReply.replace("%sundaylink%", String.valueOf(newDay.get(Calendar.DAY_OF_YEAR)));
|
||||
adminReply.replace("%sunday%", String.valueOf(newDay.get(Calendar.MONTH) + "/" + String.valueOf(newDay.get(Calendar.DAY_OF_MONTH))));
|
||||
}
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showClanHallPage(L2PcInstance activeChar, ClanHall clanhall)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/clanhall.htm");
|
||||
adminReply.replace("%clanhallName%", clanhall.getName());
|
||||
adminReply.replace("%clanhallId%", String.valueOf(clanhall.getId()));
|
||||
L2Clan owner = ClanTable.getInstance().getClan(clanhall.getOwnerId());
|
||||
if (owner == null)
|
||||
adminReply.replace("%clanhallOwner%", "None");
|
||||
else
|
||||
adminReply.replace("%clanhallOwner%", owner.getName());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+523
@@ -0,0 +1,523 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.datatables.SkillTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
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.network.serverpackets.PledgeSkillList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
|
||||
/**
|
||||
* This class handles following admin commands:
|
||||
* - show_skills
|
||||
* - remove_skills
|
||||
* - skill_list
|
||||
* - skill_index
|
||||
* - add_skill
|
||||
* - remove_skill
|
||||
* - get_skills
|
||||
* - reset_skills
|
||||
* - give_all_skills
|
||||
* - give_all_skills_fs
|
||||
* - remove_all_skills
|
||||
* - add_clan_skills
|
||||
* - admin_setskill
|
||||
*
|
||||
* @version $Revision: 1.2.4.7 $ $Date: 2005/04/11 10:06:02 $
|
||||
* 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_remove_all_skills",
|
||||
"admin_add_clan_skill",
|
||||
"admin_setskill"
|
||||
};
|
||||
|
||||
private static L2Skill[] adminSkills;
|
||||
|
||||
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"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "skills.htm");
|
||||
}
|
||||
else if (command.startsWith("admin_skill_index"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String val = command.substring(18);
|
||||
AdminHelpPage.showHelpPage(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_remove_all_skills"))
|
||||
{
|
||||
if (activeChar.getTarget() instanceof L2PcInstance)
|
||||
{
|
||||
L2PcInstance player = (L2PcInstance) activeChar.getTarget();
|
||||
for (L2Skill skill : player.getAllSkills())
|
||||
player.removeSkill(skill);
|
||||
activeChar.sendMessage("You removed all skills from " + player.getName());
|
||||
player.sendMessage("Admin removed all skills from you.");
|
||||
player.sendSkillList();
|
||||
player.broadcastUserInfo();
|
||||
}
|
||||
}
|
||||
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]);
|
||||
L2Skill skill = SkillTable.getInstance().getInfo(id, lvl);
|
||||
activeChar.addSkill(skill);
|
||||
activeChar.sendSkillList();
|
||||
activeChar.sendMessage("You added yourself skill "+skill.getName()+"("+id+") level "+lvl);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will give all the skills that the target can learn at his/her level
|
||||
* @param activeChar: the gm char
|
||||
*/
|
||||
private void adminGiveAllSkills(L2PcInstance activeChar, boolean includedByFs)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
//Notify player and admin
|
||||
activeChar.sendMessage("You gave " + player.giveAvailableSkills(includedByFs, true) + " skills to " + player.getName());
|
||||
player.sendSkillList();
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void removeSkillsPage(L2PcInstance activeChar, int page)
|
||||
{ //TODO: Externalize HTML
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_IS_INCORRECT));
|
||||
return;
|
||||
}
|
||||
|
||||
L2Skill[] skills = player.getAllSkills();
|
||||
|
||||
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;
|
||||
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
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()),
|
||||
" ",
|
||||
player.getTemplate().className,
|
||||
"</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);
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/charskills.htm");
|
||||
adminReply.replace("%name%", player.getName());
|
||||
adminReply.replace("%level%", String.valueOf(player.getLevel()));
|
||||
adminReply.replace("%class%", player.getTemplate().className);
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void adminGetSkills(L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
if (player.getName().equals(activeChar.getName()))
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_ON_YOURSELF));
|
||||
else
|
||||
{
|
||||
L2Skill[] skills = player.getAllSkills();
|
||||
adminSkills = activeChar.getAllSkills();
|
||||
for (L2Skill skill: adminSkills)
|
||||
activeChar.removeSkill(skill);
|
||||
for (L2Skill skill: skills)
|
||||
activeChar.addSkill(skill, true);
|
||||
activeChar.sendMessage("You now have all the skills of " + player.getName() + ".");
|
||||
activeChar.sendSkillList();
|
||||
}
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
|
||||
private void adminResetSkills(L2PcInstance activeChar)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
if (adminSkills == null)
|
||||
activeChar.sendMessage("You must get the skills of someone in order to do this.");
|
||||
else
|
||||
{
|
||||
L2Skill[] skills = player.getAllSkills();
|
||||
for (L2Skill skill: skills)
|
||||
player.removeSkill(skill);
|
||||
for (L2Skill skill: activeChar.getAllSkills())
|
||||
player.addSkill(skill, true);
|
||||
for (L2Skill skill: skills)
|
||||
activeChar.removeSkill(skill);
|
||||
for (L2Skill 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);
|
||||
}
|
||||
|
||||
private void adminAddSkill(L2PcInstance activeChar, String val)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
StringTokenizer st = new StringTokenizer(val);
|
||||
if (st.countTokens() != 2)
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Skill skill = null;
|
||||
try
|
||||
{
|
||||
String id = st.nextToken();
|
||||
String level = st.nextToken();
|
||||
int idval = Integer.parseInt(id);
|
||||
int levelval = Integer.parseInt(level);
|
||||
skill = SkillTable.getInstance().getInfo(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
|
||||
}
|
||||
}
|
||||
|
||||
private void adminRemoveSkill(L2PcInstance activeChar, int idval)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
L2Skill skill = SkillTable.getInstance().getInfo(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
|
||||
}
|
||||
|
||||
private void adminAddClanSkill(L2PcInstance activeChar, int id, int level)
|
||||
{
|
||||
L2Object target = activeChar.getTarget();
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
player = (L2PcInstance) target;
|
||||
else
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
if (!player.isClanLeader())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_IS_NOT_A_CLAN_LEADER).addString(player.getName()));
|
||||
showMainPage(activeChar);
|
||||
return;
|
||||
}
|
||||
if ((id < 370) || (id > 391) || (level < 1) || (level > 3))
|
||||
{
|
||||
activeChar.sendMessage("Usage: //add_clan_skill <skill_id> <level>");
|
||||
showMainPage(activeChar);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
L2Skill skill = SkillTable.getInstance().getInfo(id, level);
|
||||
if (skill != null)
|
||||
{
|
||||
String skillname = skill.getName();
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_SKILL_S1_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);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Error: there is no such skill.");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+442
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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 java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.GmListTable;
|
||||
import com.l2jserver.gameserver.SevenSigns;
|
||||
import com.l2jserver.gameserver.datatables.NpcTable;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.datatables.TeleportLocationTable;
|
||||
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.AutoChatHandler;
|
||||
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.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.templates.chars.L2NpcTemplate;
|
||||
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 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_teleport_reload",
|
||||
"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"
|
||||
};
|
||||
public static Logger _log = Logger.getLogger(AdminSpawn.class.getName());
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_show_spawns"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "spawns.htm");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_spawn_debug_menu"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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"))
|
||||
AdminHelpPage.showHelpPage(activeChar, "spawns_debug.htm");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
activeChar.sendPacket(SystemMessageId.INCORRECT_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)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "spawns.htm");
|
||||
}
|
||||
}
|
||||
else if (command.equals("admin_show_npcs"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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>");
|
||||
NpcHtmlMessage ms = new NpcHtmlMessage(1);
|
||||
ms.setHtml(html.toString());
|
||||
activeChar.sendPacket(ms);
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("Cannot find instance "+instance);
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("Invalid instance number.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage //instance_spawns <instance_number>");
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("admin_unspawnall"))
|
||||
{
|
||||
Broadcast.toAllOnlinePlayers(SystemMessage.getSystemMessage(SystemMessageId.NPC_SERVER_NOT_OPERATING));
|
||||
RaidBossSpawnManager.getInstance().cleanUp();
|
||||
DayNightSpawnManager.getInstance().cleanUp();
|
||||
L2World.getInstance().deleteVisibleNpcSpawns();
|
||||
GmListTable.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
|
||||
NpcTable.getInstance().reloadAllNpc();
|
||||
SpawnTable.getInstance().reloadAll();
|
||||
RaidBossSpawnManager.getInstance().reloadBosses();
|
||||
AutoSpawnHandler.getInstance().reload();
|
||||
AutoChatHandler.getInstance().reload();
|
||||
SevenSigns.getInstance().spawnSevenSignsNPC();
|
||||
QuestManager.getInstance().reloadAllQuests();
|
||||
GmListTable.broadcastMessageToGMs("NPC Respawn completed!");
|
||||
}
|
||||
else if (command.startsWith("admin_teleport_reload"))
|
||||
{
|
||||
TeleportLocationTable.getInstance().reloadAll();
|
||||
GmListTable.broadcastMessageToGMs("Teleport List Table reloaded.");
|
||||
}
|
||||
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 = 0;
|
||||
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
|
||||
AdminHelpPage.showHelpPage(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 = NpcTable.getInstance().getTemplateByName(params[1]).npcId;
|
||||
}
|
||||
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"))
|
||||
SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex, true);
|
||||
else
|
||||
SpawnTable.getInstance().findNPCInstances(activeChar, npcId, teleportIndex, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void printSpawn(L2Npc target, int type)
|
||||
{
|
||||
int i = target.getNpcId();
|
||||
int x = target.getSpawn().getLocx();
|
||||
int y = target.getSpawn().getLocy();
|
||||
int z = target.getSpawn().getLocz();
|
||||
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 template1;
|
||||
if (monsterId.matches("[0-9]*"))
|
||||
{
|
||||
//First parameter was an ID number
|
||||
int monsterTemplate = Integer.parseInt(monsterId);
|
||||
template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
|
||||
}
|
||||
else
|
||||
{
|
||||
//First parameter wasn't just numbers so go by name not ID
|
||||
monsterId = monsterId.replace('_', ' ');
|
||||
template1 = NpcTable.getInstance().getTemplateByName(monsterId);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
L2Spawn spawn = new L2Spawn(template1);
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
spawn.setCustom(true);
|
||||
spawn.setLocx(target.getX());
|
||||
spawn.setLocy(target.getY());
|
||||
spawn.setLocz(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.getNpcid()))
|
||||
activeChar.sendMessage("You cannot spawn another instance of " + template1.name + ".");
|
||||
else
|
||||
{
|
||||
if (RaidBossSpawnManager.getInstance().getValidTemplate(spawn.getNpcid()) != null)
|
||||
{
|
||||
spawn.setRespawnMinDelay(43200);
|
||||
spawn.setRespawnMaxDelay(129600);
|
||||
RaidBossSpawnManager.getInstance().addNewSpawn(spawn, 0, template1.baseHpMax, template1.baseMpMax, permanent);
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnTable.getInstance().addNewSpawn(spawn, permanent);
|
||||
spawn.init();
|
||||
}
|
||||
if (!permanent)
|
||||
spawn.stopRespawn();
|
||||
activeChar.sendMessage("Created " + template1.name + " on " + target.getObjectId());
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.TARGET_CANT_FOUND));
|
||||
}
|
||||
}
|
||||
|
||||
private void showMonsters(L2PcInstance activeChar, int level, int from)
|
||||
{
|
||||
L2NpcTemplate[] mobs = NpcTable.getInstance().getAllMonstersOfLevel(level);
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + mobs.length * 80,
|
||||
"<html><title>Spawn Monster:</title><body><p> Level : ",
|
||||
Integer.toString(level),
|
||||
"<br>Total Npc's : ",
|
||||
Integer.toString(mobs.length),
|
||||
"<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; i < mobs.length && j < 50; i++, j++)
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs[i].npcId), "\">", mobs[i].name, "</a><br1>");
|
||||
|
||||
if (i == mobs.length)
|
||||
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(5, tb.toString()));
|
||||
}
|
||||
|
||||
private void showNpcs(L2PcInstance activeChar, String starting, int from)
|
||||
{
|
||||
L2NpcTemplate[] mobs = NpcTable.getInstance().getAllNpcStartingWith(starting);
|
||||
final StringBuilder tb = StringUtil.startAppend(500 + mobs.length * 80,
|
||||
"<html><title>Spawn Monster:</title><body><p> There are ",
|
||||
Integer.toString(mobs.length),
|
||||
" Npcs whose name starts with ",
|
||||
starting,
|
||||
":<br>");
|
||||
|
||||
// Loop
|
||||
int i = from;
|
||||
for (int j = 0; i < mobs.length && j < 50; i++, j++)
|
||||
StringUtil.append(tb, "<a action=\"bypass -h admin_spawn_monster ", Integer.toString(mobs[i].npcId), "\">", mobs[i].name, "</a><br1>");
|
||||
|
||||
if (i == mobs.length)
|
||||
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(5, tb.toString()));
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.datatables.AdminCommandAccessRights;
|
||||
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
|
||||
{
|
||||
Logger _log = Logger.getLogger(AdminSummon.class.getName());
|
||||
|
||||
public static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_summon"
|
||||
};
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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 (!AdminCommandAccessRights.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().getAdminCommandHandler(subCommand);
|
||||
ach.useAdminCommand(subCommand + " " + id + " " + count, activeChar);
|
||||
}
|
||||
else
|
||||
{
|
||||
subCommand = "admin_spawn_once";
|
||||
if (!AdminCommandAccessRights.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().getAdminCommandHandler(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;
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.startsWith("admin_target"))
|
||||
handleTarget(command, activeChar);
|
||||
return true;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+570
@@ -0,0 +1,570 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.NpcTable;
|
||||
import com.l2jserver.gameserver.datatables.SpawnTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.RaidBossSpawnManager;
|
||||
import com.l2jserver.gameserver.model.L2CharPosition;
|
||||
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.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.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
|
||||
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_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"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_teleto"))
|
||||
{
|
||||
activeChar.setTeleMode(1);
|
||||
}
|
||||
if (command.equals("admin_instant_move"))
|
||||
{
|
||||
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"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "teleports.htm");
|
||||
}
|
||||
if (command.equals("admin_show_moves_other"))
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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);
|
||||
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);
|
||||
L2CharPosition pos = new L2CharPosition(x, y, z, 0);
|
||||
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, pos);
|
||||
}
|
||||
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
|
||||
AdminHelpPage.showHelpPage(activeChar, "teleports.htm");
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //move_to <x> <y> <z>");
|
||||
AdminHelpPage.showHelpPage(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_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.getX(), activeChar.getY(), activeChar.getZ(), 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(x, y, z, false);
|
||||
showTeleportWindow(activeChar);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Usage: //go<north|south|east|west|up|down> [offset] (default 150)");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
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, false);
|
||||
|
||||
activeChar.sendMessage("You have been teleported to " + Coords);
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
activeChar.sendMessage("Wrong or no Coordinates given.");
|
||||
}
|
||||
}
|
||||
|
||||
private void showTeleportWindow(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
|
||||
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(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_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, x, y, z, null);
|
||||
}
|
||||
catch (NoSuchElementException nsee)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param x
|
||||
* @param y
|
||||
* @param z
|
||||
*/
|
||||
private void teleportCharacter(L2PcInstance player, int x, int y, int z, L2PcInstance activeChar)
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
// Check for jail
|
||||
if (player.isInJail())
|
||||
{
|
||||
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());
|
||||
else
|
||||
player.setInstanceId(0);
|
||||
|
||||
// Information
|
||||
activeChar.sendMessage("You have recalled " + player.getName());
|
||||
player.sendMessage("Admin is teleporting you.");
|
||||
|
||||
player.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
|
||||
player.teleToLocation(x, y, z, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
|
||||
{
|
||||
if (target == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
|
||||
L2PcInstance player = null;
|
||||
if (target instanceof L2PcInstance)
|
||||
{
|
||||
player = (L2PcInstance) target;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getObjectId() == activeChar.getObjectId())
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANNOT_USE_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(x, y, z, true);
|
||||
|
||||
activeChar.sendMessage("You have teleported to character " + player.getName() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private void changeCharacterPosition(L2PcInstance activeChar, String name)
|
||||
{
|
||||
Connection con = null;
|
||||
final int x = activeChar.getX();
|
||||
final int y = activeChar.getY();
|
||||
final int z = activeChar.getZ();
|
||||
try
|
||||
{
|
||||
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");
|
||||
}
|
||||
finally
|
||||
{
|
||||
L2DatabaseFactory.close(con);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
int monsterTemplate = target.getTemplate().npcId;
|
||||
L2NpcTemplate template1 = NpcTable.getInstance().getTemplate(monsterTemplate);
|
||||
if (template1 == null)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect monster template.");
|
||||
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' template.");
|
||||
return;
|
||||
}
|
||||
|
||||
L2Spawn spawn = target.getSpawn();
|
||||
if (spawn == null)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect monster spawn.");
|
||||
_log.warning("ERROR: NPC " + target.getObjectId() + " has a 'null' spawn.");
|
||||
return;
|
||||
}
|
||||
int respawnTime = spawn.getRespawnDelay() / 1000;
|
||||
|
||||
target.deleteMe();
|
||||
spawn.stopRespawn();
|
||||
SpawnTable.getInstance().deleteSpawn(spawn, true);
|
||||
|
||||
try
|
||||
{
|
||||
//L2MonsterInstance mob = new L2MonsterInstance(monsterTemplate, template1);
|
||||
|
||||
spawn = new L2Spawn(template1);
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
spawn.setCustom(true);
|
||||
spawn.setLocx(activeChar.getX());
|
||||
spawn.setLocy(activeChar.getY());
|
||||
spawn.setLocz(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 " + template1.name + " on " + target.getObjectId() + ".");
|
||||
|
||||
if (Config.DEBUG)
|
||||
{
|
||||
_log.fine("Spawn at X=" + spawn.getLocx() + " Y=" + spawn.getLocy() + " Z=" + spawn.getLocz());
|
||||
_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.getNpcId() + " has a 'null' spawn.");
|
||||
return;
|
||||
}
|
||||
RaidBossSpawnManager.getInstance().deleteSpawn(spawn, true);
|
||||
try
|
||||
{
|
||||
L2NpcTemplate template = NpcTable.getInstance().getTemplate(target.getNpcId());
|
||||
L2Spawn spawnDat = new L2Spawn(template);
|
||||
if (Config.SAVE_GMSPAWN_ON_CUSTOM)
|
||||
spawn.setCustom(true);
|
||||
spawnDat.setLocx(activeChar.getX());
|
||||
spawnDat.setLocy(activeChar.getY());
|
||||
spawnDat.setLocz(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(SystemMessage.getSystemMessage(SystemMessageId.TARGET_CANT_FOUND));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.INCORRECT_TARGET));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.QuestManager;
|
||||
import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.quest.Quest;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
/**
|
||||
* Admin comand handler for Territory War System
|
||||
* This class handles following admin commands:
|
||||
*
|
||||
* @author Gigiikun
|
||||
*/
|
||||
public class AdminTerritoryWar implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] _adminCommands =
|
||||
{
|
||||
"admin_territory_war",
|
||||
"admin_territory_war_time",
|
||||
"admin_territory_war_start",
|
||||
"admin_territory_war_end"
|
||||
};
|
||||
|
||||
public boolean useAdminCommand(String command, L2PcInstance activeChar)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
command = st.nextToken();
|
||||
|
||||
if (command.equals("admin_territory_war"))
|
||||
{
|
||||
showMainPage(activeChar);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_territory_war_time"))
|
||||
{
|
||||
String val = "";
|
||||
if (st.hasMoreTokens())
|
||||
{
|
||||
val = st.nextToken();
|
||||
Calendar newAdminTWDate = Calendar.getInstance();
|
||||
newAdminTWDate.setTimeInMillis(TerritoryWarManager.getInstance().getTWStartTimeInMillis());
|
||||
if (val.equalsIgnoreCase("day"))
|
||||
newAdminTWDate.set(Calendar.DAY_OF_WEEK, Integer.parseInt(st.nextToken()));
|
||||
else if (val.equalsIgnoreCase("hour"))
|
||||
newAdminTWDate.set(Calendar.HOUR_OF_DAY, Integer.parseInt(st.nextToken()));
|
||||
else if (val.equalsIgnoreCase("min"))
|
||||
newAdminTWDate.set(Calendar.MINUTE, Integer.parseInt(st.nextToken()));
|
||||
|
||||
if (newAdminTWDate.getTimeInMillis() < Calendar.getInstance().getTimeInMillis())
|
||||
{
|
||||
activeChar.sendMessage("Unable to change TW Date!");
|
||||
}
|
||||
else if (newAdminTWDate.getTimeInMillis() != TerritoryWarManager.getInstance().getTWStartTimeInMillis())
|
||||
{
|
||||
Quest twQuest = QuestManager.getInstance().getQuest(TerritoryWarManager.qn);
|
||||
if (twQuest != null)
|
||||
twQuest.onAdvEvent("setTWDate " + newAdminTWDate.getTimeInMillis(), null, null);
|
||||
else
|
||||
activeChar.sendMessage("Missing Territory War Quest!");
|
||||
}
|
||||
}
|
||||
showSiegeTimePage(activeChar);
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_territory_war_start"))
|
||||
{
|
||||
Quest twQuest = QuestManager.getInstance().getQuest(TerritoryWarManager.qn);
|
||||
if (twQuest != null)
|
||||
twQuest.onAdvEvent("setTWDate " + Calendar.getInstance().getTimeInMillis(), null, null);
|
||||
else
|
||||
activeChar.sendMessage("Missing Territory War Quest!");
|
||||
}
|
||||
else if (command.equalsIgnoreCase("admin_territory_war_end"))
|
||||
{
|
||||
Quest twQuest = QuestManager.getInstance().getQuest(TerritoryWarManager.qn);
|
||||
if (twQuest != null)
|
||||
twQuest.onAdvEvent("setTWDate " + (Calendar.getInstance().getTimeInMillis() - TerritoryWarManager.WARLENGTH), null, null);
|
||||
else
|
||||
activeChar.sendMessage("Missing Territory War Quest!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return _adminCommands;
|
||||
}
|
||||
|
||||
private void showSiegeTimePage(L2PcInstance activeChar)
|
||||
{
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/territorywartime.htm");
|
||||
adminReply.replace("%time%", TerritoryWarManager.getInstance().getTWStart().getTime().toString());
|
||||
activeChar.sendPacket(adminReply);
|
||||
}
|
||||
|
||||
private void showMainPage(L2PcInstance activeChar)
|
||||
{
|
||||
AdminHelpPage.showHelpPage(activeChar, "territorywar.htm");
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
|
||||
*
|
||||
* $Author: luisantonioa $
|
||||
* $Date: 25/07/2005 17:15:21 $
|
||||
* $Revision: 1 $
|
||||
* $Log: AdminTest.java,v $
|
||||
* Revision 1 25/07/2005 17:15:21 luisantonioa
|
||||
* Added copyright notice
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.SkillTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
import com.l2jserver.gameserver.model.L2Object;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
|
||||
|
||||
|
||||
/**
|
||||
* This class ...
|
||||
*
|
||||
* @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"
|
||||
};
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.L2PcInstance)
|
||||
*/
|
||||
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") || command.startsWith("admin_st"))
|
||||
{
|
||||
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
|
||||
*/
|
||||
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;
|
||||
|
||||
L2Skill _skill = SkillTable.getInstance().getInfo(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);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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 FBIagent
|
||||
*/
|
||||
public class AdminTvTEvent implements IAdminCommandHandler
|
||||
{
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_tvt_add",
|
||||
"admin_tvt_remove",
|
||||
"admin_tvt_advance"
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
private void add(L2PcInstance activeChar, L2PcInstance playerInstance)
|
||||
{
|
||||
if (TvTEvent.isPlayerParticipant(playerInstance.getObjectId()))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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(AdminTeleport.class.getName());
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_unblockip"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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)
|
||||
{
|
||||
// Send syntax to the user
|
||||
activeChar.sendMessage("Usage mode: //unblockip <ip>");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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_set_vitality_level",
|
||||
"admin_full_vitality",
|
||||
"admin_empty_vitality",
|
||||
"admin_get_vitality"
|
||||
};
|
||||
|
||||
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 level = 0;
|
||||
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_set_vitality_level"))
|
||||
{
|
||||
try
|
||||
{
|
||||
level = Integer.parseInt(st.nextToken());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
activeChar.sendMessage("Incorrect vitality level (0-4)");
|
||||
}
|
||||
|
||||
if (level >= 0 && level <= 4)
|
||||
{
|
||||
if (level == 0)
|
||||
vitality = PcStat.MIN_VITALITY_POINTS;
|
||||
else
|
||||
vitality = PcStat.VITALITY_LEVELS[level-1];
|
||||
target.setVitalityPoints(vitality, true);
|
||||
target.sendMessage("Admin set your Vitality level to " + level);
|
||||
}
|
||||
else
|
||||
activeChar.sendMessage("Incorrect vitality level (0-4)");
|
||||
}
|
||||
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"))
|
||||
{
|
||||
level = target.getVitalityLevel();
|
||||
vitality = target.getVitalityPoints();
|
||||
|
||||
activeChar.sendMessage("Player vitality level: " + level);
|
||||
activeChar.sendMessage("Player vitality points: " + vitality);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
activeChar.sendMessage("Target not found or not a player");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
new AdminVitality();
|
||||
}
|
||||
}
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
|
||||
*
|
||||
* $Author: luisantonioa $
|
||||
* $Date: 25/07/2005 17:15:21 $
|
||||
* $Revision: 1 $
|
||||
* $Log: AdminTest.java,v $
|
||||
* Revision 1 25/07/2005 17:15:21 luisantonioa
|
||||
* Added copyright notice
|
||||
*
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received 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.datatables.MapRegionTable;
|
||||
import com.l2jserver.gameserver.handler.IAdminCommandHandler;
|
||||
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.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.model.zone.L2ZoneType;
|
||||
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_reload",
|
||||
"admin_zone_visual",
|
||||
"admin_zone_visual_clear"
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.actor.instance.L2PcInstance)
|
||||
*/
|
||||
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:" + MapRegionTable.getInstance().getMapRegionX(activeChar.getX()) + " y:" + MapRegionTable.getInstance().getMapRegionY(activeChar.getY()) + " ("+MapRegionTable.getInstance().getMapRegion(activeChar.getX(),activeChar.getY())+")");
|
||||
getGeoRegionXY(activeChar);
|
||||
activeChar.sendMessage("Closest Town: " + MapRegionTable.getInstance().getClosestTownName(activeChar));
|
||||
|
||||
Location loc;
|
||||
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Castle);
|
||||
activeChar.sendMessage("TeleToLocation (Castle): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.ClanHall);
|
||||
activeChar.sendMessage("TeleToLocation (ClanHall): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.SiegeFlag);
|
||||
activeChar.sendMessage("TeleToLocation (SiegeFlag): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
|
||||
loc = MapRegionTable.getInstance().getTeleToLocation(activeChar, MapRegionTable.TeleportWhereType.Town);
|
||||
activeChar.sendMessage("TeleToLocation (Town): x:" + loc.getX() + " y:" + loc.getY() + " z:" + loc.getZ());
|
||||
}
|
||||
else if (actualCommand.equalsIgnoreCase("admin_zone_reload"))
|
||||
{
|
||||
ZoneManager.getInstance().reload();
|
||||
activeChar.sendMessage("All Zones have been reloaded");
|
||||
}
|
||||
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());
|
||||
}
|
||||
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(), "data/html/admin/zone.htm");
|
||||
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
|
||||
adminReply.setHtml(htmContent);
|
||||
adminReply.replace("%PEACE%", (activeChar.isInsideZone(L2Character.ZONE_PEACE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%PVP%", (activeChar.isInsideZone(L2Character.ZONE_PVP) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%SIEGE%", (activeChar.isInsideZone(L2Character.ZONE_SIEGE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%TOWN%", (activeChar.isInsideZone(L2Character.ZONE_TOWN) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%CASTLE%", (activeChar.isInsideZone(L2Character.ZONE_CASTLE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%FORT%", (activeChar.isInsideZone(L2Character.ZONE_FORT) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOHQ%", (activeChar.isInsideZone(L2Character.ZONE_NOHQ) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%CLANHALL%", (activeChar.isInsideZone(L2Character.ZONE_CLANHALL) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%LAND%", (activeChar.isInsideZone(L2Character.ZONE_LANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOLAND%", (activeChar.isInsideZone(L2Character.ZONE_NOLANDING) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOSUMMON%", (activeChar.isInsideZone(L2Character.ZONE_NOSUMMONFRIEND) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%WATER%", (activeChar.isInsideZone(L2Character.ZONE_WATER) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%SWAMP%", (activeChar.isInsideZone(L2Character.ZONE_SWAMP) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%DANGER%", (activeChar.isInsideZone(L2Character.ZONE_DANGERAREA) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%NOSTORE%", (activeChar.isInsideZone(L2Character.ZONE_NOSTORE) ? "<font color=\"LEVEL\">YES</font>" : "NO"));
|
||||
adminReply.replace("%SCRIPT%", (activeChar.isInsideZone(L2Character.ZONE_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) // not display id for dynamic zones
|
||||
StringUtil.append(zones, "(", String.valueOf(zone.getId()), ")");
|
||||
}
|
||||
else
|
||||
StringUtil.append(zones, String.valueOf(zone.getId()));
|
||||
StringUtil.append(zones, " ");
|
||||
}
|
||||
}
|
||||
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+"");
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
|
||||
*/
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.network.serverpackets.ExShowVariationCancelWindow;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowVariationMakeWindow;
|
||||
|
||||
public class Augment implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Augment"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
switch(Integer.parseInt(command.substring(8, 9).trim()))
|
||||
{
|
||||
case 1:
|
||||
activeChar.sendPacket(new ExShowVariationMakeWindow());
|
||||
return true;
|
||||
case 2:
|
||||
activeChar.sendPacket(new ExShowVariationCancelWindow());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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 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"
|
||||
};
|
||||
|
||||
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.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2MerchantInstance))
|
||||
return false;
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc)target).getObjectId());
|
||||
if (activeChar.getLevel() < 40)
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item-lowlevel.htm");
|
||||
else if ((activeChar.getLevel() >= 40) && (activeChar.getLevel() < 46))
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_d.htm");
|
||||
else if ((activeChar.getLevel() >= 46) && (activeChar.getLevel() < 52))
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_c.htm");
|
||||
else if (activeChar.getLevel() >= 52)
|
||||
html.setFile(activeChar.getHtmlPrefix(), "data/html/common/shadow_item_b.htm");
|
||||
html.replace("%objectId%", String.valueOf(((L2Npc)target).getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.datatables.SkillTable;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.L2Skill;
|
||||
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.ActionFailed;
|
||||
|
||||
public class CPRecovery implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"CPRecovery"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
final L2Npc npc = (L2Npc) target;
|
||||
|
||||
if (npc.getNpcId() != 31225 && npc.getNpcId() != 31226)
|
||||
return false;
|
||||
|
||||
if (activeChar.isCursedWeaponEquipped())
|
||||
{
|
||||
activeChar.sendMessage("Go away, you're not welcome here.");
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!activeChar.reduceAdena("RestoreCP", 100, activeChar.getLastFolkNPC(), true))
|
||||
return false;
|
||||
|
||||
L2Skill skill = SkillTable.getInstance().getInfo(4380, 1);
|
||||
if (skill != null)
|
||||
{
|
||||
npc.setTarget(activeChar);
|
||||
npc.doCast(skill);
|
||||
}
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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;
|
||||
|
||||
public class ChatLink implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Chat"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (IndexOutOfBoundsException ioobe)
|
||||
{
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
}
|
||||
((L2Npc)target).showChatWindow(activeChar, val);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+143
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.Config;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
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.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.SystemMessage;
|
||||
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"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2WarehouseInstance) && !(target instanceof L2ClanHallManagerInstance))
|
||||
return false;
|
||||
|
||||
if (activeChar.isEnchanting())
|
||||
return false;
|
||||
|
||||
if (activeChar.getClan() == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_CLAN_WAREHOUSE));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (activeChar.getClan().getLevel() == 0)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.ONLY_LEVEL_1_CLAN_OR_HIGHER_CAN_USE_WAREHOUSE));
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // WithdrawC
|
||||
{
|
||||
if (Config.L2JMOD_ENABLE_WAREHOUSESORTING_CLAN)
|
||||
{
|
||||
NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc)target).getObjectId());
|
||||
msg.setFile(activeChar.getHtmlPrefix(), "data/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.tempInventoryDisable();
|
||||
|
||||
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.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final void showWithdrawWindow(L2PcInstance player, WarehouseListType itemtype, byte sortorder)
|
||||
{
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
|
||||
if ((player.getClanPrivileges() & L2Clan.CP_CL_VIEW_WAREHOUSE) != L2Clan.CP_CL_VIEW_WAREHOUSE)
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.YOU_DO_NOT_HAVE_THE_RIGHT_TO_USE_CLAN_WAREHOUSE));
|
||||
return;
|
||||
}
|
||||
|
||||
player.setActiveWarehouse(player.getClan().getWarehouse());
|
||||
|
||||
if (player.getActiveWarehouse().getSize() == 0)
|
||||
{
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_ITEM_DEPOSITED_IN_WH));
|
||||
return;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.datatables.HennaTreeTable;
|
||||
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.actor.instance.L2SymbolMakerInstance;
|
||||
import com.l2jserver.gameserver.network.serverpackets.HennaEquipList;
|
||||
|
||||
public class DrawHenna implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Draw"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2SymbolMakerInstance))
|
||||
return false;
|
||||
|
||||
activeChar.sendPacket(new HennaEquipList(activeChar, HennaTreeTable.getInstance().getAvailableHenna(activeChar.getClassId())));
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,351 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.SevenSigns;
|
||||
import com.l2jserver.gameserver.SevenSignsFestival;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
import com.l2jserver.gameserver.model.L2Party;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2FestivalGuideInstance;
|
||||
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.network.serverpackets.SystemMessage;
|
||||
import com.l2jserver.gameserver.templates.StatsSet;
|
||||
import com.l2jserver.util.StringUtil;
|
||||
|
||||
public class Festival implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"festival",
|
||||
"festivaldesc"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2FestivalGuideInstance))
|
||||
return false;
|
||||
|
||||
final L2FestivalGuideInstance npc = (L2FestivalGuideInstance)target;
|
||||
|
||||
try
|
||||
{
|
||||
final int val;
|
||||
if (command.toLowerCase().startsWith(COMMANDS[1]))
|
||||
{
|
||||
val = Integer.parseInt(command.substring(13));
|
||||
npc.showChatWindow(activeChar, val, null, true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
final L2Party party;
|
||||
val = Integer.parseInt(command.substring(9, 10));
|
||||
switch (val)
|
||||
{
|
||||
case 1: // Become a Participant
|
||||
// Check if the festival period is active, if not then don't allow registration.
|
||||
if (SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
npc.showChatWindow(activeChar, 2, "a", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if a festival is in progress, then don't allow registration yet.
|
||||
if (SevenSignsFestival.getInstance().isFestivalInitialized())
|
||||
{
|
||||
activeChar.sendMessage("You cannot sign up while a festival is in progress.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the player is in a formed party already.
|
||||
if (!activeChar.isInParty())
|
||||
{
|
||||
npc.showChatWindow(activeChar, 2, "b", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
party = activeChar.getParty();
|
||||
|
||||
// Check if the player is the party leader.
|
||||
if (!party.isLeader(activeChar))
|
||||
{
|
||||
npc.showChatWindow(activeChar, 2, "c", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check to see if the party has at least 5 members.
|
||||
if (party.getMemberCount() < Config.ALT_FESTIVAL_MIN_PLAYER)
|
||||
{
|
||||
npc.showChatWindow(activeChar, 2, "b", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if all the party members are in the required level range.
|
||||
if (party.getLevel() > SevenSignsFestival.getMaxLevelForFestival(npc.getFestivalType()))
|
||||
{
|
||||
npc.showChatWindow(activeChar, 2, "d", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check to see if the player has already signed up
|
||||
if (activeChar.isFestivalParticipant())
|
||||
{
|
||||
SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), party);
|
||||
npc.showChatWindow(activeChar, 2, "f", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
npc.showChatWindow(activeChar, 1, null, false);
|
||||
break;
|
||||
case 2: // Seal Stones
|
||||
final int stoneType = Integer.parseInt(command.substring(11));
|
||||
final int stoneCount = npc.getStoneCount(stoneType);
|
||||
if (stoneCount <= 0)
|
||||
return false;
|
||||
|
||||
if (!activeChar.destroyItemByItemId("SevenSigns", stoneType, stoneCount, npc, true))
|
||||
return false;
|
||||
|
||||
SevenSignsFestival.getInstance().setParticipants(npc.getFestivalOracle(), npc.getFestivalType(), activeChar.getParty());
|
||||
SevenSignsFestival.getInstance().addAccumulatedBonus(npc.getFestivalType(), stoneType, stoneCount);
|
||||
|
||||
npc.showChatWindow(activeChar, 2, "e", false);
|
||||
break;
|
||||
case 3: // Score Registration
|
||||
// Check if the festival period is active, if not then don't register the score.
|
||||
if (SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
npc.showChatWindow(activeChar, 3, "a", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if a festival is in progress, if it is don't register the score.
|
||||
if (SevenSignsFestival.getInstance().isFestivalInProgress())
|
||||
{
|
||||
activeChar.sendMessage("You cannot register a score while a festival is in progress.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the player is in a party.
|
||||
if (!activeChar.isInParty())
|
||||
{
|
||||
npc.showChatWindow(activeChar, 3, "b", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
final List<Integer> prevParticipants = SevenSignsFestival.getInstance().getPreviousParticipants(npc.getFestivalOracle(), npc.getFestivalType());
|
||||
|
||||
// Check if there are any past participants.
|
||||
if (prevParticipants == null
|
||||
|| prevParticipants.isEmpty()
|
||||
|| !prevParticipants.contains(activeChar.getObjectId()))
|
||||
{
|
||||
npc.showChatWindow(activeChar, 3, "b", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if this player was the party leader in the festival.
|
||||
if (activeChar.getObjectId() != prevParticipants.get(0))
|
||||
{
|
||||
npc.showChatWindow(activeChar, 3, "b", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
final L2ItemInstance bloodOfferings = activeChar.getInventory().getItemByItemId(SevenSignsFestival.FESTIVAL_OFFERING_ID);
|
||||
|
||||
// Check if the player collected any blood offerings during the festival.
|
||||
if (bloodOfferings == null)
|
||||
{
|
||||
activeChar.sendMessage("You do not have any blood offerings to contribute.");
|
||||
return true;
|
||||
}
|
||||
|
||||
final long offeringScore = bloodOfferings.getCount() * SevenSignsFestival.FESTIVAL_OFFERING_VALUE;
|
||||
if (!activeChar.destroyItem("SevenSigns", bloodOfferings, npc, false))
|
||||
return true;
|
||||
|
||||
final boolean isHighestScore = SevenSignsFestival.getInstance().setFinalScore(activeChar, npc.getFestivalOracle(), npc.getFestivalType(), offeringScore);
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CONTRIB_SCORE_INCREASED_S1);
|
||||
sm.addItemNumber(offeringScore);
|
||||
activeChar.sendPacket(sm);
|
||||
|
||||
if (isHighestScore)
|
||||
npc.showChatWindow(activeChar, 3, "c", false);
|
||||
else
|
||||
npc.showChatWindow(activeChar, 3, "d", false);
|
||||
break;
|
||||
case 4: // Current High Scores
|
||||
final StringBuilder strBuffer = StringUtil.startAppend(500,
|
||||
"<html><body>Festival Guide:<br>These are the top scores of the week, for the ");
|
||||
|
||||
final StatsSet dawnData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DAWN, npc.getFestivalType());
|
||||
final StatsSet duskData = SevenSignsFestival.getInstance().getHighestScoreData(SevenSigns.CABAL_DUSK, npc.getFestivalType());
|
||||
final StatsSet overallData = SevenSignsFestival.getInstance().getOverallHighestScoreData(npc.getFestivalType());
|
||||
|
||||
final int dawnScore = dawnData.getInteger("score");
|
||||
final int duskScore = duskData.getInteger("score");
|
||||
int overallScore = 0;
|
||||
|
||||
// If no data is returned, assume there is no record, or all scores are 0.
|
||||
if (overallData != null)
|
||||
overallScore = overallData.getInteger("score");
|
||||
|
||||
StringUtil.append(strBuffer,
|
||||
SevenSignsFestival.getFestivalName(npc.getFestivalType()),
|
||||
" festival.<br>");
|
||||
|
||||
if (dawnScore > 0)
|
||||
{
|
||||
StringUtil.append(strBuffer,
|
||||
"Dawn: ",
|
||||
calculateDate(dawnData.getString("date")),
|
||||
". Score ",
|
||||
String.valueOf(dawnScore),
|
||||
"<br>",
|
||||
dawnData.getString("members"),
|
||||
"<br>"
|
||||
);
|
||||
}
|
||||
else
|
||||
strBuffer.append("Dawn: No record exists. Score 0<br>");
|
||||
|
||||
if (duskScore > 0)
|
||||
{
|
||||
StringUtil.append(strBuffer,
|
||||
"Dusk: ",
|
||||
calculateDate(duskData.getString("date")),
|
||||
". Score ",
|
||||
String.valueOf(duskScore),
|
||||
"<br>",
|
||||
duskData.getString("members"),
|
||||
"<br>"
|
||||
);
|
||||
}
|
||||
else
|
||||
strBuffer.append("Dusk: No record exists. Score 0<br>");
|
||||
|
||||
if (overallScore > 0)
|
||||
{
|
||||
final String cabalStr;
|
||||
if (overallData.getString("cabal").equals("dawn"))
|
||||
cabalStr = "Children of Dawn";
|
||||
else
|
||||
cabalStr = "Children of Dusk";
|
||||
|
||||
StringUtil.append(strBuffer,
|
||||
"Consecutive top scores: ",
|
||||
calculateDate(overallData.getString("date")),
|
||||
". Score ",
|
||||
String.valueOf(overallScore),
|
||||
"<br>Affilated side: ",
|
||||
cabalStr,
|
||||
"<br>",
|
||||
overallData.getString("members"),
|
||||
"<br>"
|
||||
);
|
||||
}
|
||||
else
|
||||
strBuffer.append("Consecutive top scores: No record exists. Score 0<br>");
|
||||
|
||||
StringUtil.append(strBuffer,
|
||||
"<a action=\"bypass -h npc_",
|
||||
String.valueOf(npc.getObjectId()),
|
||||
"_Chat 0\">Go back.</a></body></html>"
|
||||
);
|
||||
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
|
||||
html.setHtml(strBuffer.toString());
|
||||
activeChar.sendPacket(html);
|
||||
break;
|
||||
case 8: // Increase the Festival Challenge
|
||||
if (!activeChar.isInParty())
|
||||
return true;
|
||||
|
||||
if (!SevenSignsFestival.getInstance().isFestivalInProgress())
|
||||
return true;
|
||||
|
||||
party = activeChar.getParty();
|
||||
if (!party.isLeader(activeChar))
|
||||
{
|
||||
npc.showChatWindow(activeChar, 8, "a", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SevenSignsFestival.getInstance().increaseChallenge(npc.getFestivalOracle(), npc.getFestivalType()))
|
||||
npc.showChatWindow(activeChar, 8, "b", false);
|
||||
else
|
||||
npc.showChatWindow(activeChar, 8, "c", false);
|
||||
break;
|
||||
case 9: // Leave the Festival
|
||||
if (!activeChar.isInParty())
|
||||
return true;
|
||||
|
||||
party = activeChar.getParty();
|
||||
if (party.isLeader(activeChar))
|
||||
SevenSignsFestival.getInstance().updateParticipants(activeChar, null);
|
||||
else
|
||||
{
|
||||
if (party.getMemberCount() > Config.ALT_FESTIVAL_MIN_PLAYER)
|
||||
party.removePartyMember(activeChar);
|
||||
else
|
||||
activeChar.sendMessage("Only the party leader can leave a festival when a party has minimum number of members.");
|
||||
}
|
||||
break;
|
||||
case 0: // Distribute Accumulated Bonus
|
||||
if (!SevenSigns.getInstance().isSealValidationPeriod())
|
||||
{
|
||||
activeChar.sendMessage("Bonuses cannot be paid during the competition period.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SevenSignsFestival.getInstance().distribAccumulatedBonus(activeChar) > 0)
|
||||
npc.showChatWindow(activeChar, 0, "a", false);
|
||||
else
|
||||
npc.showChatWindow(activeChar, 0, "b", false);
|
||||
break;
|
||||
default:
|
||||
npc.showChatWindow(activeChar, val, null, false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private final String calculateDate(String milliFromEpoch)
|
||||
{
|
||||
long numMillis = Long.valueOf(milliFromEpoch);
|
||||
Calendar calCalc = Calendar.getInstance();
|
||||
calCalc.setTimeInMillis(numMillis);
|
||||
return calCalc.get(Calendar.YEAR) + "/" + calCalc.get(Calendar.MONTH) + "/" + calCalc.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.instancemanager.TerritoryWarManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2FortSiegeNpcInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class FortSiege implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"fort_register",
|
||||
"fort_unregister"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2FortSiegeNpcInstance))
|
||||
return false;
|
||||
|
||||
if (activeChar.getClanId() > 0
|
||||
&& (activeChar.getClanPrivileges() & L2Clan.CP_CS_MANAGE_SIEGE) == L2Clan.CP_CS_MANAGE_SIEGE)
|
||||
{
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // register
|
||||
{
|
||||
if (System.currentTimeMillis() < TerritoryWarManager.getInstance().getTWStartTimeInMillis()
|
||||
&& TerritoryWarManager.getInstance().getIsRegistrationOver())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_SIEGE_REGISTRATION_TIME2));
|
||||
return false;
|
||||
}
|
||||
else if (System.currentTimeMillis() > TerritoryWarManager.getInstance().getTWStartTimeInMillis()
|
||||
&& TerritoryWarManager.getInstance().isTWChannelOpen())
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_SIEGE_REGISTRATION_TIME2));
|
||||
return false;
|
||||
}
|
||||
else if (((L2Npc)target).getFort().getSiege().registerAttacker(activeChar, false))
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.REGISTERED_TO_S1_FORTRESS_BATTLE);
|
||||
sm.addString(((L2Npc)target).getFort().getName());
|
||||
activeChar.sendPacket(sm);
|
||||
((L2Npc)target).showChatWindow(activeChar, 7);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // unregister
|
||||
{
|
||||
((L2Npc)target).getFort().getSiege().removeSiegeClan(activeChar.getClan());
|
||||
((L2Npc)target).showChatWindow(activeChar, 8);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
((L2Npc)target).showChatWindow(activeChar, 10);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.bypasshandlers;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.ItemAuctionManager;
|
||||
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.itemauction.ItemAuction;
|
||||
import com.l2jserver.gameserver.model.itemauction.ItemAuctionInstance;
|
||||
import com.l2jserver.gameserver.network.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExItemAuctionInfoPacket;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class ItemAuctionLink implements IBypassHandler
|
||||
{
|
||||
private static final SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
|
||||
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"ItemAuction"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
if (!Config.ALT_ITEM_AUCTION_ENABLED)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_AUCTION_PERIOD));
|
||||
return true;
|
||||
}
|
||||
|
||||
final ItemAuctionInstance au = ItemAuctionManager.getInstance().getManagerInstance(((L2Npc)target).getNpcId());
|
||||
if (au == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
st.nextToken(); // bypass "ItemAuction"
|
||||
if (!st.hasMoreTokens())
|
||||
return false;
|
||||
|
||||
String cmd = st.nextToken();
|
||||
if ("show".equalsIgnoreCase(cmd))
|
||||
{
|
||||
if (!activeChar.getFloodProtectors().getItemAuction().tryPerformAction("RequestInfoItemAuction"))
|
||||
return false;
|
||||
|
||||
if (activeChar.isItemAuctionPolling())
|
||||
return false;
|
||||
|
||||
final ItemAuction currentAuction = au.getCurrentAuction();
|
||||
final ItemAuction nextAuction = au.getNextAuction();
|
||||
|
||||
if (currentAuction == null)
|
||||
{
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_AUCTION_PERIOD));
|
||||
|
||||
if (nextAuction != null) // used only once when database is empty
|
||||
activeChar.sendMessage("The next auction will begin on the " + fmt.format(new Date(nextAuction.getStartingTime())) + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
activeChar.sendPacket(new ExItemAuctionInfoPacket(false, currentAuction, nextAuction));
|
||||
}
|
||||
else if ("cancel".equalsIgnoreCase(cmd))
|
||||
{
|
||||
final ItemAuction[] auctions = au.getAuctionsByBidder(activeChar.getObjectId());
|
||||
boolean returned = false;
|
||||
for (final ItemAuction auction : auctions)
|
||||
{
|
||||
if (auction.cancelBid(activeChar))
|
||||
returned = true;
|
||||
}
|
||||
if (!returned)
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_OFFERINGS_OWN_OR_MADE_BID_FOR));
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.severe("Exception in: " + getClass().getSimpleName() + ":" + e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.network.serverpackets.NpcHtmlMessage;
|
||||
|
||||
public class Link implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Link"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
String path = command.substring(5).trim();
|
||||
if (path.indexOf("..") != -1)
|
||||
return false;
|
||||
String filename = "data/html/" + path;
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(((L2Npc)target).getObjectId());
|
||||
html.setFile(activeChar.getHtmlPrefix(), filename);
|
||||
html.replace("%objectId%", String.valueOf(((L2Npc)target).getObjectId()));
|
||||
activeChar.sendPacket(html);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package handlers.bypasshandlers;
|
||||
|
||||
import java.text.DateFormat;
|
||||
|
||||
import com.l2jserver.Config;
|
||||
import com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.idfactory.IdFactory;
|
||||
import com.l2jserver.gameserver.instancemanager.games.Lottery;
|
||||
import com.l2jserver.gameserver.model.L2ItemInstance;
|
||||
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.SystemMessageId;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class Loto implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"Loto"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
int val = 0;
|
||||
try
|
||||
{
|
||||
val = Integer.parseInt(command.substring(5));
|
||||
}
|
||||
catch (IndexOutOfBoundsException ioobe)
|
||||
{
|
||||
}
|
||||
catch (NumberFormatException nfe)
|
||||
{
|
||||
}
|
||||
if (val == 0)
|
||||
{
|
||||
// new loto ticket
|
||||
for (int i = 0; i < 5; i++)
|
||||
activeChar.setLoto(i, 0);
|
||||
}
|
||||
showLotoWindow(activeChar, (L2Npc)target, val);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a Loto window on client with the text of the L2NpcInstance.<BR><BR>
|
||||
*
|
||||
* <B><U> Actions</U> :</B><BR><BR>
|
||||
* <li>Get the text of the selected HTML file in function of the npcId and of the page number </li>
|
||||
* <li>Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance </li>
|
||||
* <li>Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet </li><BR>
|
||||
*
|
||||
* @param player The L2PcInstance that talk with the L2NpcInstance
|
||||
* @param npc L2Npc loto instance
|
||||
* @param val The number of the page of the L2NpcInstance to display
|
||||
*
|
||||
*/
|
||||
// 0 - first buy lottery ticket window
|
||||
// 1-20 - buttons
|
||||
// 21 - second buy lottery ticket window
|
||||
// 22 - selected ticket with 5 numbers
|
||||
// 23 - current lottery jackpot
|
||||
// 24 - Previous winning numbers/Prize claim
|
||||
// >24 - check lottery ticket by item object id
|
||||
public static final void showLotoWindow(L2PcInstance player, L2Npc npc, int val)
|
||||
{
|
||||
int npcId = npc.getTemplate().npcId;
|
||||
String filename;
|
||||
SystemMessage sm;
|
||||
NpcHtmlMessage html = new NpcHtmlMessage(npc.getObjectId());
|
||||
|
||||
if (val == 0) // 0 - first buy lottery ticket window
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 1));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val >= 1 && val <= 21) // 1-20 - buttons, 21 - second buy lottery ticket window
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
//tickets can't be sold
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
//tickets can't be sold
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
|
||||
return;
|
||||
}
|
||||
|
||||
filename = (npc.getHtmlPath(npcId, 5));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
int count = 0;
|
||||
int found = 0;
|
||||
// counting buttons and unsetting button if found
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == val)
|
||||
{
|
||||
//unsetting button
|
||||
player.setLoto(i, 0);
|
||||
found = 1;
|
||||
}
|
||||
else if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
//if not rearched limit 5 and not unseted value
|
||||
if (count < 5 && found == 0 && val <= 20)
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (player.getLoto(i) == 0)
|
||||
{
|
||||
player.setLoto(i, val);
|
||||
break;
|
||||
}
|
||||
|
||||
//setting pusshed buttons
|
||||
count = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
if (player.getLoto(i) > 0)
|
||||
{
|
||||
count++;
|
||||
String button = String.valueOf(player.getLoto(i));
|
||||
if (player.getLoto(i) < 10)
|
||||
button = "0" + button;
|
||||
String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
|
||||
String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
|
||||
if (count == 5)
|
||||
{
|
||||
String search = "0\">Return";
|
||||
String replace = "22\">Your lucky numbers have been selected above.";
|
||||
html.replace(search, replace);
|
||||
}
|
||||
}
|
||||
else if (val == 22) //22 - selected ticket with 5 numbers
|
||||
{
|
||||
if (!Lottery.getInstance().isStarted())
|
||||
{
|
||||
//tickets can't be sold
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
|
||||
return;
|
||||
}
|
||||
if (!Lottery.getInstance().isSellableTickets())
|
||||
{
|
||||
//tickets can't be sold
|
||||
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
|
||||
return;
|
||||
}
|
||||
|
||||
long price = Config.ALT_LOTTERY_TICKET_PRICE;
|
||||
int lotonumber = Lottery.getInstance().getId();
|
||||
int enchant = 0;
|
||||
int type2 = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (player.getLoto(i) == 0)
|
||||
return;
|
||||
|
||||
if (player.getLoto(i) < 17)
|
||||
enchant += Math.pow(2, player.getLoto(i) - 1);
|
||||
else
|
||||
type2 += Math.pow(2, player.getLoto(i) - 17);
|
||||
}
|
||||
if (player.getAdena() < price)
|
||||
{
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
|
||||
player.sendPacket(sm);
|
||||
return;
|
||||
}
|
||||
if (!player.reduceAdena("Loto", price, npc, true))
|
||||
return;
|
||||
Lottery.getInstance().increasePrize(price);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.ACQUIRED_S1_S2);
|
||||
sm.addNumber(lotonumber);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
|
||||
item.setCount(1);
|
||||
item.setCustomType1(lotonumber);
|
||||
item.setEnchantLevel(enchant);
|
||||
item.setCustomType2(type2);
|
||||
player.getInventory().addItem("Loto", item, player, npc);
|
||||
|
||||
InventoryUpdate iu = new InventoryUpdate();
|
||||
iu.addItem(item);
|
||||
L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
|
||||
iu.addModifiedItem(adenaupdate);
|
||||
player.sendPacket(iu);
|
||||
|
||||
filename = (npc.getHtmlPath(npcId, 6));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 23) //23 - current lottery jackpot
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 3));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val == 24) // 24 - Previous winning numbers/Prize claim
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 4));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
|
||||
int lotonumber = Lottery.getInstance().getId();
|
||||
String message = "";
|
||||
for (L2ItemInstance item : player.getInventory().getItems())
|
||||
{
|
||||
if (item == null)
|
||||
continue;
|
||||
if (item.getItemId() == 4442 && item.getCustomType1() < lotonumber)
|
||||
{
|
||||
message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
|
||||
int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(), item.getCustomType2());
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
message += numbers[i] + " ";
|
||||
}
|
||||
long[] check = Lottery.getInstance().checkTicket(item);
|
||||
if (check[0] > 0)
|
||||
{
|
||||
switch ((int)check[0])
|
||||
{
|
||||
case 1:
|
||||
message += "- 1st Prize";
|
||||
break;
|
||||
case 2:
|
||||
message += "- 2nd Prize";
|
||||
break;
|
||||
case 3:
|
||||
message += "- 3th Prize";
|
||||
break;
|
||||
case 4:
|
||||
message += "- 4th Prize";
|
||||
break;
|
||||
}
|
||||
message += " " + check[1] + "a.";
|
||||
}
|
||||
message += "</a><br>";
|
||||
}
|
||||
}
|
||||
if (message.isEmpty())
|
||||
{
|
||||
message += "There has been no winning lottery ticket.<br>";
|
||||
}
|
||||
html.replace("%result%", message);
|
||||
}
|
||||
else if (val == 25) //25 - lottery instructions
|
||||
{
|
||||
filename = (npc.getHtmlPath(npcId, 2));
|
||||
html.setFile(player.getHtmlPrefix(), filename);
|
||||
}
|
||||
else if (val > 25) // >25 - check lottery ticket by item object id
|
||||
{
|
||||
int lotonumber = Lottery.getInstance().getId();
|
||||
L2ItemInstance item = player.getInventory().getItemByObjectId(val);
|
||||
if (item == null || item.getItemId() != 4442 || item.getCustomType1() >= lotonumber)
|
||||
return;
|
||||
long[] check = Lottery.getInstance().checkTicket(item);
|
||||
|
||||
sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
|
||||
sm.addItemName(4442);
|
||||
player.sendPacket(sm);
|
||||
|
||||
long adena = check[1];
|
||||
if (adena > 0)
|
||||
player.addAdena("Loto", adena, npc, true);
|
||||
player.destroyItem("Loto", item, npc, false);
|
||||
return;
|
||||
}
|
||||
html.replace("%objectId%", String.valueOf(npc.getObjectId()));
|
||||
html.replace("%race%", "" + Lottery.getInstance().getId());
|
||||
html.replace("%adena%", "" + Lottery.getInstance().getPrize());
|
||||
html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
|
||||
html.replace("%prize5%", "" + (Config.ALT_LOTTERY_5_NUMBER_RATE * 100));
|
||||
html.replace("%prize4%", "" + (Config.ALT_LOTTERY_4_NUMBER_RATE * 100));
|
||||
html.replace("%prize3%", "" + (Config.ALT_LOTTERY_3_NUMBER_RATE * 100));
|
||||
html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
|
||||
html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
|
||||
player.sendPacket(html);
|
||||
|
||||
// Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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 com.l2jserver.gameserver.handler.IBypassHandler;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManager;
|
||||
import com.l2jserver.gameserver.instancemanager.CastleManorManager;
|
||||
import com.l2jserver.gameserver.model.L2Clan;
|
||||
import com.l2jserver.gameserver.model.actor.L2Character;
|
||||
import com.l2jserver.gameserver.model.actor.L2Npc;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2CastleChamberlainInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2ManorManagerInstance;
|
||||
import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
|
||||
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.ActionFailed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.BuyListSeed;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowCropInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowCropSetting;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowManorDefaultInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowProcureCropDetail;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowSeedInfo;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowSeedSetting;
|
||||
import com.l2jserver.gameserver.network.serverpackets.ExShowSellCropList;
|
||||
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class ManorManager implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"manor_menu_select"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
final L2Npc manager = activeChar.getLastFolkNPC();
|
||||
final boolean isCastle = manager instanceof L2CastleChamberlainInstance;
|
||||
if (!(manager instanceof L2ManorManagerInstance || isCastle))
|
||||
return false;
|
||||
|
||||
if (!activeChar.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, true, false))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
final Castle castle = manager.getCastle();
|
||||
if (isCastle)
|
||||
{
|
||||
if (activeChar.getClan() == null
|
||||
|| castle.getOwnerId() != activeChar.getClanId()
|
||||
|| (activeChar.getClanPrivileges() & L2Clan.CP_CS_MANOR_ADMIN) != L2Clan.CP_CS_MANOR_ADMIN)
|
||||
{
|
||||
manager.showChatWindow(activeChar, "data/html/chamberlain/chamberlain-noprivs.htm");
|
||||
return false;
|
||||
}
|
||||
if (castle.getSiege().getIsInProgress())
|
||||
{
|
||||
manager.showChatWindow(activeChar, "data/html/chamberlain/chamberlain-busy.htm");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (CastleManorManager.getInstance().isUnderMaintenance())
|
||||
{
|
||||
activeChar.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE));
|
||||
return true;
|
||||
}
|
||||
|
||||
final StringTokenizer st = new StringTokenizer(command, "&");
|
||||
final int ask = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int state = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
final int time = Integer.parseInt(st.nextToken().split("=")[1]);
|
||||
|
||||
final int castleId;
|
||||
if (state < 0)
|
||||
castleId = castle.getCastleId(); // info for current manor
|
||||
else
|
||||
castleId = state; // info for requested manor
|
||||
|
||||
switch (ask)
|
||||
{
|
||||
case 1: // Seed purchase
|
||||
if (isCastle)
|
||||
break;
|
||||
if (castleId != castle.getCastleId())
|
||||
{
|
||||
SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR);
|
||||
sm.addString(manager.getCastle().getName());
|
||||
activeChar.sendPacket(sm);
|
||||
}
|
||||
else
|
||||
activeChar.sendPacket(new BuyListSeed(activeChar.getAdena(), castleId, castle.getSeedProduction(CastleManorManager.PERIOD_CURRENT)));
|
||||
break;
|
||||
case 2: // Crop sales
|
||||
if (isCastle)
|
||||
break;
|
||||
activeChar.sendPacket(new ExShowSellCropList(activeChar, castleId, castle.getCropProcure(CastleManorManager.PERIOD_CURRENT)));
|
||||
break;
|
||||
case 3: // Current seeds (Manor info)
|
||||
if (time == 1 && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
|
||||
activeChar.sendPacket(new ExShowSeedInfo(castleId, null));
|
||||
else
|
||||
activeChar.sendPacket(new ExShowSeedInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getSeedProduction(time)));
|
||||
break;
|
||||
case 4: // Current crops (Manor info)
|
||||
if (time == 1 && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
|
||||
activeChar.sendPacket(new ExShowCropInfo(castleId, null));
|
||||
else
|
||||
activeChar.sendPacket(new ExShowCropInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getCropProcure(time)));
|
||||
break;
|
||||
case 5: // Basic info (Manor info)
|
||||
activeChar.sendPacket(new ExShowManorDefaultInfo());
|
||||
break;
|
||||
case 6: // Buy harvester
|
||||
if (isCastle)
|
||||
break;
|
||||
((L2MerchantInstance)manager).showBuyWindow(activeChar, 300000 + manager.getNpcId());
|
||||
break;
|
||||
case 7: // Edit seed setup
|
||||
if (!isCastle)
|
||||
break;
|
||||
if (castle.isNextPeriodApproved())
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
|
||||
else
|
||||
activeChar.sendPacket(new ExShowSeedSetting(castle.getCastleId()));
|
||||
break;
|
||||
case 8: // Edit crop setup
|
||||
if (!isCastle)
|
||||
break;
|
||||
if (castle.isNextPeriodApproved())
|
||||
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
|
||||
else
|
||||
activeChar.sendPacket(new ExShowCropSetting(castle.getCastleId()));
|
||||
break;
|
||||
case 9: // Edit sales (Crop sales)
|
||||
if (isCastle)
|
||||
break;
|
||||
activeChar.sendPacket(new ExShowProcureCropDetail(state));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.info(e.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getBypassList()
|
||||
{
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This program is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should 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.datatables.MultiSell;
|
||||
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;
|
||||
|
||||
public class Multisell implements IBypassHandler
|
||||
{
|
||||
private static final String[] COMMANDS =
|
||||
{
|
||||
"multisell",
|
||||
"exc_multisell"
|
||||
};
|
||||
|
||||
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
|
||||
{
|
||||
if (!(target instanceof L2Npc))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
int listId;
|
||||
if (command.toLowerCase().startsWith(COMMANDS[0])) // multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(9).trim());
|
||||
MultiSell.getInstance().separateAndSend(listId, activeChar, (L2Npc)target, false);
|
||||
return true;
|
||||
}
|
||||
else if (command.toLowerCase().startsWith(COMMANDS[1])) // exc_multisell
|
||||
{
|
||||
listId = Integer.parseInt(command.substring(13).trim());
|
||||
MultiSell.getInstance().separateAndSend(listId, activeChar, (L2Npc)target, true);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.info("Exception in " + getClass().getSimpleName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
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