public override void onCommand(string cmd, string[] args, ICmdSource sender) { if (sender is Player) { Player player = (Player)sender; switch (cmd) { case "clearworld": { if (bot.Room.IsOwner && player.IsOp) bot.Connection.Send("clear"); else sender.Reply("You are not the owner."); break; } case "loadworld": { if (bot.Room.IsOwner && player.IsOp) bot.ChatSayer.Command("/loadlevel"); else sender.Reply("You are not the owner."); break; } case "saveworld": { if (bot.Room.IsOwner && player.IsOp) bot.Connection.Send("save"); else sender.Reply("You are not the owner."); break; } case "name": { if (bot.Room.IsOwner && player.IsOp) { string name = ""; if(args != null && args.Length > 0) { for (int i = 0; i < args.Length; i++) name += args[i] + " "; } bot.Connection.Send("name", name); } else sender.Reply("You are not the owner."); break; } } } }
public void PrintFurnitures(ICmdSource receiver) { string s = "You can place: "; foreach (var pair in furnitureTypes) s += pair.Key + ", "; s = s.Remove(s.Length - 3, 2); receiver.Reply(s); }
public override void onCommand(string cmd, string[] args, ICmdSource cmdSource) { switch(cmd) { case "test": { if (cmdSource is IPlayer) blockPlayers.Add(((Player)cmdSource).Id); else cmdSource.Reply("You are not a player."); break; } case "testf": case "testb": { int layer = 0; ; if (cmd == "testb") layer = 1; if (cmdSource is IPlayer) { IPlayer player = (IPlayer)cmdSource; int x = player.BlockX; int y = player.BlockY; IBlock block = bot.Room.getBlock(layer, x, y); if (block != null) player.Reply("ID:" + block.Id + " X:" + x + " Y:" + y + " Placer:" + (block.Placer != null ? block.Placer.Name : "undefined")); else player.Reply("That is a null block, not good!"); } else cmdSource.Reply("You are not a player."); break; } } }
public override void onCommand(string cmd, string[] args, ICmdSource cmdSource) { switch (cmd) { case "loadhouses": if (cmdSource is IPlayer) { IPlayer player = cmdSource as IPlayer; if (player.IsOp) houseManager.Load(); } break; case "helphouse": case "househelp": if (cmdSource is IPlayer) { IPlayer player = cmdSource as IPlayer; player.Send("House commands: !houseinfo, !build, !finishhouse, !edithouse, !destroyhouse, !place, !trust, !untrust, !whoistrusted"); } break; case "deletehouse": case "removehouse": case "destroyhouse": if (cmdSource is IPlayer) { IPlayer builder = cmdSource as IPlayer; houseManager.DestroyHouse(builder); } break; case "changehouse": case "edithouse": if (cmdSource is IPlayer) { IPlayer builder = cmdSource as IPlayer; houseManager.EditHouse(builder); } break; case "buildhouse": case "build": if (cmdSource is IPlayer) { IPlayer builder = cmdSource as IPlayer; if (args.Count() >= 1) { int width = 12; int height = 12; int x = builder.BlockX - width; int y = builder.BlockY - height; string houseType = args[0]; if (houseManager.BuildHouse(builder, houseType)) builder.Reply("say !finishhouse when you're done!"); } else houseManager.ShowHouses(builder); } break; case "placefurniture": case "placef": case "place": if (cmdSource is IPlayer) { IPlayer player = cmdSource as IPlayer; if (args.Length >= 1) { string furnitureType = args[0]; if (furnitureManager.GetFurnitureType(furnitureType) == null) { player.Reply("That is not a valid furniture."); return; } Furniture furniture = (Furniture)Activator.CreateInstance(furnitureManager.GetFurnitureType(furnitureType).GetType(), new object[] {-1, -1}); if (furnitureType != null) { House house = houseManager.FindHouse(player.BlockX, player.BlockY); if (house != null) { if (house.IsValidFurniturePosition(player.BlockX, player.BlockY)) { BlockPos pos = new BlockPos(0, player.BlockX, player.BlockY); furniture.X = pos.X; furniture.Y = pos.Y; bot.Room.setBlock(pos.X, pos.Y, furniture.getBlock(bot, player, house)); if (house.Furniture.ContainsKey(pos)) { if (house.Furniture[pos].Type != "empty") player.Reply("Replaced old furniture."); else player.Reply("Furniture placed."); house.Furniture[pos] = furniture; } else { house.Furniture.Add(pos, furniture); player.Reply("Furniture placed."); } houseManager.Save(); } else player.Reply("You can't place furniture there."); } else player.Reply("You must be inside your house to place furniture!"); } else { furnitureManager.PrintFurnitures(player); } } else { furnitureManager.PrintFurnitures(player); //string s = "You can place: "; //foreach (var v in FurnitureManager.FurnitureTypes) // s += v.Key + ", "; //s = s.Remove(s.Length - 3, 2); //player.Reply(s); } } break; case "finishouse": case "finishhouse": if (cmdSource is IPlayer) { IPlayer builder = cmdSource as IPlayer; houseManager.FinishHouse(builder); } break; case "houseinfo": if (cmdSource is IPlayer && args.Length >= 1) { IPlayer player = cmdSource as IPlayer; HouseType houseType = houseManager.GetHouseType(args[0]); if (houseType == null) { houseManager.ListHouseTypes(player); } else { IInventoryContainer inventoryPlayer = (IInventoryContainer)player.GetMetadata("digplayer"); player.Reply(houseType.Name + " " + "Size: " + houseType.Width + "*" + houseType.Height); houseType.PrintCost(player, inventoryPlayer.Inventory); } } break; case "trust": if (cmdSource is IPlayer && args.Length >= 1) { HousePlayer housePlayer = HousePlayer.Get(cmdSource as IPlayer); housePlayer.Trust(args[0]); housePlayer.PrintTrusted(); } break; case "untrust": if (cmdSource is IPlayer && args.Length >= 1) { HousePlayer housePlayer = HousePlayer.Get(cmdSource as IPlayer); if (housePlayer.IsTrusted(args[0])) { housePlayer.Untrust(args[0]); cmdSource.Reply("You no longer trust" + args[0] + "."); housePlayer.PrintTrusted(); } else { cmdSource.Reply("You never trusted " + args[0] + "."); } } break; case "whoistrusted": if (cmdSource is IPlayer && args.Length >= 1) { HousePlayer.Get(cmdSource as IPlayer).PrintTrusted(); } break; default: break; } }