public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//contract")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } if (1 >= splits.Count) { Chat.Send(player, "<color=orange>Wrong Arguments</color>"); return(true); } if (!int.TryParse(splits[1], out int quantity)) { Chat.Send(player, "<color=orange>Not number</color>"); return(true); } string sdirection; if (2 == splits.Count) //Default: Contract ? FORWARD { sdirection = "forward"; } else { sdirection = splits[2]; } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Vector3Int direction = CommandHelper.GetDirection(player.Forward, sdirection); Vector3Int start = wand.area.corner1; Vector3Int end = wand.area.corner2; if (1 == direction.x || 1 == direction.y || 1 == direction.z) { end -= (direction * quantity); } else { start -= (direction * quantity); } wand.area.SetCorner1(start, player); wand.area.SetCorner2(end, player); Chat.Send(player, string.Format("<color=lime>Area contracted {0} block {1}</color>", quantity, sdirection)); return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//limit")) { return(false); } //Player exists if (null == player || NetworkID.Server == player.ID) { return(true); } //Check permissions if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.wand")) { return(true); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); //Wand is OFF if (!wand.active) { Chat.Send(player, "<color=orange>Wand is OFF, use //wand to activate</color>"); return(true); } if (1 == splits.Count) { Chat.Send(player, string.Format("<color=lime>Limit: {0}</color>", wand.limit)); return(true); } if (2 != splits.Count) { Chat.Send(player, "<color=orange>Wrong Arguments</color>"); return(true); } if (!int.TryParse(splits[1], out int newLimit)) { Chat.Send(player, "<color=orange>Not number</color>"); return(true); } wand.limit = newLimit; Chat.Send(player, string.Format("<color=lime>Limit: {0}</color>", newLimit)); return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//save")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } if (!CommandHelper.CheckLimit(player)) { return(true); } if (!chat.Contains(" ")) { Chat.Send(player, "<color=orange>Wrong Arguments</color>"); return(true); } string blueprintName = chat.Substring(chat.IndexOf(" ") + 1).Trim(); blueprintName = blueprintName.Replace(" ", "_"); AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Blueprint blueprint = wand.copy; if (blueprint == null) { Chat.Send(player, string.Format("<color=orange>There is nothing to save.</color>")); return(true); } if (BlueprintManager._blueprints.ContainsKey(blueprintName)) { Chat.Send(player, string.Format("<color=orange>A blueprint with that name already exists.</color>")); return(true); } blueprint.saveBlueprint(blueprintName); BlueprintManager._blueprints.Add(blueprintName, blueprint); Chat.Send(player, string.Format("<color=lime>Blueprint saved as: {0}</color>", blueprintName)); return(true); }
//player != null public static bool CheckLimit(Players.Player player) { AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); int blocks_in_selected_area = wand.area.GetSize(); if (wand.limit < blocks_in_selected_area) { Chatting.Chat.Send(player, string.Format("<color=orange>You are trying to change {0} and the limit is {1}. You can change the limit with //limit <new_limit></color>", blocks_in_selected_area, wand.limit)); return(false); } return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().Equals("//pos1") && !chat.Trim().ToLower().Equals("//pos2")) { return(false); } //Player exists if (null == player || NetworkID.Server == player.ID) { return(false); } //Check permissions if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.wand")) { return(true); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); //Wand is OFF if (!wand.active) { Chat.Send(player, "<color=orange>Wand is OFF, use //wand to activate</color>"); return(true); } Vector3Int newPos = new Vector3Int(player.Position); if (splits[0].Equals("//pos1")) { wand.area.SetCorner1(newPos, player); Chat.Send(player, string.Format("<color=lime>Pos 1: {0}</color>", newPos)); } else //pos2 { wand.area.SetCorner2(newPos, player); Chat.Send(player, string.Format("<color=lime>Pos 2: {0}</color>", newPos)); } return(true); }
//Misc checks to call a command public static bool CheckCommand(Players.Player player) { //Player exists if (null == player || NetworkID.Server == player.ID) { return(false); } //Player has permission if (!PermissionsManager.CheckAndWarnPermission(player, "khanx.wand")) { return(false); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); //Wand is OFF if (!wand.active) { Chatting.Chat.Send(player, "<color=orange>Wand is OFF, use //wand to activate</color>"); return(false); } //Pos1 initialized if (!wand.area.IsPos1Initialized()) { Chatting.Chat.Send(player, "<color=orange>Pos 1 not initialized</color>"); return(false); } //Pos2 initialized if (!wand.area.IsPos2Initialized()) { Chatting.Chat.Send(player, "<color=orange>Pos 2 not initialized</color>"); return(false); } return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//size")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Chat.Send(player, "<color=olive>Area size:</color>"); Chat.Send(player, string.Format("<color=lime>x: {0}</color>", wand.area.GetXSize())); Chat.Send(player, string.Format("<color=lime>y: {0}</color>", wand.area.GetYSize())); Chat.Send(player, string.Format("<color=lime>z: {0}</color>", wand.area.GetZSize())); Chat.Send(player, string.Format("<color=lime>total: {0}</color>", wand.area.GetSize())); return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//rotate")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } if (!CommandHelper.CheckLimit(player)) { return(true); } //LEFT int direction = 1; if (2 <= splits.Count) { switch (splits[1].Trim().ToLower()) { case "l": case "left": case "270": direction = 3; break; case "r": case "right": case "90": direction = 1; break; case "b": case "back": case "f": case "flip": case "180": direction = 2; break; default: direction = 1; break; } } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Blueprint blueprint = new Blueprint(wand.area, player); Vector3Int start = wand.area.corner1; Vector3Int end = wand.area.corner2; //Remove the current area for (int x = end.x; x >= start.x; x--) { for (int y = end.y; y >= start.y; y--) { for (int z = end.z; z >= start.z; z--) { Vector3Int newPos = new Vector3Int(x, y, z); if (!World.TryGetTypeAt(newPos, out ushort actualType) || actualType != BlockTypes.BuiltinBlocks.Indices.air) { AdvancedWand.AddAction(newPos, BlockTypes.BuiltinBlocks.Indices.air, player); } } } } for (int i = 0; i < direction; i++) { blueprint.Rotate(); } for (int x = 0; x < blueprint.xSize; x++) { for (int y = 0; y < blueprint.ySize; y++) { for (int z = 0; z < blueprint.zSize; z++) { Vector3Int newPosition = new Vector3Int(player.Position) - blueprint.playerMod + new Vector3Int(x, y, z); //DONT USE THIS IT CAN CAUSE PROBLEMS!!! //if(!World.TryGetTypeAt(newPosition, out ushort actualType) || actualType != blueprint.blocks[x, y, z]) AdvancedWand.AddAction(newPosition, blueprint.blocks[x, y, z], player); } } } return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//info")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Vector3Int start = wand.area.corner1; Vector3Int end = wand.area.corner2; Dictionary <ushort, int> info = new Dictionary <ushort, int>(); for (int x = start.x; x <= end.x; x++) { for (int y = start.y; y <= end.y; y++) { for (int z = start.z; z <= end.z; z++) { Vector3Int newPos = new Vector3Int(x, y, z); if (World.TryGetTypeAt(newPos, out ushort actualType)) { ItemTypes.ItemType type = ItemTypes.GetType(actualType); if (!ItemTypes.NotableTypes.Contains(type)) { while (type.ParentItemType != null) { type = type.ParentItemType; } actualType = type.ItemIndex; } if (info.TryGetValue(actualType, out int value)) { info[actualType] = value + 1; } else { info[actualType] = 1; } } } } } //Las camas son de dos bloques if (info.ContainsKey(ItemTypes.IndexLookup.GetIndex("bed"))) { info[ItemTypes.IndexLookup.GetIndex("bed")] /= 2; } Chat.Send(player, "<color=olive>Area info:</color>"); foreach (ushort key in info.Keys) { if (key == 0) { continue; } string name = ItemTypes.IndexLookup.GetName(key); Chat.Send(player, string.Format("<color=lime>{0}({1}): {2}</color>", name, key, info[key])); } return(true); }
public bool TryDoCommand(Players.Player player, string chat, List <string> splits) { if (!chat.Trim().ToLower().StartsWith("//count")) { return(false); } if (!CommandHelper.CheckCommand(player)) { return(true); } if (2 != splits.Count) { Chat.Send(player, "<color=orange>Wrong Arguments</color>"); return(true); } AdvancedWand wand = AdvancedWand.GetAdvancedWand(player); Vector3Int start = wand.area.corner1; Vector3Int end = wand.area.corner2; ushort blockIndex = 0; try { bool isNumeric = int.TryParse(splits[1], out int IDBlock); if (isNumeric) { blockIndex = (ushort)IDBlock; } else { blockIndex = ItemTypes.IndexLookup.GetIndex(splits[1]); } } catch (System.ArgumentException) { Chat.Send(player, "<color=orange>Block not found</color>"); return(true); } int count = 0; for (int x = start.x; x <= end.x; x++) { for (int y = start.y; y <= end.y; y++) { for (int z = start.z; z <= end.z; z++) { Vector3Int newPos = new Vector3Int(x, y, z); if (World.TryGetTypeAt(newPos, out ushort actualType)) { if (actualType == blockIndex) { count++; } else { ItemTypes.ItemType type = ItemTypes.GetType(actualType); if (type.ParentItemType != null && type.ParentItemType.ItemIndex == blockIndex) { count++; } } } } } } //Las camas son de dos bloques if (blockIndex == ItemTypes.IndexLookup.GetIndex("bed")) { count /= 2; } Chat.Send(player, string.Format("<color=lime>{0}({1}): {2}</color>", splits[1], blockIndex, count)); return(true); }