public void AddPlayer(String player, int entityId) { if (!IsStringInList(player, Player)) { Player.Add(player); UpdatePlayer(player, 1); foreach (IPlugin plugin in Plugins) { try { if (plugin.Enabled) { plugin.OnPlayerJoined(this, player); } } catch { Log.AppendText("Error Executing Plugin OnPlayerJoined()", Log.PluginLog); } } try { UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); User user = users.GetUserByName(player); user.LastEntityId = entityId; OnlineUsers.Add(user); } catch { Log.AppendText("Error Adding user at OnlineUsers OnPlayerJoined()", Log.ExceptionsLog); } } }
private void timerCurrency_Tick(object sender, EventArgs e) { if (mc.Config.CurrencySystemEnabled) { if (currencyTicker >= mc.Config.CurrencyCycleMinutes * 60) { currencyTicker = 0; UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); int amount = mc.Config.CurrencyAmountInCycle; if (Tunnel.IsConnected) { Tunnel.ServerSocket.SendServerMessage("§" + mc.Config.ResponseColorChar + mc.Config.ResponsePrefix + " " + mc.Config.CurrencyCycleMessage + " (" + amount + mc.Config.CurrencySymbol + ")"); } //mc.ExecuteSay(); foreach (User u in users.Items) { if (u.LevelID != 0) { if (mc.IsStringInList(u.Name, mc.Player)) { u.Balance += amount; } } } } currencyTicker++; } }
private void SaveToConfig() { //mc.Config.MakeBackup = chkMakeBackup.Checked; mc.Config.InternalPort = (int)numericInternalPort.Value; mc.Config.ExternalPort = (int)numericExternalPort.Value; //mc.Config.SplitterDistance = split.SplitterDistance; mc.Config.MainFormSize = this.Size; mc.Config.MainFormStartPosition = this.Location; mc.Config.SelectedTabIndex = this.tabNpcs.SelectedIndex; mc.Config.ChatListScroll = this.chkChatScroll.Checked; mc.Config.ServerTunnelActive = this.chkTunnelActive.Checked; mc.Config.Save(); UserCollectionSingletone.GetInstance().Save(); taskConfig.Save(); try { Log.AppendText(rtbConsole.Text, Log.ConsoleLogFile); } catch { } try { Log.AppendText(rtbServerClient.Text, Log.ChatMessageLogFile); } catch { } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (ClientUser.LevelID != 0) { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { long balance = ClientUser.Balance; long money = 0; try { money = Convert.ToInt64(arg2); } catch { } UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); User u = users.GetUserByName(match); if (u != null) { return(GiveMoney(u, money)); } } else { return(new CommandResult(true, String.Format("User <{0}> not found", arg1))); } } else { return(new CommandResult(true, String.Format("You don't have an account"))); } return(new CommandResult(true, String.Format("{0} execute by {1}", Name, TriggerPlayer))); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { try { int money = 500; try { money = Convert.ToInt32(arg1); } catch { } UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); foreach (User u in userCollection.Items) { if (ClientUser.LevelID != 0) { u.Balance = money; } } return(new CommandResult(true, String.Format("{0} has reset the giro accounts to §6{1} {2}", TriggerPlayer, money, MinecraftHandler.Config.CurrencySymbol))); } catch { Log.Append(this, "Exception while executing ClearCommands", Log.ExceptionsLog); return(new CommandResult(true, String.Format("Exception while executing ClearCommands"))); } }
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 void RemovePlayer(String player) { if (IsStringInList(player, Player)) { Player.Remove(player); UpdatePlayer(player, 0); foreach (IPlugin plugin in Plugins) { try { if (plugin.Enabled) { plugin.OnPlayerLeft(this, player); } } catch { Log.AppendText("Error Executing Plugin OnPlayerLeft()", Log.PluginLog); } } try { UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); OnlineUsers.Remove(users.GetUserByName(player)); } catch { Log.AppendText("Error Removing user at OnlineUsers OnPlayerLeft()", Log.ExceptionsLog); } } }
public CommandResult CommandHandlerExternal(String userName, String command, String args, ClientSocket client, ServerSocket server) { if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(command)) { return(null); } string username = userName; try { CommandManager helper = CommandManager.GetInstance(this); String commandMatch = EasyGuess.GetMatchedCommand(helper, command); if (String.IsNullOrEmpty(commandMatch)) { return(null); } Command c = helper.Items[commandMatch]; if (c != null) { UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); User user = userCollection.GetUserByName(userName); if (user == null) { user = new User(userName); } if (user != null && user.Level.IsCommandInList(commandMatch)) { string arg1 = "", arg2 = "", arg3 = ""; GetArgs(args, out arg1, out arg2, out arg3); c.ClientUser = user; c.RegArg = args; c.Client = client; c.Server = server; c.TriggerPlayer = userName; CommandResult result; if (arg1.Length > 0 && arg1[0] == '?') { result = c.ExecuteHelp(); } else { result = c.Execute(arg1, arg2, arg3, userName); } return(result); } } } catch {} return(new CommandResult()); }
private void btApply_Click(object sender, EventArgs e) { if (ValidateInput()) { user.WebUsername = tbWebUsername.Text; user.PasswordHash = HashProvider.GetHash(tbPassword.Text, HashProvider.SHA256); UserCollectionSingletone.GetInstance().Save(); Close(); } }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (!String.IsNullOrEmpty(arg1)) { IMinecraftHandler mc = MinecraftHandler; String match = EasyGuess.GetMatchedString(mc.Player, arg1); if (!String.IsNullOrEmpty(match)) { UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); User matchedPlayer = userCollection.GetUserByName(match); if (matchedPlayer != null) { GroupCollectionSingletone groups = GroupCollectionSingletone.GetInstance(); Group group = EasyGuess.GetMatchedGroup(groups, arg2); if (group != null) { if (ClientUser.LevelID >= matchedPlayer.LevelID && ClientUser.LevelID >= group.Id) // checks if the triggered user has a higher group level { matchedPlayer.LevelID = group.Id; // sets the rank to the user :) if (matchedPlayer.Generated) { matchedPlayer.Name = match; if (!userCollection.IsInlist(match)) { userCollection.Add(matchedPlayer); userCollection.Save(); } } return(new CommandResult(true, string.Format("player {0} set to group {1}", matchedPlayer.Name, group.Name))); } else { return(new CommandResult(true, string.Format("group level is too low {0} ID:{1}", ClientUser.Level.Name, ClientUser.LevelID))); } } else { return(new CommandResult(true, string.Format("couldn't find group {0}", arg2))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find the user {0}", match))); // give as much informations as you can } } else { return(new CommandResult(true, string.Format("couldn't find player {0}", arg1))); } }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { try { ConfigLotto config = ConfigLotto.Load(); LottoUserCollection _lottoUsers = XObject <LottoUserCollection> .Load(ConfigLotto.ConfigFolder + ConfigLotto.LottoFile); UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); return(new CommandResult(true, string.Format("The current Jackpot is §6{0} {1}", _lottoUsers.Jackpot, MinecraftHandler.Config.CurrencySymbol))); } catch { return(new CommandResult(true, string.Format("Lotto User list not found"))); } }
public void OnPluginLoaded(ICommandManager CommandManager, IMinecraftHandler mc) { this.mc = mc; CommandManager.RegisterCommand("lotto", new CommandLotto(mc)); CommandManager.RegisterCommand("jackpot", new CommandJackpot(mc)); ConfigLotto.ConfigFolder = Path.GetDirectoryName(startupPath) + Path.DirectorySeparatorChar; LottoUserCollection.Load().Save(); config = ConfigLotto.Load(); config.Save(); users = UserCollectionSingletone.GetInstance(); lottoEnabled = true; lottoThread = new Thread(new ThreadStart(LottoThread)); lottoThread.Start(); }
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); User user = UserCollectionSingletone.GetInstance().GetUserByName(match); if (!user.Generated) { if (ClientUser.LevelID >= zone.LevelID) { if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID) { if (MinecraftHandler.IsStringInList(user.Name, zone.Whitelist)) { zone.Whitelist.Remove(user.Name); return(new CommandResult(true, String.Format("{0} removed user {1} removed from zone {2}", TriggerPlayer, user.Name, zone.Name))); } else { return(new CommandResult(true, String.Format("User {0} is not in zone {1} whitelist", user.Name, zone.Name))); } } else { return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id"))); } } else { return(new CommandResult(true, String.Format("Insufficient permissions to set remove a player from whitelist"))); } } else { return(new CommandResult(true, String.Format("User not found: {0}", arg1))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { ServerSocket server = (ServerSocket)Server; String match = EasyGuess.GetMatchedString(MinecraftHandler.Player, arg1); if (!String.IsNullOrEmpty(match)) { User user = UserCollectionSingletone.GetInstance().GetUserByName(match); IClient client = Server.FindPlayer(match); if (client != null) { if (!user.Generated) { String message = RegArg.Substring(arg1.Length + 1); if (!String.IsNullOrEmpty(message)) { char lineColor = 'f'; if (server.FirstLine) { lineColor = MinecraftHandler.Config.LineFirstColorKey; } else { lineColor = MinecraftHandler.Config.LineSecondColorKey; } server.FirstLine = !server.FirstLine; if (MinecraftHandler.Config.ChannelModeChat) { server.SendChannelMessage(String.Format("§f<§{0}{1}§{2}> §{3}{4}", user.Level.GroupColor, user.Name, 'F', lineColor, message), (ClientSocket)client); } else { server.SendServerMessage(String.Format("§f<§{0}{1}§{2}> §{3}{4}", user.Level.GroupColor, user.Name, 'F', lineColor, message)); } } } } } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer), true)); }
/// <summary> /// Checks authentication with ZMA /// </summary> /// <param name="request"></param> /// <param name="session"></param> private void Authenticate(IHttpRequest request, IHttpSession session) { if (request.Param["login"].Value != null) { if (!webLogin.ContainsKey(session.Id)) { webLogin.Add(session.Id, false); } String username = request.Param["username"].Value; String password = request.Param["password"].Value; var userlist = UserCollectionSingletone.GetInstance(); var user = userlist.GetUserByLogin(username); // First check if we have access and the if we can login :-) // I use SHA256 with salt so avoid using other authentications if (!user.Generated && user.HasWebAccess && HashProvider.GetHash(password, HashProvider.SHA256) == user.PasswordHash) { webLogin[session.Id] = true; } } }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { var mc = MinecraftHandler; List <String> playerList = MinecraftHandler.Player; StringBuilder builder = new StringBuilder(); List <String> lines = new List <string>(); builder.AppendFormat("Online: {0} ", playerList.Count); if (playerList.Count > 0) { for (int i = 0; i < playerList.Count; i++) { String player = playerList[i]; User u = UserCollectionSingletone.GetInstance().GetUserByName(player); if (builder.Length + player.Length + mc.Config.ResponsePrefix.Length < 70) { builder.AppendFormat("§f<§{0}{1}§f> ", u.Level.GroupColor, player); } else { lines.Add(builder.ToString()); builder = new StringBuilder(); i--; } } } if (builder.Length + mc.Config.ResponsePrefix.Length <= 70) { lines.Add(builder.ToString()); } //MinecraftHandler.ExecuteSay(result); foreach (String line in lines) { Server.SendExecuteResponse(TriggerPlayer, line); } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer))); }
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); User user = UserCollectionSingletone.GetInstance().GetUserByName(match); if (user.Generated) { user = new User(TriggerPlayer, false); user.LevelID = 0; UserCollectionSingletone.GetInstance().Add(user); UserCollectionSingletone.GetInstance().Save(); } if (TriggerPlayer == zone.Owner || ClientUser.LevelID > zone.LevelID) { if (!MinecraftHandler.IsStringInList(user.Name, zone.Whitelist)) { zone.Whitelist.Add(user.Name); return(new CommandResult(true, String.Format("{0} has added user {1} to Zone {2}", TriggerPlayer, user.Name, zone.Name))); } else { return(new CommandResult(true, String.Format("User {0} is allready in Zone {1}", user.Name, zone.Name))); } } else { return(new CommandResult(true, String.Format("You cannot whitelist, you need to be the owner or have an higher id"))); } } else { return(new CommandResult(true, String.Format("Zone not found: {0}", arg1))); } }
void MinecraftHandler_PlayerJoined(object sender, string player) { User user = UserCollectionSingletone.GetInstance().GetUserByName(player); if (user.Generated) { user = new User(player, false); user.LevelID = 0; UserCollectionSingletone.GetInstance().Add(user); UserCollectionSingletone.GetInstance().Save(); } List <Channel> channels = Channels.FindAll(x => x.User.IsInlist(player)); if (channels.Count <= 0) { defaultChannel.User.Add(user); if (Tunnel.MinecraftHandler.Config.ChannelModeChat) { SendExecuteResponse(player, "You joined the default channel"); } } }
public override CommandResult Execute(String chan, String pw, String arg3, String arg4) { if (!String.IsNullOrEmpty(chan)) { if (chan.Length <= 12 && chan.Length >= 3 || chan.Length == 1 && chan[0] == '*') { ServerSocket server = (ServerSocket)Server; if (ClientUser.Generated) { ClientUser = new User(TriggerPlayer, false); UserCollectionSingletone.GetInstance().Add(ClientUser); UserCollectionSingletone.GetInstance().Save(); } Channel channel = server.Channels.Find(chan); // check if a channel exists or creates a new if (channel == null) { if (String.IsNullOrEmpty(pw)) // if has a password creates a channel with password :) { channel = new Channel(chan); // create new without password } else { channel = new Channel(chan, pw); // create with password } server.Channels.AddChannel(channel); // add user to channel } if (channel.User.IsInlist(ClientUser)) { return(new CommandResult(false, String.Format("You're already in this channel", TriggerPlayer, channel.Name), true)); } if (channel.RequiresPassword) { if (String.IsNullOrEmpty(pw)) { return(new CommandResult(true, String.Format("{0} requires a password", channel.Name), true)); // no pw as argument so we are out here :) } else { // we have a password lets check it if (channel.Password == pw) { channel.User.Add(ClientUser); return(new CommandResult(true, String.Format("{0} joined channel {1}", TriggerPlayer, channel.Name))); } else { // password is wrong :( return(new CommandResult(true, String.Format("Password for channel {0} is wrong", channel.Name), true)); } } } else { // no pw so we are ok //ClientUser.Channels.AddChannel(channel); if (!channel.User.IsInlist(ClientUser)) { channel.User.Add(ClientUser); return(new CommandResult(true, String.Format("{0} joined channel {1}", TriggerPlayer, channel.Name))); } else { return(new CommandResult(true, String.Format("You're already in this channel", TriggerPlayer, channel.Name), true)); //return new CommandResult(true, null); } } } else { // channel name length must be between 3 and 12 return(new CommandResult(true, String.Format("Channel name length must be between 3 and 12"), true)); } } else { return(new CommandResult(true, String.Format("Unknown Argument"), true)); } }
public void GetCommands(MinecraftHandler mc, LockFreeQueue <WebActionCommand> webCommands) { try { if (mc.Started && mc.Config.StreamEnabled) { String guid = mc.Config.GuidString; MySqlCommand command = connection.CreateCommand(); String sql = String.Format( "SELECT * FROM zma_app.zma_web_queue w WHERE w.server_guid = '{0}';" , guid); command.CommandText = sql; MySqlDataReader reader = command.ExecuteReader(); List <int> ids = new List <int>(); int id = -1; while (reader.Read()) { id = reader.GetInt32("id"); WebActionType type = WebActionType.None; type = (WebActionType)reader.GetInt32("type"); string message = ""; message = reader.GetString("message"); UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); String userName = ""; try { userName = reader.GetString("name"); } catch { } if (id >= 0) { ids.Add(id); } User user = users.GetUserByName(userName); if (type == WebActionType.Chat && id >= 0 && !user.Generated) { WebActionCommand cmd = new WebActionCommand(id, type, message, user, this); webCommands.Enqueue(cmd); } } reader.Close(); foreach (int i in ids) { command.CommandText = String.Format("DELETE FROM zma_app.zma_web_queue WHERE id = {0};", i); command.ExecuteNonQuery(); } } } catch (Exception ex) { Log.Append(this, "GetCommands " + ex.Message, Log.ExceptionsLog); } }
public void UpdatePlayer(MinecraftHandler mc, String playerName, int isOnline) { if (mc.Config.StreamEnabled) { try { string name = mc.Config.ServerName; String guid = mc.Config.GuidString; int id = GetServerId(guid); int online = isOnline; int secondsOnline = mc.SecondsOnline; //int playersMax = 100; int playersOnline = mc.Player.Count; string ip = mc.Config.ExternalIp; int port = mc.Config.ExternalPort; DateTime dt = DateTime.Now; UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); User u = users.GetUserByName(playerName); int hasWebAccess = u.HasWebAccess ? 1 : 0; if (u.Generated) { hasWebAccess = 0; } if (!IsInTable("zma_players", "name", playerName)) { String query = String.Format("INSERT INTO zma_players " + "(is_online,name,seconds_online,date_last_online, fk_server_id, web_login, web_password, has_web_access,fk_web_server_guid) " + "VALUES ({0},'{1}',{2}, {3},{4},'{5}',MD5('{6}'),{7},{8});", online, playerName, secondsOnline, "NOW()", id, u.WebUsername, u.PasswordHash, hasWebAccess, id ); ExecuteSQL(query); } else { String query = String.Format("UPDATE zma_players SET " + "seconds_online = {0} ," + "date_last_online = {1}, " + "is_online = {2}, " + "fk_server_id = {3}, " + "web_login = '******', " + "web_password = MD5('{5}'), " + "has_web_access = {6}, " + "fk_web_server_guid = {7} " + "WHERE name = '{8}';", secondsOnline, "NOW()", online, id, u.WebUsername, u.PasswordHash, hasWebAccess, id, playerName ); ExecuteSQL(query); } } catch (Exception ex) { Log.Append(this, ex.Message, Log.ExceptionsLog); } } }
public LottoUser() { UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); }
/// <summary> /// this is the execution method which gets executed later /// to get more arguments use the internal regArgs variable /// </summary> /// <param name="arg1">first argument after the command in the string</param> /// <param name="arg2">second argument after the command in the string</param> /// <param name="arg3">third argument after the command in the string</param> /// <param name="arg4">fourth argument after the command in the string</param> /// <returns>remember to set the command result in every return case</returns> public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { try { ConfigLotto config = ConfigLotto.Load(); LottoUserCollection _lottoUsers = XObject <LottoUserCollection> .Load(ConfigLotto.ConfigFolder + ConfigLotto.LottoFile); UserCollectionSingletone users = UserCollectionSingletone.GetInstance(); if (ClientUser != null && ClientUser.LevelID != 0) { if (!_lottoUsers.IsInList(TriggerPlayer)) { if (ClientUser.Balance >= config.Price) { try { ClientUser.Balance -= config.Price; int zahl = Convert.ToInt32(arg1); if (zahl >= config.Min && zahl <= config.Max) { LottoUser lottouser = new LottoUser(TriggerPlayer, zahl); _lottoUsers.Add(lottouser); _lottoUsers.Jackpot += config.Price; _lottoUsers.Save(); Server.SendExecuteResponse(TriggerPlayer, string.Format("§{0}Your lucky number is §6{1}", MinecraftHandler.Config.ResponseColorChar, zahl)); return(new CommandResult(true, string.Format("{0} participates lotto!", TriggerPlayer))); } else { Server.SendExecuteResponse(TriggerPlayer, string.Format("Number must be between {0} - {1}", config.Min, config.Max)); } } catch { Server.SendExecuteResponse(TriggerPlayer, string.Format("Entered a wrong number!")); } } else { Server.SendExecuteResponse(TriggerPlayer, string.Format("Not enough money!")); } } else { Server.SendExecuteResponse(TriggerPlayer, string.Format("Allready participated!")); } } else { Server.SendExecuteResponse(TriggerPlayer, string.Format("You have no giro account!")); } } catch { Server.SendExecuteResponse(TriggerPlayer, string.Format("Lotto User list not found")); } return(new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer))); }
public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4) { if (!String.IsNullOrEmpty(arg1)) { UserCollectionSingletone userlist = UserCollectionSingletone.GetInstance(); if (arg1[0] == '*') { if (arg1 == "*true") { foreach (User u in userlist.Items) { if (ClientUser != u) { u.AllowChat = false; } } Server.SendServerMessage(String.Format("Every player has been muted except {0}", TriggerPlayer)); } if (arg1 == "*false") { foreach (User u in userlist.Items) { if (ClientUser != u) { u.AllowChat = true; } } Server.SendServerMessage(String.Format("Every player has been unmuted except {0}", TriggerPlayer)); } } else { List <String> playerlist = MinecraftHandler.Player; string match = EasyGuess.GetMatchedString(playerlist, arg1); if (!String.IsNullOrEmpty(match)) { User user = userlist.GetUserByName(match); if (user.Generated) { user.Generated = false; userlist.Add(user); user.AllowChat = false; userlist.Save(); return(new CommandResult(true, string.Format("{0} has muted {1}", TriggerPlayer, match))); } else { user.AllowChat = !user.AllowChat; userlist.Save(); if (user.AllowChat) { return(new CommandResult(true, string.Format("{0} has unmuted {1}", TriggerPlayer, match))); } else { return(new CommandResult(true, string.Format("{0} has muted {1}", TriggerPlayer, match))); } } } } } return(new CommandResult(true, string.Format("user not found {0}", arg1))); }
public CommandResult ActionCommand(String message, User user, String remoteName) { bool tunnelMessage = true; string text = message; MinecraftHandler mc = Tunnel.MinecraftHandler; String name = user.Name; List <String> players = mc.Player; UserCollectionSingletone userCollection = UserCollectionSingletone.GetInstance(); CommandResult cmdResult = new CommandResult(false, ""); if (text.Length > 0) { if (text[0] == mc.Config.CommandChar[0]) { string commandRegexPattern = String.Format(@"{0}(?<cmd>[a-zA-Z]+) ?(?<arg1>.+)?", mc.Config.CommandChar); Regex commandRegex = new Regex(commandRegexPattern); Match match = commandRegex.Match(text); string regCommand = ""; string regArg1 = ""; if (match.Success) { try { tunnelMessage = false; regCommand = match.Groups["cmd"].Value; regArg1 = match.Groups["arg1"].Value; if (mc != null && mc.Started) { cmdResult = mc.CommandHandlerExternal(name, regCommand, regArg1, null, this); if (cmdResult != null && cmdResult.HasResult) { if (mc.Config.CommandExecutedResponse) { if (user.Level.OwnExecuteResponse) { SendExecuteResponse(user.Name, cmdResult.Message); } foreach (User u in userCollection.Items) { if (user != u) { if (u.Level.OtherExecuteResponse) { if (mc.IsStringInList(u.Name, players)) { SendExecuteResponse(u.Name, cmdResult.Message); } } } } } } else { SendExecuteResponse(name, String.Format("Unknown command {0}", text)); } } } catch (Exception ex) { SendExecuteResponse(name, String.Format("Exception while executing ask Zicore :)", text)); Log.AppendText(ex.Message, Log.ExceptionsLog); } } } } if (tunnelMessage && text[0] != '/') { tunnelMessage = false; char lineColor = 'f'; if (FirstLine) { lineColor = mc.Config.LineFirstColorKey; } else { lineColor = mc.Config.LineSecondColorKey; } FirstLine = !FirstLine; SendServerMessage(String.Format("§f<§{0}{1}§{2} [§6{3}§f]> §{4}{5}", user.Level.GroupColor, name, 'F', remoteName, lineColor, text)); //ZmaSQLConnection sql = new ZmaSQLConnection(); //sql.AddChatMessage(name, text, mc); } return(cmdResult); }