void add(Level l, ushort x, ushort z, ushort y, string message, Player sender) { PluginMessageBlock pmb = (PluginMessageBlock)Plugin.getByType(typeof(PluginMessageBlock).Name); if (pmb == null) { Logger.Log(typeof(PluginMessageBlock).Name + " is currently not loaded"); sender.SendMessage(typeof(PluginMessageBlock).Name + " is currently not loaded"); return; } if (message.StartsWith("/") && sender.Group.Permission >= commandBlockPermission) { message = "c:" + sender.Group.Permission + ":" + message.ToHexString(); } else { message = "m" + message; } if (pmb.Add(l, new Vector3S(x, z, y), message)) { sender.SendMessage("Message block added"); } else { sender.SendMessage("Message block updated"); } }
void remove_Normal(Player sender, BlockChangeEventArgs args) { sender.OnPlayerBlockChange.Normal -= remove_Normal; args.Cancel(); Vector3S v = new Vector3S(args.X, args.Z, args.Y); PluginMessageBlock pmb = (PluginMessageBlock)Plugin.getByType(typeof(PluginMessageBlock).Name); if (pmb == null) { sender.SendMessage(typeof(PluginMessageBlock).Name + " is currently not loaded"); return; } if (pmb.Remove(sender.Level, v)) { sender.SendMessage("Message block removed"); } else { sender.SendMessage("There was already no message set for this block"); } }
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; } } }