public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length < 2) { Help(client, alias, arguments); return; } string username = arguments[0]; var messageBuilder = new System.Text.StringBuilder(); for (int i = 1; i < arguments.Length; i++) messageBuilder.Append(arguments[i] + " "); var message = messageBuilder.ToString(); var receivingPlayer = GetPlayerByName(client, username); if (receivingPlayer == null) { client.SendMessage("No client with the username \"" + username + "\" was found."); return; } if (receivingPlayer == client) { client.SendMessage(ChatColor.Red + "You can't send a private message to yourself!"); return; } receivingPlayer.SendMessage(ChatColor.Gray + "<"+ client.Username + " -> You> " + message); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { switch (arguments.Length) { case 0: client.SendMessage(client.World.Time.ToString()); break; case 2: if (!arguments[0].Equals("set")) Help(client, alias, arguments); int newTime; if(!Int32.TryParse(arguments[1], out newTime)) Help(client, alias, arguments); client.World.Time = newTime; client.SendMessage(string.Format("Setting time to {0}", arguments[1])); foreach (var remoteClient in client.Server.Clients.Where(c => c.World.Equals(client.World))) remoteClient.QueuePacket(new TimeUpdatePacket(newTime)); break; default: Help(client, alias, arguments); break; } }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length < 2) { Help(client, alias, arguments); return; } string username = arguments[0]; var messageBuilder = new System.Text.StringBuilder(); for (int i = 1; i < arguments.Length; i++) { messageBuilder.Append(arguments[i] + " "); } var message = messageBuilder.ToString(); var receivingPlayer = GetPlayerByName(client, username); if (receivingPlayer == null) { client.SendMessage("No client with the username \"" + username + "\" was found."); return; } if (receivingPlayer == client) { client.SendMessage(ChatColor.Red + "You can't send a private message to yourself!"); return; } receivingPlayer.SendMessage(ChatColor.Gray + "<" + client.Username + " -> You> " + message); }
public void HelpPage(IRemoteClient client, int page) { const int perPage = 5; var numPages = (int)Math.Floor((double)Commands.Commands.Count / perPage); if (Commands.Commands.Count % perPage > 0) { numPages++; } if (page < 1 || page > numPages) { page = 1; } var startingIndex = (page - 1) * perPage; client.SendMessage("--Help page " + page + " of " + numPages + "--"); for (var i = 0; i < perPage; i++) { var index = startingIndex + i; if (index > Commands.Commands.Count - 1) { break; } var command = Commands.Commands[index]; client.SendMessage("/" + command.Name + " - " + command.Description); } }
public void HelpPage(IRemoteClient Client, int Page) { int PerPage = 5; int Pages = (int)Math.Floor((double)(Program.CommandManager.Commands.Count / PerPage)); if ((Program.CommandManager.Commands.Count % PerPage) > 0) { Pages++; } if (Page < 1 || Page > Pages) { Page = 1; } int StartingIndex = (Page - 1) * PerPage; Client.SendMessage("--Help Page " + Page + " of " + Pages + "--"); for (int i = 0; i < PerPage; i++) { int Index = StartingIndex + i; if (Index > Program.CommandManager.Commands.Count - 1) { break; } ICommand C = Program.CommandManager.Commands[Index]; Client.SendMessage("/" + C.Name + " - " + C.Description); } }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { StringBuilder listMessage = new StringBuilder("Currently connected players: "); foreach (IRemoteClient c in client.Server.Clients) { if (listMessage.Length + c.Username.Length + 2 >= 120) { client.SendMessage(listMessage.ToString()); listMessage.Clear(); } listMessage.AppendFormat("{0}, ", c.Username); } listMessage.Remove(listMessage.Length - 2, 2); client.SendMessage(listMessage.ToString()); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } int id; if (!int.TryParse(arguments[0], out id)) { Help(client, alias, arguments); return; } var manager = client.Server.GetEntityManagerForWorld(client.World); var entity = manager.GetEntityByID(id) as MobEntity; if (entity == null) { client.SendMessage(ChatColor.Red + "An entity with that ID does not exist in this world."); return; } manager.DespawnEntity(entity); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length < 2) { Help(client, alias, arguments); return; } string username = arguments[0], itemid = arguments[1], amount = "1"; if(arguments.Length >= 3) amount = arguments[2]; var receivingPlayer = GetPlayerByName(client, username); if (receivingPlayer == null) { client.SendMessage("No client with the username \"" + username + "\" was found."); return; } if (!GiveItem(receivingPlayer, itemid, amount, client)) { Help(client, alias, arguments); } }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { string toSend = "Currently connected players: "; foreach (IRemoteClient i in client.Server.Clients) { toSend = toSend + i.Username + ", "; if (toSend > 119) { client.SendMessage("Too many online players."); return; } } toSend = toSend.Remove(toSend.Length - 2); client.SendMessage(toSend); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length < 3) { Help(client, alias, arguments); return; } string username = arguments[1], itemid = arguments[2], amount = "1"; if (arguments.Length >= 4) { amount = arguments[3]; } var receivingPlayer = GetPlayerByName(client, username); if (receivingPlayer == null) { client.SendMessage("No client with the username \"" + username + "\" was found."); return; } if (!GiveItem(receivingPlayer, itemid, amount, client)) { Help(client, alias, arguments); } }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } var entityTypes = new List <Type>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var t in assembly.GetTypes()) { if (typeof(IEntity).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface) { entityTypes.Add(t); } } } arguments[0] = arguments[0].ToUpper(); var type = entityTypes.SingleOrDefault(t => t.Name.ToUpper() == arguments[0] + "ENTITY"); if (type == null) { client.SendMessage(ChatColor.Red + "Unknown entity type."); return; } var entity = (IEntity)Activator.CreateInstance(type); var em = client.Server.GetEntityManagerForWorld(client.World); entity.Position = client.Entity.Position + MathHelper.FowardVector(client.Entity.Yaw) * 3; em.SpawnEntity(entity); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 0) { Help(client, alias, arguments); return; } client.SendMessage(client.Entity.Position.ToString()); }
protected static bool GiveItem(IRemoteClient receivingPlayer, string itemid, string amount, IRemoteClient client) { short Id; short metadata = 0; int count; if (itemid.Contains(":")) { var parts = itemid.Split(':'); if (!short.TryParse(parts[0], out Id) || !short.TryParse(parts[1], out metadata) || !int.TryParse(amount, out count)) { return(false); } } else { if (!short.TryParse(itemid, out Id) || !int.TryParse(amount, out count)) { return(false); } } if (client.Server.ItemRepository.GetItemProvider(Id) == null) { client.SendMessage("Invalid item Id \"" + Id + "\"."); return(true); } var username = receivingPlayer.Username; var inventory = receivingPlayer.Inventory as InventoryWindow; if (inventory == null) { return(false); } while (count > 0) { sbyte amountToGive; if (count >= 64) { amountToGive = 64; } else { amountToGive = (sbyte)count; } count -= amountToGive; inventory.PickUpStack(new ItemStack(Id, amountToGive, metadata)); } return(true); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 0) { Help(client, alias, arguments); return; } client.SendMessage(client.SelectedItem.ToString()); }
public override void Handle(IRemoteClient Client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(Client, alias, arguments); return; } Client.SendMessage(Client.Entity.Position.ToString()); }
/// <summary> /// Tries to find the specified command by first performing a /// case-insensitive search on the command names, then a /// case-sensitive search on the aliases. /// </summary> /// <param name="client">Client which called the command</param> /// <param name="alias">Case-insensitive name or case-sensitive alias of the command</param> /// <param name="arguments"></param> public void HandleCommand(IRemoteClient client, string alias, string[] arguments) { ICommand foundCommand = FindByName(alias) ?? FindByAlias(alias); if (foundCommand == null) { client.SendMessage("Invalid command \"" + alias + "\"."); return; } foundCommand.Handle(client, alias, arguments); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } int Id; if (!int.TryParse(arguments[0], out Id)) { Help(client, alias, arguments); return; } var manager = client.Server.GetEntityManagerForWorld(client.World); var entity = manager.GetEntityById(Id) as MobEntity; if (entity == null) { client.SendMessage(ChatColor.Red + "An entity with that Id does not exist in this world."); return; } Task.Factory.StartNew(() => { var astar = new AStarPathFinder(); var path = astar.FindPath(client.World, entity.BoundingBox, (Coordinates3D)entity.Position, (Coordinates3D)client.Entity.Position); if (path == null) { client.SendMessage(ChatColor.Red + "It is impossible for this entity to reach you."); } else { client.SendMessage(string.Format(ChatColor.Blue + "Executing path with {0} waypoints", path.Waypoints.Count())); entity.CurrentPath = path; } }); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { int mod = 0; if (arguments.Length == 1) { int.TryParse(arguments[0], out mod); } client.SendMessage(client.World.GetSkyLight( (Coordinates3D)(client.Entity.Position + new Vector3(0, -mod, 0))).ToString()); }
public void HelpPage(IRemoteClient client, int page) { const int perPage = 5; int numPages = (int)Math.Floor(((double)Program.CommandManager.Commands.Count / perPage)); if ((Program.CommandManager.Commands.Count % perPage) > 0) numPages++; if (page < 1 || page > numPages) page = 1; int startingIndex = (page - 1) * perPage; client.SendMessage("--Help page " + page + " of " + numPages + "--"); for (int i = 0; i < perPage; i++) { int index = startingIndex + i; if (index > Program.CommandManager.Commands.Count - 1) { break; } var command = Program.CommandManager.Commands[index]; client.SendMessage("/" + command.Name + " - " + command.Description); } }
public override void Handle(IRemoteClient Client, string alias, string[] arguments) { switch (arguments.Length) { case 1: Client.SendMessage(Client.World.Time.ToString()); break; case 3: if (!arguments[1].Equals("set")) { Help(Client, alias, arguments); } int newTime; if (!Int32.TryParse(arguments[2], out newTime)) { Help(Client, alias, arguments); } Client.World.Time = newTime; Client.SendMessage(string.Format("Setting time to {0}", arguments[2])); foreach (var client in Client.Server.Clients.Where(c => c.World.Equals(Client.World))) { client.QueuePacket(new TimeUpdatePacket(newTime)); } break; default: Help(Client, alias, arguments); break; } }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } int Id; if (!int.TryParse(arguments[0], out Id)) { Help(client, alias, arguments); return; } var manager = client.Server.GetEntityManagerForWorld(client.World); var entity = manager.GetEntityById(Id); if (entity == null) { client.SendMessage(ChatColor.Red + "An entity with that Id does not exist in this world."); return; } client.SendMessage(string.Format( "{0} {1}", entity.GetType().Name, entity.Position)); if (entity is MobEntity) { var mob = entity as MobEntity; client.SendMessage(string.Format( "{0}/{1} HP, {2} State, moving to to {3}", mob.Health, mob.MaxHealth, mob.CurrentState?.GetType().Name ?? "null", mob.CurrentPath?.Waypoints.Last().ToString() ?? "null")); } }
protected static bool GiveItem(IRemoteClient receivingPlayer, string itemid, string amount, IRemoteClient client) { short id; int count; if (!short.TryParse(itemid, out id) || !Int32.TryParse(amount, out count)) { return(false); } if (client.Server.ItemRepository.GetItemProvider(id) == null) { client.SendMessage("Invalid item id \"" + id + "\"."); return(true); } string username = receivingPlayer.Username; var inventory = receivingPlayer.Inventory as InventoryWindow; if (inventory == null) { return(false); } while (count > 0) { sbyte amountToGive; if (count >= 64) { amountToGive = 64; } else { amountToGive = (sbyte)count; } count -= amountToGive; inventory.PickUpStack(new ItemStack(id, amountToGive)); } return(true); }
protected static bool GiveItem(IRemoteClient receivingPlayer, string itemid, string amount, IRemoteClient client) { short id; short metadata = 0; int count; if (itemid.Contains(":")) { var parts = itemid.Split(':'); if (!short.TryParse(parts[0], out id) || !short.TryParse(parts[1], out metadata) || !Int32.TryParse(amount, out count)) return false; } else { if (!short.TryParse(itemid, out id) || !Int32.TryParse(amount, out count)) return false; } if (client.Server.ItemRepository.GetItemProvider(id) == null) { client.SendMessage("Invalid item id \"" + id + "\"."); return true; } string username = receivingPlayer.Username; var inventory = receivingPlayer.Inventory as InventoryWindow; if (inventory == null) return false; while (count > 0) { sbyte amountToGive; if (count >= 64) amountToGive = 64; else amountToGive = (sbyte) count; count -= amountToGive; inventory.PickUpStack(new ItemStack(id, amountToGive, metadata)); } return true; }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/save: Saves the world!"); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/pos: Shows your position."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/tome [id]: Moves a mob to your position."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/time: Shows the current time."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Correct usage is /" + alias + " <User> <Item ID> [Amount]"); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } var entityTypes = new List<Type>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var t in assembly.GetTypes()) { if (typeof(IEntity).IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface) entityTypes.Add(t); } } arguments[0] = arguments[0].ToUpper(); var type = entityTypes.SingleOrDefault(t => t.Name.ToUpper() == arguments[0] + "ENTITY"); if (type == null) { client.SendMessage(ChatColor.Red + "Unknown entity type."); return; } var entity = (IEntity)Activator.CreateInstance(type); var em = client.Server.GetEntityManagerForWorld(client.World); entity.Position = client.Entity.Position + MathHelper.FowardVector(client.Entity.Yaw) * 3; em.SpawnEntity(entity); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/destroy [id]: " + Description); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Pong!"); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/spawn [type]: Spawns a mob of that type."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Correct usage is /" + alias); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/pos: Toggles client logging."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/sl"); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Correct usage is /" + alias + " <page#/command> [command arguments]"); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { int mod = 0; if (arguments.Length == 1) int.TryParse(arguments[0], out mod); client.SendMessage(client.World.GetSkyLight( (Coordinates3D)(client.Entity.Position + new Vector3(0, -mod, 0))).ToString()); }
public virtual void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Command \"" + alias + "\" is not functional!"); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/reinv: Resends your inventory."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/what: Tells you what you're holding."); }
public override void Handle(IRemoteClient client, string alias, string[] arguments) { if (arguments.Length != 1) { Help(client, alias, arguments); return; } int id; if (!int.TryParse(arguments[0], out id)) { Help(client, alias, arguments); return; } var manager = client.Server.GetEntityManagerForWorld(client.World); var entity = manager.GetEntityByID(id) as MobEntity; if (entity == null) { client.SendMessage(ChatColor.Red + "An entity with that ID does not exist in this world."); return; } Task.Factory.StartNew(() => { var astar = new AStarPathFinder(); var path = astar.FindPath(client.World, entity.BoundingBox, (Coordinates3D)entity.Position, (Coordinates3D)client.Entity.Position); if (path == null) { client.SendMessage(ChatColor.Red + "It is impossible for this entity to reach you."); return; } entity.CurrentPath = path; }); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("Correct usage is /trash <hotbar/all> or leave blank to clear\nselected slot."); }
public override void Help(IRemoteClient client, string alias, string[] arguments) { client.SendMessage("/trash: Discards selected item."); }