/// <summary> /// Adds a <see cref="SharpCraft.BossBar"/> with the specified name to the world /// </summary> /// <param name="name">the name of the <see cref="SharpCraft.BossBar"/></param> /// <param name="showName">The name to show ontop of the <see cref="SharpCraft.BossBar"/></param> /// <returns>the newly created <see cref="SharpCraft.BossBar"/></returns> public BossBar Add(string name, BaseJsonText showName) { BossBar addBar = new BossBar(ForFunction.PackNamespace, name.ToLower()); ForFunction.AddCommand(new BossBarAddCommand(addBar, showName)); return(addBar); }
/// <summary> /// Intializes a new <see cref="BaseVisibleAdvancement"/> /// </summary> /// <param name="packNamespace">The namespace the advancement is in</param> /// <param name="fileName">The name of the advancement file</param> /// <param name="writeSetting">The setting for writing the file</param> /// <param name="requirements">The requirements for getting the advancement</param> /// <param name="reward">The rewards to get for getting the advancement</param> /// <param name="announceInChat">True if when the advancement is unlocked it will be announced in chat. False if not</param> /// <param name="description">The description on the advancement</param> /// <param name="frame">The frame around the <see cref="Icon"/></param> /// <param name="hidden">True if the advancement can't be seen unless it has been unlocked</param> /// <param name="icon">The icon on the advancement</param> /// <param name="name">The shown advancement name</param> /// <param name="showToast">True if when the advancement is unlocked it will display a toast in the top right corner. False if not</param> protected BaseVisibleAdvancement(BasePackNamespace packNamespace, string?fileName, Requirement[] requirements, Reward?reward, BaseJsonText name, BaseJsonText description, Item icon, ID.AdvancementFrame frame = ID.AdvancementFrame.task, bool announceInChat = false, bool showToast = true, bool hidden = false, WriteSetting writeSetting = WriteSetting.LockedAuto) : base(packNamespace, fileName, requirements, reward, writeSetting) { Name = name; Description = description; Icon = icon; Frame = frame; AnnounceInChat = announceInChat; ShowToast = showToast; Hidden = hidden; }
public void TestAdding() { //setup BaseJsonText text1 = "hello"; BaseJsonText text2 = " "; BaseJsonText text3 = " world"; //test Assert.AreEqual("{\"extra\":[{\"text\":\" \"},{\"text\":\" world\"}],\"text\":\"hello\"}", (text1 + text2 + text3).GetJsonString(), "text isn't added together correctly"); Assert.AreEqual("{\"text\":\"hello\"}", text1.GetJsonString(), "Text was changed when being added together with other text"); }
/// <summary> /// Adds the specified <see cref="Team"/> to the world /// </summary> /// <param name="teamName">the <see cref="Team"/>'s name</param> /// <param name="displayName">the displayed name of the <see cref="Team"/></param> /// <param name="teamColor">the color of the <see cref="Team"/>. If null the <see cref="Team"/> will have the default color (white)</param> /// <returns>the newly created <see cref="Team"/></returns> public Team Add(string teamName, BaseJsonText displayName, ID.MinecraftColor?teamColor = null) { Team creating = new Team(teamName); if (teamColor is null) { ForFunction.AddCommand(new TeamAddCommand(creating, displayName)); } else { ForFunction.Custom.GroupCommands((g) => { g.AddCommand(new TeamAddCommand(creating, displayName)); g.AddCommand(new TeamModifyColorCommand(creating, teamColor.Value)); }); } return(creating); }
/// <summary> /// Displays a whole title for the selected players /// </summary> /// <param name="player">the <see cref="BaseSelector"/> to use</param> /// <param name="topMessage">The main title message</param> /// <param name="bottomMessage">the bottom part of the title message</param> /// <param name="startFade">The amount of ticks it takes for the title to fade in</param> /// <param name="stay">The amount of ticks the title stays on screen</param> /// <param name="endFade">The amount of ticks it takes for the title to fade out</param> public void FullTitle(BaseSelector player, BaseJsonText topMessage, BaseJsonText bottomMessage, NoneNegativeTime <int> startFade, NoneNegativeTime <int> stay, NoneNegativeTime <int> endFade) { ForFunction.Custom.GroupCommands(f => { ForFunction.AddCommand(new TitleTimesCommand(player, startFade, stay, endFade)); if (!(bottomMessage is null)) { ForFunction.AddCommand(new TitleSubtitleCommand(player, bottomMessage)); } if (topMessage is null) { ForFunction.AddCommand(new TitleCommand(player, new JsonText.Text(""))); } else { ForFunction.AddCommand(new TitleCommand(player, topMessage)); } }); }
/// <summary> /// Changes the specified <see cref="SharpCraft.BossBar"/>'s display name /// </summary> /// <param name="bossBar">the <see cref="SharpCraft.BossBar"/> to change</param> /// <param name="newName">the new display name for the bar</param> public void SetName(BossBar bossBar, BaseJsonText newName) { ForFunction.AddCommand(new BossBarChangeNameCommand(bossBar, newName)); }
/// <summary> /// Changes the suffix shown after the name of players in the specified <see cref="Team"/> /// </summary> /// <param name="changeTeam">the <see cref="Team"/> to change</param> /// <param name="suffixJson">the new prefix to show</param> public void Suffix(Team changeTeam, BaseJsonText suffixJson) { ForFunction.AddCommand(new TeamModifyDisplayCommand(changeTeam, ID.TeamDisplayName.suffix, suffixJson)); }
/// <summary> /// Changes the display name of the specified <see cref="Team"/> /// </summary> /// <param name="changeTeam">the <see cref="Team"/> to change</param> /// <param name="name">The new name of the team</param> public void DisplayName(Team changeTeam, BaseJsonText name) { ForFunction.AddCommand(new TeamModifyDisplayCommand(changeTeam, ID.TeamDisplayName.displayName, name)); }
/// <summary> /// Changes the <see cref="SharpCraft.Objective"/>'s displayed name /// </summary> /// <param name="objective">the <see cref="SharpCraft.Objective"/> to change</param> /// <param name="name">The new display name</param> public void DisplayName(Objective objective, BaseJsonText name) { ForFunction.AddCommand(new ScoreboardObjectiveChangeNameCommand(objective, name)); }
/// <summary> /// Intializes a new <see cref="BossBarAddCommand"/> /// </summary> /// <param name="bossBar">The boss bar to add</param> /// <param name="name">The shown name of the boss bar</param> public BossBarAddCommand(BossBar bossBar, BaseJsonText name) { BossBar = bossBar; Name = name; }
/// <summary> /// Intializes a new <see cref="NameChange"/> /// </summary> public NameChange(BaseJsonText name, ID.LootTarget?target = null) : base("minecraft:set_name") { Name = name; Target = target; }
/// <summary> /// displays a subtitle for the selected players /// Note: the subtitle is first shown when the title command is ran /// </summary> /// <param name="player">the <see cref="BaseSelector"/> to use</param> /// <param name="message">The message to show the players</param> public void SubTitle(BaseSelector player, BaseJsonText message) { ForFunction.AddCommand(new TitleSubtitleCommand(player, message)); }
/// <summary> /// Shows a message in the selected players actionbar /// </summary> /// <param name="player">the <see cref="BaseSelector"/> to use</param> /// <param name="message">The message to show</param> public void Actionbar(BaseSelector player, BaseJsonText message) { ForFunction.AddCommand(new TitleActionbarCommand(player, message)); }
/// <summary> /// Tells the selected players a message in chat /// </summary> /// <param name="player">the <see cref="BaseSelector"/> to use</param> /// <param name="message">The message to tell the players</param> public void Tellraw(BaseSelector player, BaseJsonText message) { ForFunction.AddCommand(new TellrawCommand(player, message)); }
/// <summary> /// Intializes a new <see cref="TextHoverEvent"/> /// </summary> /// <param name="text">The text to show when the text gets hovered</param> public TextHoverEvent(BaseJsonText text) : base("show_text") { Text = text; }
/// <summary> /// Intializes a new <see cref="ScoreboardObjectiveChangeNameCommand"/> /// </summary> /// <param name="displayName">The new display name for the objective</param> /// <param name="scoreObject">The objective to change</param> public ScoreboardObjectiveChangeNameCommand(Objective scoreObject, BaseJsonText displayName) { DisplayName = displayName; ScoreObject = scoreObject; }