public override void BroadcastMessage(string text, MessageType type = MessageType.Chat, MiNET.Player sender = null, MiNET.Player[] sendList = null, bool needsTranslation = false, string[] parameters = null) { if (type == MessageType.Chat || type == MessageType.Raw) { foreach (var line in text.Split(new[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string sen = sender == null ? "" : (sender.DisplayName ?? sender.Username) + ": "; McpeText message = McpeText.CreateObject(); message.type = 0; message.source = ""; //sender == null ? "" : (sender.DisplayName ?? sender.Username); message.message = $"{sen}{line}"; //message.parameters = new string[0]; // message.islocalized = false; RelayBroadcast(sendList, message); } return; } else { McpeText message = McpeText.CreateObject(); message.type = (byte)type; message.source = sender == null ? "" : sender.Username; message.message = text; // message.parameters = new string[0]; // message.islocalized = false; RelayBroadcast(sendList, message); } }
public override void HandleMcpeText(McpeText message) { if (!PlayerData.isAuth) { return; } DateTime now = DateTime.UtcNow; if ((now - PlayerData.ActionTime) < s500) { return; } PlayerData.ActionTime = DateTime.UtcNow; if (PlayerData.muted) { if ((long)PlayerData.mute_time > Database.UnixTime()) { long mute = (long)PlayerData.mute_time - Database.UnixTime(); SendMessage(string.Format(PlayerData.lang.get("bm.mute.blocking"), mute)); return; } else { SendMessage(PlayerData.lang.get("bm.mute.unlocking")); PlayerData.muted = false; PlayerData.mute_time = 0; } } string chatFormat = $"[{ChatColors.Yellow}" + PlayerData.DataValue["lvl"] + $"{ChatColors.White}]{ChatColors.Gray}[" + PlayerData.prefix + $"{ChatColors.Gray}]{ChatColors.White}" + Username + " : §r" + message.message; Level.BroadcastMessage(chatFormat); return; }
public Package ChatHandler(McpeText text, Player player) { if (text.message.StartsWith("/") || text.message.StartsWith(".")) return text; player.Level.BroadcastTextMessage((" � + player.Username + "� " + text.message), null, MessageType.Raw); return null; }
public override void HandleMcpeText(McpeText message) { if (Log.IsDebugEnabled) { Log.Debug($"Text: {message.message}"); } string text = message.message; if (string.IsNullOrEmpty(text)) { return; } var wantExec = _executioners.Where(e => e.CanExecute(text)); foreach (var executioner in wantExec) { Log.Debug($"Executing command handler: {executioner.GetType().FullName}"); Task.Run(() => executioner.Execute(this, text)); } if (text.Equals(".do")) { Client.SendCraftingEvent(); } }
public Packet MessageHandler(McpeText message, Player player) { string text = TextUtils.RemoveFormatting(message.message); player.Level.BroadcastMessage($"{GetNameTag(player)} says:{ChatColors.White} {text}", MessageType.Chat); return(null); }
private void OnMcpeText(McpeText message) { Log.Debug($"Text: {message.message}"); if (message.message.Equals(".do")) { SendCraftingEvent(); } }
public void OnChat(McpeText packet, Player player) { switch (packet.message) { case "run": //run(player); break; } }
public void SendChat(string text) { var packet = new McpeText() { source = Username, message = text }; SendPackage(packet); }
public void SendMessage(string text, Player sender = null, byte type = McpeText.TypeChat) { foreach (var line in text.Split('\n')) { McpeText message = McpeText.CreateObject(); message.type = type; message.source = sender == null ? "MiNET" : sender.Username; message.message = line; SendPackage(message); } }
public override void HandleMcpeText(McpeText message) { if (Log.IsDebugEnabled) { Log.Debug($"Text: {message.message}"); } if (message.message.Equals(".do")) { Client.SendCraftingEvent(); } }
public virtual void BroadcastMessage(string text, MessageType type = MessageType.Chat, Player sender = null) { foreach (var line in text.Split('\n')) { McpeText message = McpeText.CreateObject(); message.type = (byte)type; message.source = sender == null ? "" : sender.Username; message.message = line; RelayBroadcast(message); } }
/// <summary> /// Handles the message. /// </summary> /// <param name="message">The message.</param> private void HandleMessage(McpeText message) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { Server.PluginManager.HandleCommand(Server.UserManager, text, this); } else { Level.BroadcastTextMessage(text, this); } }
public Package MessageHandler(McpeText message, Player player) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { return(message); } text = TextUtils.RemoveFormatting(text); player.Level.BroadcastMessage($"{GetNameTag(player)}:{ChatColors.White} {text}", MessageType.Raw); return(null); }
public Package MessageHandler(McpeText message, MiNET.Player player) { string text = message.message; if (text.StartsWith("/")) { return(message); } if (player is SkyPlayer skyPlayer && skyPlayer.Level is GameLevel level) { level.CurrentState.HandlePlayerChat(skyPlayer, text); } return(null); }
public Package MessageHandler(McpeText message, Player player) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { return(message); } text = TextUtils.RemoveFormatting(text); player.Level.BroadcastMessage($"{GetNameTag(player)}:{ChatColors.White} {text}", MessageType.Raw); var leaveSound = new AnvilFallSound(player.Level.SpawnPoint.ToVector3()); leaveSound.Spawn(player.Level); return(null); }
//[EventAttribute(Type = typeof(EventHandler<PlayerChatEventArgs>))] //[EventAttribute(Type = typeof(PlayerChatEventArgs))] public override void HandleMcpeText(McpeText message) { //base.HandleMcpeText(message); Stopwatch watch = new Stopwatch(); watch.Start(); if (message.type == (byte)McpeText.ChatTypes.Chat) { PlayerChatEventArgs chatEvent = new PlayerChatEventArgs(this, message.message, null); if (chatEvent.OnCallEvent()) { //Level.BroadcastMessage(chatEvent.GetMessage()); base.HandleMcpeText(message); } } watch.Stop(); Console.WriteLine(message.GetType() + " в Тиках :" + watch.ElapsedTicks + "\r\n"); Console.WriteLine(message.GetType() + " в MS :" + watch.ElapsedMilliseconds + "\r\n"); }
/// <summary> /// Handles incoming chat messages /// </summary> /// <param name="message"></param> public override void HandleMcpeText(McpeText message) { string text = message.message; if (string.IsNullOrEmpty(text)) { return; } PlayerChatEvent chatEvent = new PlayerChatEvent(this, text); EventDispatcher.DispatchEventAsync(chatEvent).Then(result => { if (result.IsCancelled) { return; } Level.BroadcastMessage(chatEvent.Message, sender: this); }); }
public virtual void BroadcastMessage(string text, MessageType type = MessageType.Chat, Player sender = null, Player[] sendList = null) { if (type == MessageType.Chat || type == MessageType.Raw) { foreach (var line in text.Split(new string[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { McpeText message = McpeText.CreateObject(); message.type = (byte)type; message.source = sender == null ? "" : sender.Username; message.message = line; RelayBroadcast(sendList, message); } } else { McpeText message = McpeText.CreateObject(); message.type = (byte)type; message.source = sender == null ? "" : sender.Username; message.message = text; RelayBroadcast(sendList, message); } }
public Package OnPlayerSendMessage(McpeText packet, Player player) { var userManager = Context.Server.UserManager; var user = userManager.FindByNameAsync(player.Username).Result; if (user != null) { if (user.IsAuthenticated) { if (userManager.CheckPasswordAsync(user, packet.message).Result) { user.IsAuthenticated = true; userManager.UpdateAsync(user); player.SendMessage("you has been Logged"); } else { player.SendMessage($"{ChatColors.Green}Check your password again,that have some error!"); } packet.message = null; return packet; } else { return packet; } } else if (packet.message.StartsWith("/reg")) { return packet; } else { player.SendMessage($"{ChatColors.Green}Plz Register frist!"); packet.message = null; return packet; } }
public Package ChatHandler(McpeText text, Player player) { if (text.message.StartsWith("/") || text.message.StartsWith(".")) { return(text); } PlayerData user = Pool.getPlayer(player.Username); if (user == null || !AuthME.isAuthenticated(player)) { Log.Info("chat1"); return(null); } if (user.muted) { if ((long)user.mute_time > Database.UnixTime()) { long mute = (long)user.mute_time - Database.UnixTime(); player.SendMessage("[✘] Вы заблокированы в чате на " + mute + " секунд\n[✘] You are locked in a chat with " + mute + " seconds"); return(null); } else { player.SendMessage("[v] Вас разблокировали в чате!"); Pool.editPlayer(player.Username, "muted", "no"); Pool.editPlayer(player.Username, "mute_time", "", 0); } } string chatFormat = "{COLOR_GRAY}[" + user.prefix + "{COLOR_GRAY}]{COLOR_WHITE}{user_name} : {message}"; chatFormat = chatFormat.Replace("{user_name}", player.Username); chatFormat = addColors(chatFormat); chatFormat = chatFormat.Replace("{message}", text.message); player.Level.BroadcastMessage(chatFormat); return(null); }
public Package HandleCommand(McpeText packet, Player player) { var msg = packet.message; if (msg.First() != '!') { return(packet); } var commands = this.Context.PluginManager.Commands.ToList(); msg = msg.Remove(0, 1); if (string.IsNullOrWhiteSpace(msg)) { return(packet); } var msgs = msg.Split(' ').ToList(); var targetCommand = msgs[0]; var targetCommandArgs = new List <string>(); if (msgs.Count > 1) { msgs.Remove(msgs[0]); targetCommandArgs = msgs; } string overloadKey = null; JObject commandInputJson = null; if (commands.Exists(x => x.Key == targetCommand)) { var command = commands.Find(x => x.Key == targetCommand); var commandArgNames = new List <string>(); if (targetCommandArgs.Count > 0) { var targetCommandArgTypes = new List <string>(); foreach (var arg in targetCommandArgs) { targetCommandArgTypes.Add(GetArgType(arg)); } targetCommandArgTypes.Sort(); foreach (var overload in command.Value.Versions.First().Overloads) { var commandArgTypes = new List <string>(); foreach (var parameter in overload.Value.Method.GetParameters()) { if (parameter.ParameterType == typeof(Player)) { continue; } commandArgTypes.Add(GetParameterType(parameter)); commandArgNames.Add(parameter.Name); } commandArgTypes.Sort(); if (targetCommandArgTypes.SequenceEqual(commandArgTypes)) { overloadKey = overload.Key; commandInputJson = JObject.Parse(ConvertJson(commandArgNames, targetCommandArgs)); } commandArgNames.Clear(); } if (overloadKey == null) { player.SendMessage($"{ChatColors.Yellow}명령어가 존재하지 않아요!"); return(null); } } else { overloadKey = "default"; } } else { player.SendMessage($"{ChatColors.Yellow}명령어가 존재하지 않아요!"); return(null); } this.Context.PluginManager.HandleCommand(player, targetCommand, overloadKey, commandInputJson); return(null); }
protected virtual void HandleMessage(McpeText message) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { Server.PluginManager.HandleCommand(Server.UserManager, text, this); } else { text = TextUtils.Strip(text); Level.BroadcastMessage(text, sender: this); } }
public virtual void HandleMcpeText(McpeText message) { }
public Package MessageHandler(McpeText message, Player player) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { return message; } text = TextUtils.RemoveFormatting(text); player.Level.BroadcastMessage($"{GetNameTag(player)}:{ChatColors.White} {text}", MessageType.Raw); return null; }
public override void HandleMcpeText(McpeText message) { }
public void HandleMcpeText(McpeText message) { WritePackage(message); }
/// <summary> /// Handles the message. /// </summary> /// <param name="message">The message.</param> private void HandleMessage(McpeText message) { string text = message.message; if (text.StartsWith("/") || text.StartsWith(".")) { _pluginManager.HandleCommand(Server.UserManager, text, this); } else { Level.BroadcastTextMessage(text, this); } }
public override void HandleMcpeText(McpeText message) { BaseClient.WorldProvider?.GetChatReceiver?.Receive(new ChatObject(message.message)); }
public abstract void HandleMcpeText(McpeText message);
public void HandleMcpeText(McpeText message) { }