public void Use(Player p, string[] args) { CatchPos cpos = new CatchPos(); if (args.Length != 0) { cpos.ignore = new List<byte>(); for (int i = 0; i < args.Length; i++) { try { cpos.ignore.Add(Block.NameToBlock(args[i])); } catch { p.SendMessage("Could not find the block '" + args[i] + "'"); return; } } string s = ""; for (int i = 0; i < cpos.ignore.Count; i++) { s += ((Block)cpos.ignore[i]).Name; if (i == cpos.ignore.Count - 2) s += " and "; else if (i != cpos.ignore.Count - 1) s += ", "; } p.SendMessage("Ignoring " + s + "."); } //else //cpos.ignore.Add(Block.NameToByte("unknown")); //So it doesn't ignore air. p.SendMessage("Place two blocks to determine the edges."); //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos); p.SetDatapass("CmdMeasure_cpos", cpos); p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock); }
void BlockChange1(Player sender, BlockChangeEventArgs args) { CatchPos cpos = (CatchPos)sender.GetDatapass(Name); cpos.pos = new Vector3S((short)args.X, (short)args.Z, (short)args.Y); args.Cancel(); sender.OnPlayerBlockChange.Normal -= BlockChange1; sender.SetDatapass(Name, cpos); sender.OnPlayerBlockChange.Normal += BlockChange2; }
public void Use(Player p, string[] args) { if (args.Length == 0) { p.SendMessage("Please specify a message to write!"); Help(p); return; } CatchPos cpos = new CatchPos(); cpos.message = string.Join(" ", args); p.SetDatapass(Name, cpos); p.SendMessage("Place two blocks to determine the direction!"); p.OnPlayerBlockChange.Normal += BlockChange1; }
public void CatchBlock(Player sender, BlockChangeEventArgs args) { args.Unregister(); Vector3S FirstBlock = new Vector3S(args.X, args.Z, args.Y); sender.SendMessage("Please place another block..."); sender.SetDatapass("CmdDatapassExample_FirstBlock", FirstBlock); sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2); }
public void CatchBlock1(Player p, BlockChangeEventArgs args) { CatchPos cpos = (CatchPos)p.GetDatapass(this.Name); cpos.pos = new Vector3S(args.X, args.Z, args.Y); args.Cancel(); p.OnPlayerBlockChange.Normal -= new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1); p.SetDatapass(this.Name, cpos); p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2); }
//public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass) public void CatchBlock(Player sender, BlockChangeEventArgs args) { CatchPos cpos = (CatchPos)sender.GetDatapass("CmdReplaceNot_cpos"); cpos.pos = new Vector3S(args.X, args.Z, args.Y); args.Unregister(); sender.SetDatapass("CmdReplaceNot_cpos", cpos); sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2); //p.CatchNextBlockchange(CatchBlock2, (object)cpos); }
public void CatchBlock(Player sender, BlockChangeEventArgs args) { CatchPos cpos = (CatchPos)sender.GetDatapass("CmdReplace_cpos"); ; cpos.pos = new Vector3S(args.X, args.Y, args.Z); args.Unregister(); args.Cancel(); sender.SetDatapass("CmdReplace_cpos", cpos); sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2); }
//public void CatchBlock(Player p, ushort x, ushort z, ushort y, byte NewType, bool placed, object DataPass) public void CatchBlock(Player sender, BlockChangeEventArgs args) { args.Cancel(); args.Unregister(); sender.SendBlockChange(args.X, args.Z, args.Y, sender.Level.GetBlock(args.X, args.Z, args.Y)); CatchPos cpos = (CatchPos)sender.GetDatapass("CmdMeasure_cpos"); cpos.FirstBlock = new Vector3S(args.X, args.Z, args.Y); sender.SetDatapass("CmdMeasure_cpos", cpos); sender.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock2); //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock2), (object)cpos); }
public void Use(Player p, string[] args) { if (args.Length != 2) { p.SendMessage("Invalid number of arguments!"); Help(p); return; } CatchPos cpos = new CatchPos(); List<string> oldType; if (args[0].Contains(",")) oldType = new List<string>(args[0].Split(',')); else oldType = new List<string>() { args[0] }; oldType = oldType.Distinct().ToList(); // Remove duplicates List<string> invalid = new List<string>(); //Check for invalid blocks foreach (string name in oldType) if (!Block.ValidBlockName(name)) invalid.Add(name); if (!Block.ValidBlockName(args[1])) invalid.Add(args[1]); if (invalid.Count > 0) { p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid))); return; } if (oldType.Contains(args[1])) oldType.Remove(args[1]); if (oldType.Count < 1) { p.SendMessage("Replacing a block with the same one would be pointless!"); return; } cpos.oldType = new List<byte>(); foreach (string name in oldType) cpos.oldType.Add(Block.NameToBlock(name)); cpos.newType = Block.NameToBlock(args[1]); p.SendMessage("Place two blocks to determine the edges."); p.SetDatapass(this.Name, cpos); p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1); }
public void Use(Player p, string[] args) { Level l = args.Length != 0 ? Level.Levels.Find(lev => { return lev.Name.IndexOf(String.Join(" ", args)) != -1; }) : p.Level; if (l == null) { p.SendMessage("Could not find specified level."); return; } p.SendMessage(String.Concat(Colors.yellow, "Map Name: ", Colors.white, l.Name)); p.SendMessage(String.Concat(Colors.yellow, "Map Size: ", Colors.white, l.Size)); p.SendMessage(String.Concat(Colors.yellow, "Total Blocks: ", Colors.white, l.TotalBlocks)); p.SendMessage(String.Concat(Colors.yellow, "Spawn Pos: ", Colors.white, l.SpawnPos)); p.SendMessage(String.Concat(Colors.yellow, "Physics Tick: ", Colors.white, l.PhysicsTick)); p.SendMessage(String.Concat("To see a list of players currently on ", l.Name, ", type \"yes\".")); //OnPlayerChat.Register(plist, MCForge.API.Priority.Normal, l, p); p.OnPlayerChat.Normal += new ChatEvent.EventHandler(plist); p.SetDatapass("mapinfoLevel", l); }
public void Use(Player p, string[] args) { if (p.Group.Permission < Permission) { p.SendMessage("You're not allowed to use /mb"); return; } PluginMessageBlock pmb = (PluginMessageBlock)Plugin.getByType(typeof(PluginMessageBlock).Name); if (pmb == null) { p.SendMessage(typeof(PluginMessageBlock).Name + " is currently not loaded"); return; } if (args.Length > 0) { if (args[0] == "+") { if (args.Length == 1) { Help(p); return; } if (args.Length == 2) { if (args[1] == "view") { if (p.Group.Permission < viewPermission) { p.SendMessage("Your are not allowed to use /mb + view"); return; } string[] ov = pmb.GetOverview(p.Level); for (int i = 0; i < ov.Length; i++) { p.SendMessage(ov[i]); } return; } else if (args[1] == "remove") { if (p.Group.Permission < createPermission) { p.SendMessage("Your are not allowed to use /mb + remove"); return; } p.OnPlayerBlockChange.Normal += remove_Normal; return; } } else if (args.Length == 3 && args[1] == "remove") { if (args[2] == "all") { if (p.Group.Permission < removeAllPermission) { p.SendMessage("You're not allowed to use /mb + all"); return; } int count = pmb.RemoveAll(p.Level); p.SendMessage(count + " message block" + (count == 1 ? "" : "s") + " removed"); return; } } else if (args.Length > 5) { ushort x, z, y; try { x = ushort.Parse(args[1]); z = ushort.Parse(args[2]); y = ushort.Parse(args[3]); } catch { p.SendMessage("Location could not be parsed"); return; } Level l = Level.FindLevel(args[4]); if (l == null) { p.SendMessage("Level is not loaded or does not exist"); return; } string message = String.Join(" ", args, 5, args.Length - 5); add(l, x, z, y, message, p); return; } Help(p); return; } else { string message = String.Join(" ", args); p.SetDatapass("MessageBlockMessage", message); p.OnPlayerBlockChange.Normal += add_Normal; } } }
public void Use(Player p, string[] args) { byte type = 0; byte type2 = 0; if (args.Length != 2) { p.SendMessage("Invalid arguments!"); Help(p); return; } if (!Block.ValidBlockName(args[0 | 1])) { p.SendMessage("Could not find block specified"); } //Block permissions here. CatchPos cpos = new CatchPos(); cpos.type = type; cpos.type2 = type2; p.SendMessage("Place two blocks to determine the edges."); p.OnPlayerBlockChange.Normal += new BlockChangeEvent.EventHandler(CatchBlock); p.SetDatapass("CmdReplaceNot_cpos", cpos); //p.CatchNextBlockchange(new Player.BlockChangeDelegate(CatchBlock), (object)cpos); }
public void Use(Player p, string[] args) { if (args.Length != 2) { p.SendMessage("Invalid number of arguments!"); Help(p); return; } CatchPos cpos = new CatchPos(); List<string> ignore; if (args[0].Contains(",")) ignore = new List<string>(args[0].Split(',')); else ignore = new List<string>() { args[0] }; ignore = ignore.Distinct().ToList(); // Remove duplicates List<string> invalid = new List<string>(); //Check for invalid blocks foreach (string name in ignore) if (!Block.ValidBlockName(name)) invalid.Add(name); if (!Block.ValidBlockName(args[1])) invalid.Add(args[1]); if (invalid.Count > 0) { p.SendMessage(String.Format("Invalid block{0}: {1}", invalid.Count == 1 ? "" : "s", String.Join(", ", invalid))); return; } if (ignore.Contains(args[1])) ignore.Remove(args[1]); if (ignore.Count < 1) p.SendMessage("Next time, just use cuboid if you're not going to ignore anything!"); cpos.ignore = new List<byte>(); foreach (string name in ignore) cpos.ignore.Add(Block.NameToBlock(name)); cpos.newType = Block.NameToBlock(args[1]); p.SendMessage("Place two blocks to determine the edges."); p.SetDatapass(this.Name, cpos); p.OnPlayerBlockChange.Normal += new Event<Player, BlockChangeEventArgs>.EventHandler(CatchBlock1); }