public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); coll.Load(); if (arg2.ToLower() == "p1" || arg2.ToLower() == "p2") { Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { if (arg2 == "p1") { zone.Position1 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false); coll.Save(); return(new CommandResult(true, string.Format("{0} set zone {1} position 1", TriggerPlayer, zone.Name))); } if (arg2 == "p2") { zone.Position2 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false); coll.Save(); return(new CommandResult(true, string.Format("{0} set zone {1} position 2", TriggerPlayer, zone.Name))); } } else { return(new CommandResult(true, string.Format("{0} zone not found", arg1))); } } else if (!String.IsNullOrEmpty(arg1)) { Zone zone = ZoneCollectionSingletone.GetInstance().GetZoneByName(arg1); if (zone == null) { zone = new Zone(arg1); if (!MinecraftHandler.IsStringInList(TriggerPlayer, zone.Whitelist)) { zone.Whitelist.Add(TriggerPlayer); } zone.LevelID = ClientUser.LevelID; zone.Owner = TriggerPlayer; zone.Position1 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false); zone.Position2 = new MinecraftWrapper.Player.XPosition((int)Client.Position.X, (int)Client.Position.Y, (int)Client.Position.Z, 0, 0, 0, false); coll.Add(zone); coll.Save(); return(new CommandResult(true, string.Format("{0} created zone {1}", TriggerPlayer, arg1))); } else { return(new CommandResult(true, string.Format("Zone {0} is allready in use", zone.Name))); } } return(new CommandResult()); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { try { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { if (ClientUser.LevelID > zone.LevelID || TriggerPlayer == zone.Owner) { String name = zone.Name; coll.Items.Remove(zone); coll.Save(); return(new CommandResult(true, String.Format("Zone {0} removed by {1}", name, TriggerPlayer))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to delete a zone"))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } } catch { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { if (!String.IsNullOrEmpty(arg1)) { if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID) { String message = RegArg.Substring(arg1.Length).Trim(); zone.WelcomeMessage = message; coll.Save(); return(new CommandResult(true, String.Format("Zone-Message of zone {0} is now {1}", zone.Name, message))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to set the message"))); } } else { return(new CommandResult(true, String.Format("Zone-Message is empty"))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { StringBuilder builder = new StringBuilder(); if (zone.Whitelist.Count > 0) { builder.AppendFormat("Whitelist: ", zone.Name); foreach (String player in zone.Whitelist) { User u = UserCollectionSingletone.GetInstance().GetUserByName(player); builder.AppendFormat("§f<§{0}{1}§f> ", u.Level.GroupColor, player); } String result = builder.ToString(); if (!String.IsNullOrEmpty(result)) { Server.SendExecuteResponse(TriggerPlayer, result); } coll.Save(); } return(new CommandResult(true, String.Format("Zone Whitelist executed by {0}", TriggerPlayer))); } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg2); if (!String.IsNullOrEmpty(match)) { if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID) { zone.Owner = match; coll.Save(); return(new CommandResult(true, String.Format("Zone-Owner of zone {0} is now {1}", zone.Name, match))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to set the owner"))); } } else { return(new CommandResult(true, String.Format("User not found {0}", match))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ZoneCollectionSingletone coll = ZoneCollectionSingletone.GetInstance(); Zone zone = EasyGuess.GetMatchedZone(coll, arg1); if (zone != null) { int level = 0; if (int.TryParse(arg2, out level)) { if (TriggerPlayer == ClientUser.Name || ClientUser.LevelID > zone.LevelID) { int setLevel = 0; if (ClientUser.Level.BlockLevel < level || level < 0) { setLevel = ClientUser.Level.BlockLevel; } else { setLevel = level; } coll.Save(); return(new CommandResult(true, String.Format("Zone-Level of zone {0} is now {1}", zone.Name, setLevel))); } else { return(new CommandResult(true, String.Format("Insufficient permissions to set the blocklevel"))); } } else { return(new CommandResult(true, String.Format("Invalid blocklevel {0}", arg2))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
private void btOK_Click(object sender, EventArgs e) { _zoneCollection.Save(); }