protected override bool Process(Player player, RealmTime time, string args)
        {
            int index = args.IndexOf(' ');
            int num;
            string name = args;

            if (args.IndexOf(' ') > 0 && int.TryParse(args.Substring(0, args.IndexOf(' ')), out num)) //multi
                name = args.Substring(index + 1);
            else
                num = 1;

            ushort objType;
            if (!player.Manager.GameData.IdToObjectType.TryGetValue(name, out objType) ||
                !player.Manager.GameData.ObjectDescs.ContainsKey(objType))
            {
                player.SendError("Unknown entity!");
                return false;
            }

            for (int i = 0; i < num; i++)
            {
                var entity = Entity.Resolve(player.Manager, objType);
                entity.Move(player.X, player.Y);
                player.Owner.EnterWorld(entity);
            }
            return true;
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.Guild != "")
         try
         {
             var saytext = string.Join(" ", args);
             if ((from w in player.Manager.Worlds let world = w.Value where w.Key != 0 from i in world.Players.Where(i => i.Value.Guild == player.Guild) select world).Any())
             {
                 if (saytext.Equals(" ") || saytext == "")
                 {
                     player.SendHelp("Usage: /guild <text>");
                     return false;
                 }
                 player.Manager.Chat.SayGuild(player, saytext.ToSafeText());
                 return true;
             }
         }
         catch(Exception e)
         {
             player.SendError(e.ToString());
             player.SendInfo("Cannot guild chat!");
             return false;
         }
     else
         player.SendInfo("You need to be in a guild to use guild chat!");
     return false;
 }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     ConditionEffectIndex effect;
     if (!Enum.TryParse(args, true, out effect))
     {
         player.SendError("Invalid effect!");
         return false;
     }
     if ((player.ConditionEffects & (ConditionEffects)(1 << (int)effect)) != 0)
     {
         //remove
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = effect,
             DurationMS = 0
         });
     }
     else
     {
         //add
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = effect,
             DurationMS = -1
         });
     }
     return true;
 }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.HasConditionEffect(ConditionEffects.Paused))
     {
         player.ApplyConditionEffect(new ConditionEffect()
         {
             Effect = ConditionEffectIndex.Paused,
             DurationMS = 0
         });
         player.SendInfo("Game resumed.");
         return true;
     }
     else
     {
         if (player.Owner.EnemiesCollision.HitTest(player.X, player.Y, 8).OfType<Enemy>().Any())
         {
             player.SendError("Not safe to pause.");
             return false;
         }
         else
         {
             player.ApplyConditionEffect(new ConditionEffect()
             {
                 Effect = ConditionEffectIndex.Paused,
                 DurationMS = -1
             });
             player.SendInfo("Game paused.");
             return true;
         }
     }
 }
Beispiel #5
0
        public bool Execute(Player player, RealmTime time, string args)
        {
            if (!HasPermission(player))
            {
                player.SendError("No permission!");
                return false;
            }

            try
            {
                return Process(player, time, args);
            }
            catch (Exception ex)
            {
                log.Error("Error when executing the command.", ex);
                player.SendError("Error when executing the command.");
                return false;
            }
        }
Beispiel #6
0
        public Pet(RealmManager manager, PetItem petData, Player playerOwner)
            : base(manager, (ushort)petData.Type, true, true)
        {
            rand        = new Random();
            PlayerOwner = playerOwner;
            Info        = petData;

            try
            {
                if (petData.InstanceId != -1)
                {
                    FirstPetLevel = new PetLevel(AbilityType.First,
                                                 Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[0].Type)),
                                                 petData.Abilities[0].Points, petData.Abilities[0].Power, this);

                    SecondPetLevel = new PetLevel(AbilityType.Second,
                                                  Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[1].Type)),
                                                  petData.Abilities[1].Points, petData.Abilities[1].Power, this);

                    ThirdPetLevel = new PetLevel(AbilityType.Third,
                                                 Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[2].Type)),
                                                 petData.Abilities[2].Points, petData.Abilities[2].Power, this);
                    if (playerOwner != null)
                    {
                        using (Database db = new Database())
                            Size = db.GetPetSize(Convert.ToInt32(PlayerOwner.AccountId), petData.InstanceId);
                    }
                    else
                    {
                        Size = 0;
                    }

                    if (Size == 0)
                    {
                        Size = manager.GameData.TypeToPet[(ushort)petData.Type].Size;
                    }

                    PetRarity    = (Rarity)petData.Rarity;
                    PetFamily    = manager.GameData.TypeToPet[(ushort)petData.Type].PetFamily;
                    MaximumLevel = petData.MaxAbilityPower;
                    UpdateNeeded = true;
                }
                Skin   = petData.SkinName;
                SkinId = petData.Skin;
                PetId  = petData.InstanceId;
                IsPet  = true;
            }
            catch (Exception e)
            {
                PlayerOwner?.SendError(
                    $"An error ocurred while loading your pet data, please report this to an Admin: {e.Message}");
            }
        }
Beispiel #7
0
        private static void Handle(Player player)
        {
            var cli = player.Client;

            if (cli.Account.RaidToken < 1)
            {
                player.SendError("You do not have an Alert to launch.");
                return;
            }

            if (cli.Account.Credits < 1000)
            {
                player.SendError("You do not have the required amount of gold to launch an Alert.");
                return;
            }

            var rnd = new Random();

            cli.Manager.Database.UpdateAlertToken(cli.Account, -1);
            player.AlertToken--;
            player.ForceUpdate(player.AlertToken);

            player.SendHelp("Launching Alert... Good luck!");
            var alertArea = player.Owner.Manager.Resources.Worlds[AlertAreas[rnd.Next(AlertAreas.Length)]];

            DynamicWorld.TryGetWorld(alertArea, player.Client, out var world);
            world = player.Owner.Manager.AddWorld(world ?? new World(alertArea));

            player.Owner.Timers.Add(new WorldTimer(8000, (w, t) => {
                player.Client.Reconnect(new Reconnect {
                    Host        = "",
                    Port        = 2050,
                    GameId      = world.Id,
                    Name        = world.SBName,
                    IsFromArena = false
                });
            }));
        }
        public Pet(RealmManager manager, PetItem petData, Player playerOwner)
            : base(manager, (ushort)petData.Type, true, true)
        {
            rand        = new Random();
            PlayerOwner = playerOwner;
            Info        = petData;

            try
            {
                if (petData.InstanceId != -1)
                {
                    FirstPetLevel = new PetLevel(AbilityType.First,
                                                 Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[0].Type)),
                                                 petData.Abilities[0].Points, petData.Abilities[0].Power, this);

                    SecondPetLevel = new PetLevel(AbilityType.Second,
                                                  Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[1].Type)),
                                                  petData.Abilities[1].Points, petData.Abilities[1].Power, this);

                    ThirdPetLevel = new PetLevel(AbilityType.Third,
                                                 Utils.GetEnumByName <Ability>(Utils.GetEnumName <Ability>(petData.Abilities[2].Type)),
                                                 petData.Abilities[2].Points, petData.Abilities[2].Power, this);

                    Size         = manager.GameData.TypeToPet[(ushort)petData.Type].Size;
                    PetRarity    = (Rarity)petData.Rarity;
                    PetFamily    = manager.GameData.TypeToPet[(ushort)petData.Type].PetFamily;
                    MaximumLevel = petData.MaxAbilityPower;
                    UpdateNeeded = true;
                }
                Skin   = petData.SkinName;
                SkinId = petData.Skin;
                PetId  = petData.InstanceId;
                IsPet  = true;

                if (PetRarity == Rarity.Divine) //Change size if wanted.
                {
                    Size = 70;
                }
            }
            catch (Exception e)
            {
                if (PlayerOwner != null)
                {
                    PlayerOwner.SendError(
                        String.Format(
                            "An error ocurred while loading your pet data, please report this to an Admin: {0}",
                            e.Message));
                }
            }
        }
Beispiel #9
0
        public static Pet Create(RealmManager manager, Player player, Item egg)
        {
            // there are no explicit uncommon/legendary pets so this is need
            var rarity = egg.Rarity;

            switch (rarity)
            {
            case PRarity.Uncommon:
                rarity = PRarity.Common;
                break;

            case PRarity.Legendary:
                rarity = PRarity.Rare;
                break;
            }

            var petDesc = GetRandomPetDesc(manager, rarity, egg.Family);

            if (petDesc == null)
            {
                player.SendErrorFormat("Bad egg. Family: {0} and Rarity: {1} combination does not exist.",
                                       egg.Family.ToString(), egg.Rarity.ToString());
                return(null);
            }

            var acc = player.Client.Account;

            if (acc.PetList.Length >= player.Manager.Resources.Settings.MaxPetCount)
            {
                player.SendError("Pet cap has been reached. Please release a pet before adding new ones.");
                return(null);
            }

            var dbPet = manager.Database.NewPet(acc);

            dbPet.ObjectType = petDesc.ObjectType;
            var pet = new Pet(manager, player, dbPet);

            pet.Rarity   = egg.Rarity;
            pet.MaxLevel = GetRarityMaxLevel(egg.Rarity);
            InitializeAbilities(manager, pet, petDesc);
            pet.Feed(GetNeededPower(GetRarityMaxLevel(egg.Rarity - 1) - 1));
            pet.Save();

            return(pet);
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     ushort objType;
     if (!player.Manager.GameData.IdToObjectType.TryGetValue(args, out objType))
     {
         player.SendError("Unknown item type!");
         return false;
     }
     for (int i = 0; i < player.Inventory.Length; i++)
         if (player.Inventory[i] == null)
         {
             player.Inventory[i] = player.Manager.GameData.Items[objType];
             player.UpdateCount++;
             return true;
         }
     player.SendError("Not enough space in inventory!");
     return false;
 }
        protected override bool Process(Player player, RealmTime time, string args)
        {
            string saytext = string.Join(" ", args);
            int index = args.IndexOf(' ');
            if (player.Client.Account.Muted) return false;
            if (!player.NameChosen)
            {
                player.SendError("Choose a name!");
                return false;
            }
            if (saytext.Equals(" ") || saytext == "")
            {
                player.SendError("Usage: /tell <player name> <text>");
                return false;
            }
            string playername = args.Substring(0, index);
            string msg = args.Substring(index + 1);

            if (msg.Trim() == "")
                return false;

            if (String.Equals(player.Name.ToLower(), playername.ToLower()))
            {
                player.SendInfo("Quit telling yourself!");
                return false;
            }

            foreach (var i in player.Manager.Clients.Values)
            {
                if (i.Account.NameChosen && i.Account.Name.EqualsIgnoreCase(playername))
                {
                    if (i.Player == null || i.Player.Owner == null)
                        continue;

                    player.Client.SendPacket(new TextPacket //echo to self
                    {
                        ObjectId = player.Id,
                        BubbleTime = 10,
                        Stars = player.Stars,
                        Name = player.Name,
                        Recipient = i.Account.Name,
                        Text = msg.ToSafeText(),
                        CleanText = ""
                    });

                    i.SendPacket(new TextPacket //echo to /tell player
                    {
                        ObjectId = player.Owner.Id == i.Player.Owner.Id ? player.Id : 0,
                        BubbleTime = (byte)(player.Owner.Id == i.Player.Owner.Id ? 10 : 0),
                        Stars = player.Stars,
                        Name = player.Name,
                        Recipient = i.Account.Name,
                        Text = msg.ToSafeText(),
                        CleanText = ""
                    });
                    return true;
                }
            }
            player.SendError(string.Format("{0} not found.", playername));
            return false;
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     foreach (var i in player.Manager.Clients.Values)
     {
         if (i.Account.Name.EqualsIgnoreCase(args))
         {
             i.Disconnect();
             player.SendInfo("Player disconnected!");
             return true;
         }
     }
     player.SendError(string.Format("Player '{0}' could not be found!", args));
     return false;
 }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.GuildRank < 20) return false;
     foreach (var e in from i in player.Manager.Worlds where i.Key != 0 from e in i.Value.Players select e)
         if (String.Equals(e.Value.Client.Account.Name, args, StringComparison.CurrentCultureIgnoreCase))
             if (e.Value.Client.Account.Guild.Name == "")
             {
                 player.SendInfo(e.Value.Client.Account.Name + " has been invited to your guild!");
                 e.Value.Client.SendPacket(new InvitedToGuildPacket
                 {
                     Name = player.Client.Account.Name,
                     Guild = player.Client.Account.Guild.Name
                 });
                 return true;
             }
             else
             {
                 player.SendError(e.Value.Client.Account.Name + " is already in a guild!");
                 return false;
             }
         else
             player.SendInfo("Members and initiates cannot invite!");
     return false;
 }
        void Handle(Player player, RealmTime time, UnboxRequest packet)
        {
            var acc = player.Client.Account;

            switch (packet.lootboxType)
            {
            case 1:
                if (player.BronzeLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateBronzeLootbox(acc, -1);
                    player.BronzeLootbox -= 1;
                    player.ForceUpdate(player.BronzeLootbox);
                    player.Unbox(1);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 2:
                if (player.SilverLoootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateSilverLootbox(acc, -1);
                    player.SilverLoootbox -= 1;
                    player.ForceUpdate(player.SilverLoootbox);
                    player.Unbox(2);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 3:
                if (player.GoldLootbox >= 1)
                {
                    player.Client.Manager.Database.UpdateGoldLootbox(acc, -1);
                    player.GoldLootbox -= 1;
                    player.ForceUpdate(player.GoldLootbox);
                    player.Unbox(3);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open!");
                }
                break;

            case 4:
                if (player.EliteLootbox >= 1 && player.Onrane >= 5)
                {
                    player.Client.Manager.Database.UpdateEliteLootbox(acc, -1);
                    player.Client.Manager.Database.UpdateOnrane(acc, -5);
                    player.EliteLootbox -= 1;
                    player.Onrane        = player.Client.Account.Onrane - 5;
                    player.ForceUpdate(player.Onrane);
                    player.ForceUpdate(player.EliteLootbox);
                    player.Unbox(4);
                }
                else
                {
                    player.SendError("You do not have any lootboxes to open or you don't have the sufficient amount of onrane!");
                }
                break;

            case 5:
                if (player.Kantos >= 600)
                {
                    player.Client.Manager.Database.UpdateKantos(acc, -600);
                    player.Kantos = player.Client.Account.Kantos - 600;
                    player.ForceUpdate(player.Kantos);
                    player.Unbox(5);
                }
                else
                {
                    player.SendError("You do not have the sufficient amount of Kantos to open this box.");
                }
                break;
            }
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (args.Length == 0)
     {
         player.SendHelp("Usage: /gimme <Itemname>");
         return false;
     }
     ushort objType;
     if (!player.Manager.GameData.IdToObjectType.TryGetValue(args, out objType))
     {
         player.SendError("Unknown item type!");
         return false;
     }
     for (int i = 0; i < player.Inventory.Length; i++)
         if (player.Inventory[i] == null)
         {
             player.Inventory[i] = player.Manager.GameData.Items[objType];
             player.UpdateCount++;
             player.SaveToCharacter();
             player.SendInfo("Success!");
             return true;
         }
     player.SendError("Not enough space in inventory!");
     return false;
 }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (args.Length == 0)
     {
         player.SendHelp("Usage: /summon <playername>");
         return false;
     }
     foreach (var i in player.Owner.Players)
     {
         if (i.Value.Name.EqualsIgnoreCase(args))
         {
             i.Value.Teleport(time, player.Id);
             player.SendInfo("Player summoned!");
             return true;
         }
     }
     player.SendError(string.Format("Player '{0}' could not be found!", args));
     return false;
 }
Beispiel #17
0
        protected override bool Process(Player player, RealmTime time, string args)
        {
            if (!player.NameChosen)
            {
                player.SendError("Choose a name!");
                return false;
            }
            int index = args.IndexOf(' ');
            if (index == -1)
            {
                player.SendError("Usage: /tell <player name> <text>");
                return false;
            }

            string playername = args.Substring(0, index);
            string msg = args.Substring(index + 1);

            if (player.Name.ToLower() == playername.ToLower())
            {
                player.SendInfo("Quit telling yourself!");
                return false;
            }

            foreach (var i in player.Manager.Clients.Values)
            {
                if (i.Account.NameChosen && i.Account.Name.EqualsIgnoreCase(playername))
                {
                    player.Client.SendPacket(new TextPacket() //echo to self
                    {
                        BubbleTime = 10,
                        Stars = player.Stars,
                        Name = player.Name,
                        Recipient = i.Account.Name,
                        Text = msg
                    });

                    i.SendPacket(new TextPacket() //echo to /tell player
                    {
                        BubbleTime = 10,
                        Stars = player.Stars,
                        Name = player.Name,
                        Recipient = i.Account.Name,
                        Text = msg
                    });
                    return true;
                }
            }
            player.SendError(string.Format("{0} not found.", playername));
            return false;
        }
        protected override bool Process(Player player, RealmTime time, string args)
        {
            var index = args.IndexOf(' ');
              int num;
              var name = args;
              string extras = "";

              if (name.Split('%').Length > 1)
              {
            extras = name.Split('%')[1].Trim();
            name = name.Split('%')[0].Trim();
              }

              if (args.IndexOf(' ') > 0 && int.TryParse(args.Substring(0, args.IndexOf(' ')), out num)) //multi
            name = args.Substring(index + 1);
              else
            num = 1;

              ushort objType;
              if (!player.Manager.GameData.IdToObjectType.TryGetValue(name, out objType) ||
              !player.Manager.GameData.ObjectDescs.ContainsKey(objType))
              {
            player.SendError("Unknown entity!");
            return false;
              }

              for (var i = 0; i < num; i++)
              {
            var entity = Entity.Resolve(player.Manager, objType);
            entity.Move(player.X, player.Y);
            foreach (string item in extras.Split(';'))
            {
              string[] kv = item.Split(':');
              switch (kv[0])
              {
            case "name":
              entity.Name = kv[1];
              break;
            case "size":
              entity.Size = Utils.FromString(kv[1]);
              break;
            case "eff":
              entity.ConditionEffects = (ConditionEffects)Utils.FromString(kv[1]);
              break;
            case "conn":
              (entity as ConnectedObject).Connection =
                  ConnectionInfo.Infos[(uint)Utils.FromString(kv[1])];
              break;
            case "mtype":
              (entity as Merchants).Custom = true;
              (entity as Merchants).MType = Utils.FromString(kv[1]);
              break;
            case "mcount":
              (entity as Merchants).MRemaining = Utils.FromString(kv[1]);
              break;
            case "mtime":
              (entity as Merchants).MTime = Utils.FromString(kv[1]);
              break;
            case "mcost":
              (entity as SellableObject).Price = Utils.FromString(kv[1]);
              break;
            case "mcur":
              (entity as SellableObject).Currency = (CurrencyType)Utils.FromString(kv[1]);
              break;
            case "stars":
              (entity as SellableObject).RankReq = Utils.FromString(kv[1]);
              break;
              //case "nstar":
              //    entity.Stats[StatsType.NameChangerStar] = Utils.FromString(kv[1]); break;
              }
            }
            player.Owner.EnterWorld(entity);
              }
              if (num > 1)
            if (!args.ToLower().EndsWith("s"))
              player.SendInfo("Sucessfully spawned " + num + " : " +
                          CultureInfo.CurrentCulture.TextInfo.ToTitleCase(
                              args.Substring(index + 1).ToLower() + "s"));
            else
              player.SendInfo("Sucessfully spawned " + num + " : " +
                          CultureInfo.CurrentCulture.TextInfo.ToTitleCase(
                              args.Substring(index + 1).ToLower() + "'"));
              else
            player.SendInfo("Sucessfully spawned " + num + " : " +
                        CultureInfo.CurrentCulture.TextInfo.ToTitleCase(args.ToLower()));
              return true;
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     var item = args;
       var data = "";
       if (args.IndexOf("{", StringComparison.Ordinal) >= 0 && args.EndsWith("}"))
       {
     item = args.Remove(args.IndexOf("{", StringComparison.Ordinal)).TrimEnd();
     data = args.Substring(args.IndexOf("{", StringComparison.Ordinal));
       }
       ushort objType;
       if (!player.Manager.GameData.IdToObjectType.TryGetValue(item, out objType))
       {
     player.SendError("Unknown item type!");
     return false;
       }
       for (var i = 0; i < player.Inventory.Length; i++)
     if (player.Inventory[i] == null)
     {
       player.Inventory[i] = player.Manager.GameData.Items[objType];
       if (data != "")
     player.Inventory.Data[i] = ItemData.CreateData(data);
       player.UpdateCount++;
       return true;
     }
       player.SendError("Not enough space in inventory!");
       return false;
 }
        protected override bool Process(Player player, RealmTime time, string args)
        {
            if (player.Name.EqualsIgnoreCase(args))
            {
                player.SendInfo("You are already at yourself, and always will be!");
                return false;
            }
            if (player.Owner.AllowTeleport == false)
            {
                player.SendError("You are not allowed to teleport in this area!");
                return false;
            }

            foreach (var i in player.Owner.Players)
            {
                if (i.Value.Name.EqualsIgnoreCase(args))
                {
                    if (i.Value.isNotVisible)
                    {
                        player.SendInfo(string.Format("Unable to find player: {0}", args));
                        return false;
                    }
                    if (i.Value.HasConditionEffect(ConditionEffects.Invisible))
                    {
                        player.SendError("You can't teleport to invisible players");
                        return false;
                    }
                    player.Teleport(time, i.Value.Id);
                    return true;
                }
            }
            player.SendInfo(string.Format("Unable to find player: {0}", args));
            return false;
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (player.Quest == null)
     {
         player.SendError("Player does not have a quest!");
         return false;
     }
     player.SendInfo("Quest location: (" + player.Quest.X + ", " + player.Quest.Y + ")");
     return true;
 }
Beispiel #22
0
        public bool Execute(Player player, RealmTime time, string text)
        {
            var index = text.IndexOf(' ');
            string cmd = text.Substring(1, index == -1 ? text.Length - 1 : index - 1);
            var args = index == -1 ? "" : text.Substring(index + 1);

            Command command;
            if (!cmds.TryGetValue(cmd, out command))
            {
                player.SendError("Unknown command!");
                return false;
            }
            else
            {
                log.InfoFormat("[Command] <{0}> {1}", player.Name, text);
                return command.Execute(player, time, args);
            }
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (args.Length == 0)
     {
         player.SendHelp("Usage: /killPlayer <playername>");
         return false;
     }
     foreach (var i in player.Manager.Clients.Values)
     {
         if (i.Account.Name.EqualsIgnoreCase(args))
         {
             i.Player.HP = 0;
             i.Player.Death("Moderator");
             player.SendInfo("Player killed!");
             return true;
         }
     }
     player.SendError(string.Format("Player '{0}' could not be found!", args));
     return false;
 }
Beispiel #24
0
        public void UsePortal(RealmTime time, UsePortalPacket pkt)
        {
            Entity entity = Owner.GetEntity(pkt.ObjectId);
            if (entity == null || !entity.Usable) return;
            World world = null;
            Player player = this;
            Portal p = null;
            if (entity is Portal)
            {
                p = entity as Portal;
                world = p.WorldInstance;
            }
            if (world == null)
            {
                if (p != null)
                {
                    bool setWorldInstance = true;
                    string d = "";
                    if (XmlDatas.IdToDungeon.TryGetValue(entity.ObjectType, out d))
                    {
                        world = RealmManager.AddWorld(new XMLWorld(XmlDatas.DungeonDescs[d]));
                    }
                    else
                    {
                        switch (entity.ObjectType) //handling default case for not found. Add more as implemented
                        {
                            
                            case 0x0703: //portal of cowardice
                                {
                                    if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId))  //may not be valid, realm recycled?
                                        world = RealmManager.PlayerWorldMapping[this.AccountId];  //also reconnecting to vault is a little unexpected
                                    else if (world.Id == -5 || world.Id == -11)
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                    else
                                        world = RealmManager.GetWorld(World.NEXUS_ID);
                                } break;
                            case 0x0712:
                                world = RealmManager.GetWorld(World.NEXUS_ID); break;
                            case 0x071d:
                                world = RealmManager.GetWorld(World.NEXUS_ID); break;
                            case 0x071c:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x0720:
                                world = RealmManager.PlayerVault(psr);
                                setWorldInstance = false; break;
                            case 0x071e:
                                world = RealmManager.AddWorld(new Kitchen()); break;
                            case 0x0ffa: //these need to match IDs
                                //world = RealmManager.GetWorld(World.GauntletMap); break; //this creates a singleton dungeon
                                world = RealmManager.AddWorld(new Island()); break; //this allows each dungeon to be unique
                            case 0x0ffc:
                                world = RealmManager.AddWorld(new WineCellarMap()); break;
                            case 0x1900:
                                world = RealmManager.AddWorld(new ArenaMap()); break;
                            case 0x0730:
                                world = RealmManager.AddWorld(new OceanTrench()); break;
                            case 0x070c:
                                world = RealmManager.AddWorld(new SpriteWorld()); break;
                            case 0x071b:
                                world = RealmManager.AddWorld(new Abyss()); break;
                            case 0x071a:
                                world = RealmManager.AddWorld(new UndeadLair()); break;
                            case 0x1901:
                                world = RealmManager.AddWorld(new VoidWorld()); break;
                            case 0x072c:
                                world = RealmManager.AddWorld(new TombMap()); break;
                            case 0x0742:
                                world = RealmManager.AddWorld(new BeachZone()); break;
                            case 0x0718:
                                world = RealmManager.AddWorld(new SnakePit()); break;
                            case 0x0890:
                                world = RealmManager.AddWorld(new MadLabMap()); break;
                            case 0x1905:
                                if (player.Client.Account.Stats.TotalFame > 100)
                                {
                                    using (var db = new Database())
                                    {
                                       
                                        world = RealmManager.AddWorld(new BattleArenaMap());
                                        setWorldInstance = false;
                                        db.UpdateFame(player.Client.Account, -100);
                                    }
                                }
                                else
                                {
                                    player.SendError("Not Enough Fame!");
                                }
                                break;
                                
                                
                            case 0x1919:
                                world = RealmManager.AddWorld(new Secret()); break;
                            case 0x1923:
                                world = RealmManager.AddWorld(new ZombieMap()); break;
                            default: SendError("Portal Not Implemented!"); break;
                            case 0x195d:
                                world = RealmManager.AddWorld(new MarketMap()); break;
                            case 0x070d:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x070e:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x0704:
                                world = RealmManager.Monitor.GetRandomRealm(); break;
                            case 0x753E:
                                world = RealmManager.AddWorld(new LairofDraconis()); break;
                            case 0x7002:
                                world = RealmManager.AddWorld(new PartyCellarMap()); break;
                           

                        }
                    }
                    if(setWorldInstance)
                        p.WorldInstance = world;
                }
                else
                {
                    switch (entity.ObjectType) // Special Portals that cannot be the portal class
                    {
                        case 0x072f:
                            world =  RealmManager.GuildHallWorld(Guild);
                            break;
                        default: psr.SendPacket(new TextPacket
                        {
                            BubbleTime = 0,
                            Stars = -1,
                            Name = "",
                            Text = "Semi-Portal Not Implemented!"
                        }); break;
                    }
                }
            }

            //used to match up player to last realm they were in, to return them to it. Sometimes is odd, like from Vault back to Vault...
            if (RealmManager.PlayerWorldMapping.ContainsKey(this.AccountId))
            {
                World tempWorld;
                RealmManager.PlayerWorldMapping.TryRemove(this.AccountId, out tempWorld);
            }
            RealmManager.PlayerWorldMapping.TryAdd(this.AccountId, Owner);
            psr.Reconnect(new ReconnectPacket()
            {
                Host = "",
                Port = 2050,
                GameId = world.Id,
                Name = world.Name,
                Key = Empty<byte>.Array,
            });
        }
        protected override bool Process(Player player, RealmTime time, string args)
        {
            if (args.Length == 0)
            {
                player.SendHelp("Usage: /tpPos <X> <Y>");
                return false;
            }
            string[] coordinates = args.Split(' ');
            if (coordinates.Length != 2)
            {
                player.SendError("Invalid coordinates!");
                return false;
            }

            int x, y;
            if (!int.TryParse(coordinates[0], out x) ||
                !int.TryParse(coordinates[1], out y))
            {
                player.SendError("Invalid coordinates!");
                return false;
            }

            player.Move(x + 0.5f, y + 0.5f);
            player.SetNewbiePeriod();
            player.UpdateCount++;
            player.Owner.BroadcastPacket(new GotoPacket()
            {
                ObjectId = player.Id,
                Position = new Position()
                {
                    X = player.X,
                    Y = player.Y
                }
            }, null);
            return true;
        }
 protected override bool Process(Player player, RealmTime time, string args)
 {
     if (args.Trim() != "")
     {
         string cmd = args.Split(' ')[0];
         string left = args.Split(' ').Length > 1 ? string.Join(" ", args.Split(' ').Skip(1)) : "";
         bool inParty = player.Party != null;
         bool leader = inParty && player.Party.Leader == player;
         switch (cmd)
         {
             case "join":
                 if (left == "")
                 {
                     player.SendInfo("Usage: /party join <username>");
                     return false;
                 }
                 Player target = player.Owner.GetUniqueNamedPlayer(left);
                 if(target == null)
                 {
                     player.SendInfo("Player not found.");
                     return false;
                 }
                 if(target.Party == null)
                 {
                     player.SendInfo("Player is not in a party.");
                     return false;
                 }
                 if(target.Party.Leader != target)
                 {
                     player.SendInfo("You can only join the leader of the party.");
                     return false;
                 }
                 if(!target.Party.Invitations.Contains(player.AccountId))
                 {
                     player.SendInfo("You must be invited to join a party.");
                     return false;
                 }
                 if (player.Party != null)
                     if (player.Party.Leader == player)
                         player.Party.Disband();
                     else
                         player.Party.RemoveMember(player);
                 target.Party.AddMember(player);
                 break;
             case "invite":
                 if (left == "")
                 {
                     player.SendInfo("Usage: /party invite <username>");
                     return false;
                 }
                 if(inParty && !leader)
                 {
                     player.SendInfo("You must be the leader of a party to invite others.");
                     return false;
                 }
                 if(!inParty)
                 {
                     player.Party = new Party(player);
                     player.UpdateCount++;
                     inParty = true;
                 }
                 Player target2 = player.Owner.GetUniqueNamedPlayer(left);
                 if (target2 == null)
                 {
                     player.SendInfo("Player not found.");
                     return false;
                 }
                 if(target2.Client == null)
                 {
                     player.SendError("Player no longer exists!");
                     return false;
                 }
                 if(target2.Party == player.Party)
                 {
                     player.SendInfo("Player is already in your party.");
                     return false;
                 }
                 if (!player.Party.Invitations.Contains(target2.AccountId))
                     player.Party.Invitations.Add(target2.AccountId);
                 player.Party.SendPacket(new TextPacket
                 {
                     BubbleTime = 0,
                     Stars = -1,
                     Name = "",
                     Recipient = "*Party*",
                     Text = target2.Name + " was invited to the party"
                 }, null);
                 target2.Client.SendPacket(new InvitedToPartyPacket
                 {
                     Name = player.Name,
                     PartyID = player.Party.ID
                 });
                 break;
             case "kick":
                 if(left == "")
                 {
                     player.SendInfo("Usage: /party kick <username>");
                     return false;
                 }
                 if(!inParty || !leader)
                 {
                     player.SendInfo("You must be the leader of a party to kick others.");
                     return false;
                 }
                 Player target3 = player.Owner.GetUniqueNamedPlayer(left);
                 if (target3 == null)
                 {
                     player.SendInfo("Player not found.");
                     return false;
                 }
                 if (target3.Party != player.Party)
                 {
                     player.SendInfo("Player must be in your party.");
                     return false;
                 }
                 player.Party.SendPacket(new TextPacket
                 {
                     BubbleTime = 0,
                     Stars = -1,
                     Name = "",
                     Recipient = "*Party*",
                     Text = target3.Name + " was kicked from the party"
                 }, null);
                 player.Party.RemoveMember(target3);
                 break;
             case "disband":
             case "leave":
                 if(!inParty)
                 {
                     player.SendInfo("You are not in a party.");
                     return false;
                 }
                 if (player.Party.Leader == player)
                     player.Party.Disband();
                 else
                     player.Party.RemoveMember(player);
                 break;
             case "chat":
                 if(left.Trim() == "")
                 {
                     player.SendInfo("Usage: /party chat <message> or /p <message>");
                     return false;
                 }
                 if(!inParty)
                 {
                     player.SendInfo("You are not in a party.");
                     return false;
                 }
                 player.Manager.Chat.SayParty(player, left.ToSafeText());
                 break;
             case "help":
                 player.SendHelp("Party commands:\n[/party join <username>]: accept a party invite\n[/party invite <username>]: invite a player to your party (leader only)\n[/party kick <username>]: kick a user from your party (leader only)\n[/party leave]: leave your current party\n[/party chat <message>]: send a message to your party");
                 break;
             default:
                 player.SendInfo("Invalid command!");
                 player.SendInfo("Type \"/party help\" for commands.");
                 break;
         }
     }
     else
     {
         if(player.Party == null)
         {
             player.SendInfo("You are not in a party!");
             player.SendInfo("Type \"/party help\" for commands.");
             return false;
         }
         player.SendInfo("Party Leader:\n " + player.Party.Leader.Name);
         var members = player.Party.Members.Select(i => i.Name).ToList();
         player.SendInfo("Party Members:\n " + (members.Count > 0 ? string.Join(", ", members.ToArray()) : "None"));
         player.SendInfo("Type \"/party help\" for commands.");
     }
     return true;
 }