public virtual void HandlePlayerChat(SkyPlayer player, string message) { if (PunishCore.GetPunishmentsFor(player.CertificateData.ExtraData.Xuid).HasActive(PunishmentType.Mute)) { player.SendMessage("§c§l(!)§r §cYou cannot chat while you are muted."); return; } message = TextUtils.RemoveFormatting(message); if (message.Length > 200) { player.SendMessage("§c§l(!)§r §cYour message is too long, please shorten it."); return; } /*foreach (char character in message) * { * if (!char.IsLetterOrDigit(character) && !char.IsPunctuation(character) && !char.IsSymbol(character)) * { * player.SendMessage("§c§l(!)§r §cYour message contains invalid characters!"); * return; * } * }*/ string chatColor = ChatColors.White; if (player.PlayerGroup == PlayerGroup.Player) { chatColor = ChatColors.Gray; } player.Level.BroadcastMessage($"{player.GetNameTag(player)}{ChatColors.Gray}: {chatColor}{message}", MessageType.Raw); }
private static void RunPunishmentCommand(MiNET.Player player, PunishmentType punishmentType, String playerName, string[] args) { string targetXuid = StatisticsCore.GetXuidForPlayername(playerName); if (targetXuid == null) { player.SendMessage($"§f[PUNISH] §7{playerName} §cis not a Skytonia user."); return; } args = ParseExpiryTime(player, args, out DurationUnit durationUnit, out int durationAmount); if (args == null) { return; //Message printed to player } string punishReason = GetReasonFromArgs(args); DateTime expiry = UpdateExpiryTime(durationUnit, durationAmount); Punishment punishment = new Punishment(punishReason, player.CertificateData.ExtraData.Xuid, true, durationAmount, durationUnit, expiry); PunishCore.AddPunishment(targetXuid, punishmentType, punishment); if (punishmentType == PunishmentType.Ban) { SkyPlayer target = SkyCoreAPI.Instance.GetPlayer(playerName); if (durationUnit == DurationUnit.Permanent) { player.SendMessage($"§f[PUNISH] §7{playerName} §chas been banned permanently for: \"{punishReason}\""); target?.Disconnect(PunishmentMessages.GetPunishmentMessage(target, punishmentType, punishment)); } else { player.SendMessage($"§f[PUNISH] §7{playerName} §chas been banned for: §f{GetNeatDuration(durationAmount, durationUnit)} \"{punishReason}\""); target?.Disconnect(PunishmentMessages.GetPunishmentMessage(target, punishmentType, punishment)); } } else if (punishmentType == PunishmentType.Mute) { SkyPlayer target = SkyCoreAPI.Instance.GetPlayer(playerName); if (durationUnit == DurationUnit.Permanent) { player.SendMessage($"§f[PUNISH] §7{playerName} §chas been muted permanently for: \"{punishReason}\""); target?.SendMessage(PunishmentMessages.GetPunishmentMessage(target, PunishmentType.Mute, punishment)); } else { player.SendMessage($"§f[PUNISH] §7{playerName} §chas been muted for: §f{GetNeatDuration(durationAmount, durationUnit)} \"{punishReason}\""); target?.SendMessage(PunishmentMessages.GetPunishmentMessage(target, PunishmentType.Mute, punishment)); } } }
/*[Command(Name = "gameedit")] * [Authorize(Permission = CommandPermission.Normal)] * public void CommandGameEdit(MiNET.Player player, params string[] args) * { * if (player.CommandPermission < CommandPermission.Admin) * { * player.SendMessage("§c§l(!)§r §cYou do not have permission for this command."); * return; * } * * if (!(player.Level is GameLevel level)) * { * player.SendMessage($"§cYou must be in a {GameName} game to use this command!"); * return; * } * * if (!(level.GameLevelInfo is GameLevelInfo gameLevelInfo)) * { * player.SendMessage("§cThe current level's information could not be loaded."); * return; * } * * if (args[0].Equals("timeleft")) * { * if (args.Length < 2) * { * player.SendMessage("§c/gameedit timeleft <time>"); * return; * } * * if (!int.TryParse(args[1], out var timeRemaining)) * { * player.SendMessage($"§cInvalid time remaining ({args[1]})"); * return; * } * * level.Tick = 0; * ((RunningState)level.CurrentState).EndTick = timeRemaining * 2; * * player.SendMessage($"§eReset in-game timer, and updated end-time to {timeRemaining} seconds"); * } * else if (args[0].Equals("level")) * { * if (args.Length < 2) * { * player.SendMessage("§c/gameedit level <levelname>"); * return; * } * * string fullyQualifiedName = $"C:\\Users\\Administrator\\Desktop\\worlds\\{RawName}\\{args[1]}"; * GameLevel gameLevel; * if (!LevelNames.Contains(fullyQualifiedName) || (gameLevel = InitializeNewGame(fullyQualifiedName)) == null) * { * player.SendMessage($"§cInvalid level name ({args[1]})"); * player.SendMessage($"§cBad Args: \n§c- {string.Join("\n§c- ", LevelNames.Select(x => _removeQualification(x.ToString())).ToArray())}"); * return; * } * * foreach (SkyPlayer gamePlayer in level.GetAllPlayers()) * { * gameLevel.AddPlayer(gamePlayer); * } * * level.UpdateGameState(new VoidGameState()); //'Close' the game eventually * * player.SendMessage($"§cUpdating game level to {args[1]}"); * } * else if (args[0].Equals("nextstate")) * { * GameState nextState = level.CurrentState.GetNextGameState(level); * if (nextState is VoidGameState) * { * player.SendMessage("§cNo Next Available State Available."); * return; * } * * player.SendMessage($"§cProgressing to next state ({level.CurrentState.GetType()} -> {nextState.GetType()})"); * level.UpdateGameState(nextState); * } * else * { * if (!HandleGameEditCommand(player as SkyPlayer, level, gameLevelInfo, args)) * { * player.SendMessage("§c/gameedit timeleft"); * player.SendMessage("§c/gameedit tp"); * player.SendMessage("§c/gameedit nextstate"); * player.SendMessage("§c/gameedit level <level-name>"); * { * string subCommandHelp = GetGameEditCommandHelp(player as SkyPlayer); * if (subCommandHelp != null) * { * player.SendMessage(subCommandHelp); * } * } * player.SendMessage($"§cBad Args: {string.Join(",", args.Select(x => x.ToString()).ToArray())}"); * } * } * }*/ public override bool HandleGameEditCommand(SkyPlayer player, GameLevel gameLevel, GameLevelInfo gameLevelInfo, params string[] args) { if (args[0].Equals("tp")) { if (!(gameLevel is BuildBattleLevel level)) { player.SendMessage("§eWorld is not BuildBattle world!"); return(false); } player.SendMessage("§eTeleporting to a random spawn location"); player.Teleport(level.BuildTeams[Random.Next(level.BuildTeams.Count)].SpawnLocation); } else { return(false); } return(true); }
public static void AddPlayer(SkyPlayer player, string gameName) { if (player == null) { return; } if (!GameRegistrations.ContainsKey(gameName)) { player.SendMessage($"{ChatColors.Red}No game existed for the name '{gameName}'"); return; } RequeuePlayer(player, gameName); }
public static void RequeuePlayer(SkyPlayer player, string gameName) { if (!GameRegistrations.ContainsKey(gameName)) { player.SendMessage($"{ChatColors.Red}No game existed for the name '{gameName}'"); return; } try { GameRegistrations[gameName].AddPlayer(player); } catch (Exception e) { BugSnagUtil.ReportBug(e); } }
public void DoTick() { List <int> removedKeys = new List <int>(); bool isContentAlreadyVisible = false; foreach (int priorityKey in _popupContentQueue.Keys) { string visibleContent = ProcessContentQueue(_popupContentQueue[priorityKey]); if (visibleContent == null) { removedKeys.Add(priorityKey); } else if (!isContentAlreadyVisible) { string content; if (_player.GameMode == GameMode.Creative) { content = $"{visibleContent}"; } else { content = $"{visibleContent}"; } _player.SendMessage(content, MessageType.Popup); isContentAlreadyVisible = true; } } foreach (int priorityKey in removedKeys) { _popupContentQueue.Remove(priorityKey); } removedKeys.Clear(); isContentAlreadyVisible = false; foreach (int priorityKey in _barContentQueue.Keys) { string visibleContent = ProcessContentQueue(_barContentQueue[priorityKey]); if (visibleContent == null) { removedKeys.Add(priorityKey); } else if (!isContentAlreadyVisible) { _player.SendTitle("", TitleType.AnimationTimes, 6, 6, 20); string content; if (_player.GameMode == GameMode.Creative) { content = $"§f\n§f\n§f\n{visibleContent}"; } else { content = $"§f\n{visibleContent}\n§f\n§f"; } _player.SendTitle(content, TitleType.ActionBar); isContentAlreadyVisible = true; } } foreach (int priorityKey in removedKeys) { _barContentQueue.Remove(priorityKey); } }
public override bool HandleGameEditCommand(SkyPlayer player, GameLevel level, GameLevelInfo gameLevelInfo, params string[] args) { if (!(gameLevelInfo is MurderLevelInfo murderLevelInfo)) { player.SendMessage("§cThe current levels game info is not in the correct format to be a Murder Level Info."); player.SendMessage("§cUpdating as MurderLevelInfo and saving with default options."); murderLevelInfo = new MurderLevelInfo(gameLevelInfo.LevelName, gameLevelInfo.WorldTime, gameLevelInfo.LobbyLocation, new List <PlayerLocation>(), new List <PlayerLocation>()); } if (args[0].Equals("add")) { if (args.Length < 2) { player.SendMessage("§c/location add <spawn/gunpart>"); player.SendMessage("§cNot Enough Arguments."); return(true); } List <PlayerLocation> locationList = null; if (args[1].Equals("spawn")) { locationList = murderLevelInfo.PlayerSpawnLocations; } else if (args[1].Equals("gunpart")) { locationList = murderLevelInfo.GunPartLocations; } if (locationList == null) { player.SendMessage($"§cAction invalid. Must be 'spawn' or 'gunpart', but was '{args[1]}'"); return(true); } PlayerLocation addedLocation = (PlayerLocation)player.KnownPosition.Clone(); addedLocation.X = (float)(Math.Floor(addedLocation.X) + 0.5f); addedLocation.Y = (float)Math.Floor(addedLocation.Y); addedLocation.Z = (float)(Math.Floor(addedLocation.Z) + 0.5f); addedLocation.HeadYaw = (float)Math.Floor(addedLocation.HeadYaw); addedLocation.HeadYaw = addedLocation.HeadYaw; addedLocation.Pitch = (float)Math.Floor(addedLocation.Pitch); locationList.Add(addedLocation); string fileName = $"C:\\Users\\Administrator\\Desktop\\worlds\\{RawName}\\{RawName}-{level.LevelName}.json"; SkyUtil.log($"Saving as '{fileName}' -> {level.GameType} AND {level.LevelName}"); File.WriteAllText(fileName, JsonConvert.SerializeObject(gameLevelInfo, Formatting.Indented)); player.SendMessage($"§cUpdated {args[0]} location list ({locationList.Count}) with current location."); //Update current level info ((MurderLevel)player.Level).GameLevelInfo = gameLevelInfo; } else if (args[0].Equals("visualize")) { if (_currentVisualizationTasks.ContainsKey(player.Username)) { _currentVisualizationTasks[player.Username].Cancelled = true; _currentVisualizationTasks.Remove(player.Username); player.SendMessage("§eCancelling Visualization Task"); } else { player.SendMessage("§eVisualizing Gun Part and Player Spawn Locations..."); _currentVisualizationTasks.Add(player.Username, RunnableTask.RunTaskIndefinitely(() => { foreach (PlayerLocation location in murderLevelInfo.GunPartLocations) { PlayerLocation displayLocation = (PlayerLocation)location.Clone(); displayLocation.Y += 0.5f; Vector3 particleLocation = displayLocation.ToVector3(); new FlameParticle(player.Level) { Position = particleLocation }.Spawn(new MiNET.Player[] { player }); } foreach (PlayerLocation location in murderLevelInfo.PlayerSpawnLocations) { PlayerLocation displayLocation = (PlayerLocation)location.Clone(); displayLocation.Y += 0.5f; Vector3 particleLocation = displayLocation.ToVector3(); new HeartParticle(player.Level) { Position = particleLocation }.Spawn(new MiNET.Player[] { player }); } }, 500)); } } else if (args[0].Equals("tp")) { player.SendMessage("§eTeleporting to a random spawn location"); player.Teleport(murderLevelInfo.PlayerSpawnLocations[Random.Next(murderLevelInfo.PlayerSpawnLocations.Count)]); } else { //Falls through, no specific handling return(false); } //One if-branch was used, this counts enough as usage return(true); }