Exemplo n.º 1
0
            /// <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);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Adds the specified <see cref="SharpCraft.Objective"/> to the world
            /// </summary>
            /// <param name="scoreName">The name of the <see cref="SharpCraft.Objective"/></param>
            /// <param name="type">the type of the scoreboard. See <see cref="ID.Objective"/> for a list of types</param>
            /// <param name="displayName">The name to display when the scoreboard is viewed in the sidebar</param>
            /// <returns>the newly created <see cref="SharpCraft.Objective"/></returns>
            public Objective Add(string scoreName, string type = "dummy", BaseJsonText?displayName = null)
            {
                Objective newObject = new Objective(scoreName);

                ForFunction.AddCommand(new ScoreboardObjectiveAddCommand(newObject, type, displayName));
                return(newObject);
            }
Exemplo n.º 3
0
 /// <summary>
 /// Executes if the <paramref name="mainSelector"/>'s score value is <paramref name="operation"/> than <paramref name="otherSelector"/>'s score value
 /// </summary>
 /// <param name="mainSelector">The first <see cref="BaseSelector"/></param>
 /// <param name="mainObject">The first <see cref="BaseSelector"/>'s <see cref="Objective"/></param>
 /// <param name="operation">The operation used to check the scores</param>
 /// <param name="otherSelector">The second <see cref="BaseSelector"/></param>
 /// <param name="otherObject">The second <see cref="BaseSelector"/>'s <see cref="Objective"/></param>
 /// <param name="want">false if it should execute when it's false</param>
 /// <returns>The function running the command</returns>
 public Function IfScore(BaseSelector mainSelector, Objective mainObject, ID.IfScoreOperation operation, BaseSelector otherSelector, Objective otherObject, bool want = true)
 {
     mainSelector.LimitSelector();
     otherSelector.LimitSelector();
     ForFunction.AddCommand(new ExecuteIfScoreRelative(mainSelector, mainObject, operation, otherSelector, otherObject, want));
     return(ForFunction);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Auto aligns the execute coordinates to all the axis
 /// </summary>
 /// <param name="center">True if it should center to the block</param>
 /// <returns>The function running the command</returns>
 public Function Align(bool center = false)
 {
     ForFunction.AddCommand(new ExecuteAlign());
     if (center)
     {
         ForFunction.AddCommand(new ExecutePosition(new Coords(0.5, 0.5, 0.5)));
     }
     return(ForFunction);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Enables the specified <see cref="SharpCraft.Datapack"/>
 /// </summary>
 /// <param name="datapack">the <see cref="SharpCraft.Datapack"/> to enable</param>
 /// <param name="placeAt">choses where the <see cref="SharpCraft.Datapack"/> should be placed relative to other enabled <see cref="SharpCraft.Datapack"/>s</param>
 /// <param name="otherPack">the <see cref="SharpCraft.Datapack"/> the <paramref name="datapack"/> is placed relative to</param>
 public void Enable(BaseDatapack datapack, ID.DatapackPlace placeAt, Datapack?otherPack = null)
 {
     if (otherPack is null)
     {
         ForFunction.AddCommand(new DatapackEnableCommand(datapack, placeAt == ID.DatapackPlace.first));
     }
     else
     {
         ForFunction.AddCommand(new DatapackEnableAtCommand(datapack, placeAt == ID.DatapackPlace.after, otherPack));
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// Makes the selected entities join the specified <see cref="Team"/>
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="team">The team they should join. Leave null to make them leave their team</param>
 public void JoinTeam(BaseSelector selector, Team?team)
 {
     if (team != null)
     {
         ForFunction.AddCommand(new TeamJoinCommand(team, selector));
     }
     else
     {
         ForFunction.AddCommand(new TeamLeaveCommand(selector));
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Clears a display slot
 /// </summary>
 /// <param name="display">the display slot to clear</param>
 /// <param name="teamColor">the team's sidebar slot to clear. Note: this only works with <see cref="ID.ScoreDisplay.sidebar"/> as the <paramref name="display"/></param>
 public void ClearDisplay(ID.ScoreDisplay display, ID.MinecraftColor?teamColor = null)
 {
     if (display == ID.ScoreDisplay.sidebar && !(teamColor is null))
     {
         ForFunction.AddCommand(new ScoreboardSetTeamDisplayCommand(null, teamColor.Value));
     }
     else
     {
         ForFunction.AddCommand(new ScoreboardSetDisplayCommand(null, display));
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Spawns loot into the world at the given location
 /// </summary>
 /// <param name="coords">The location to spawn the loot</param>
 /// <param name="breakBlock">the block whose "when mined loot" should be dropped</param>
 /// <param name="breakWith">the tool used to break the block</param>
 public void Loot(Vector coords, Vector breakBlock, Item breakWith)
 {
     if (breakWith is null)
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.SpawnTarget(coords), new LootSources.MineHandSource(breakBlock, true)));
     }
     else
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.SpawnTarget(coords), new LootSources.MineItemSource(breakBlock, breakWith)));
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Gives an item to the selected players
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="giveItem">The <see cref="Item"/> to give to the players</param>
 public void GiveItem(BaseSelector player, Item giveItem)
 {
     if (giveItem.Slot is null)
     {
         ForFunction.AddCommand(new GiveCommand(player, giveItem, giveItem.Count ?? 1));
     }
     else
     {
         ForFunction.AddCommand(new ReplaceitemEntityCommand(player, new Slots.InventorySlot((int)giveItem.Slot), giveItem, giveItem.Count ?? 1));
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// Puts the item from the loot table into the players hotbar
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="breakBlock">the coords of the block</param>
 /// <param name="breakWith">the item used to break the block</param>
 /// <param name="slot">The hotbar slot to put the item in</param>
 public void GiveHotbar(BaseSelector player, Vector breakBlock, Item?breakWith, int slot)
 {
     if (breakWith is null)
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.EntityTarget(player, new Slots.HotbarSlot(slot)), new LootSources.MineHandSource(breakBlock, true)));
     }
     else
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.EntityTarget(player, new Slots.HotbarSlot(slot)), new LootSources.MineItemSource(breakBlock, breakWith)));
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Gives the loot which the block at the given coords would drop of broken to the selected players
 /// </summary>
 /// <param name="player">the <see cref="BaseSelector"/> to use</param>
 /// <param name="breakBlock">the coords of the block</param>
 /// <param name="breakWith">the item used to break the block</param>
 public void GiveItem(BaseSelector player, Vector breakBlock, Item?breakWith)
 {
     if (breakWith is null)
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.GiveTarget(player), new LootSources.MineHandSource(breakBlock, true)));
     }
     else
     {
         ForFunction.AddCommand(new LootCommand(new LootTargets.GiveTarget(player), new LootSources.MineItemSource(breakBlock, breakWith)));
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Runs the specified function
        /// </summary>
        /// <param name="runFunction">the function to run</param>
        /// <param name="delay">the amount of time to function execution should be delayed. null doesnt delay it.
        /// (If value is other than null the function will ignore the arguments send in the execute command which executed it)</param>
        /// <param name="append">If the function is being scheduled: if false replace the last time the function was scheduled</param>
        /// <returns>The ran function</returns>
        public IFunction Function(IFunction runFunction, NoneNegativeTime <int>?delay = null, bool append = true)
        {
            if (delay == null)
            {
                ForFunction.AddCommand(new RunFunctionCommand(runFunction));
            }
            else
            {
                ForFunction.AddCommand(new ScheduleAddCommand(runFunction, delay, append));
            }

            return(runFunction);
        }
Exemplo n.º 13
0
 /// <summary>
 /// Forces a player to spectate an entity. The player has to be in spectator mode. Leave both params empty to make the executing player stop spectating
 /// </summary>
 /// <param name="spectate">The entity to spectate</param>
 /// <param name="spectator">The spectating player</param>
 public void Spectate(BaseSelector spectate, BaseSelector spectator)
 {
     if (spectate is null)
     {
         ForFunction.AddCommand(new SpectateStopCommand());
     }
     else
     {
         spectate.LimitSelector();
         spectator.LimitSelector();
         ForFunction.AddCommand(new SpectateCommand(spectate, spectator));
     }
 }
Exemplo n.º 14
0
 /// <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));
         }
     });
 }
Exemplo n.º 15
0
            /// <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);
            }
Exemplo n.º 16
0
 /// <summary>
 /// Makes the specified item the selected horses' chest
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="giveItem">the item to add to the horses.</param>
 public void Chest(BaseSelector selector, Item giveItem)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.HorseSlot(ID.HorseSlot.chest), giveItem, giveItem.Count ?? 1));
 }
Exemplo n.º 17
0
 /// <summary>
 /// Adds the specified item to the selected horses' inventory
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="giveItem">the item to add to the horses. <see cref="Item.Slot"/> is used to specify the slot</param>
 public void Inventory(BaseSelector selector, Item giveItem)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.HorseInventorySlot(giveItem.Slot ?? 0), giveItem, giveItem.Count ?? 1));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Adds the specified item to the selected villagers' inventory
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="addItem">the item to add to the villager. <see cref="Item.Slot"/> is used to specify the slot</param>
 public void VillagerInventory(BaseSelector selector, Item addItem)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.VillagerInventorySlot(addItem.Slot ?? 0), addItem, addItem.Count ?? 1));
 }
Exemplo n.º 19
0
 /// <summary>
 /// Adds the specified item to the selected entities' inventory
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="addItem">the item to add to the entities. <see cref="Item.Slot"/> is used to specify the slot</param>
 public void Container(BaseSelector selector, Item addItem)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.ContainerSlot(addItem.Slot ?? 0), addItem, addItem.Count ?? 1));
 }
Exemplo n.º 20
0
 /// <summary>
 /// Changes the selected entities' weapon to the specified item
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="giveItem">the <see cref="Item"/> to give</param>
 /// <param name="offHand">If its the offhand weapon which should change</param>
 public void Weapon(BaseSelector selector, Item giveItem, bool offHand = false)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.WeaponSlot(!offHand), giveItem, giveItem.Count ?? 1));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Changes the selected entities' armor to the specified item
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="giveItem">the <see cref="Item"/> to give</param>
 /// <param name="armorSlot">the armor slot to put the item in</param>
 public void Armor(BaseSelector selector, Item giveItem, ID.ArmorSlot armorSlot)
 {
     ForFunction.AddCommand(new ReplaceitemEntityCommand(selector, new Slots.ArmorSlot(armorSlot), giveItem, giveItem.Count ?? 1));
 }
Exemplo n.º 22
0
 /// <summary>
 /// Spreads all entities selected by the selector around the specified location
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="center">The center to spread around</param>
 /// <param name="minDistance">the minimum distance the player can be spreaded away from each other</param>
 /// <param name="spreadDistanceMax">the maximum distance the player can be spreaded from the <paramref name="center"/></param>
 /// <param name="spreadTeams">If teams should be placed close to each other</param>
 /// <param name="underHeight">The height the players will be spread under. Leave null to use maximum height.</param>
 public void Spread(BaseSelector selector, Vector center, int minDistance, int spreadDistanceMax, bool spreadTeams = false, int?underHeight = null)
 {
     ForFunction.AddCommand(new SpreadPlayersCommand(center, selector, minDistance, spreadDistanceMax, spreadTeams, underHeight));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Gives the specified effect to the selected entities
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="effect">the effect to give</param>
 /// <param name="time">the duration of the effect</param>
 /// <param name="amplifier">the amplifier of the effect (0 = level 1)</param>
 /// <param name="hideParticles">if the particles from the effect should be hidden or not</param>
 public void Give(BaseSelector selector, ID.Effect effect, int time, byte amplifier = 0, bool hideParticles = true)
 {
     ForFunction.AddCommand(new EffectGiveCommand(selector, effect, time, amplifier, hideParticles));
 }
Exemplo n.º 24
0
 /// <summary>
 /// Clears the specified effect from the selected entities
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="effect">the effect to remove</param>
 public void Clear(BaseSelector selector, ID.Effect?effect = null)
 {
     ForFunction.AddCommand(new EffectClearCommand(selector, effect));
 }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the selected entity's score and outputs it
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="objective">the <see cref="Objective"/> to take the score from</param>
 public void Get(BaseSelector selector, Objective objective)
 {
     selector.LimitSelector();
     ForFunction.AddCommand(new ScoreboardValueGetCommand(selector, objective));
 }
Exemplo n.º 26
0
 /// <summary>
 /// Teleports the selected entities to the specified location
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="tpTo">The location to teleport the entities to. Leave null to teleport to executed position</param>
 public void Teleport(BaseSelector selector, Vector?tpTo = null)
 {
     ForFunction.AddCommand(new TeleportToCommand(tpTo ?? new Coords(), selector));
 }
Exemplo n.º 27
0
 /// <summary>
 /// Enchants the selected entities hand item
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="enchant">the enchantment to enchant with</param>
 /// <param name="level">the level of the enchantment</param>
 public void Enchant(BaseSelector selector, ID.Enchant enchant, int level)
 {
     ForFunction.AddCommand(new EnchantCommand(selector, level, enchant));
 }
Exemplo n.º 28
0
 /// <summary>
 /// Does math with two scores and saves the result in one of the entities' score
 /// </summary>
 /// <param name="mainSelector">The first entity (The result will be stored in this entity's score)</param>
 /// <param name="mainObjective">The first entity's <see cref="Objective"/> (The result will be stored in here)</param>
 /// <param name="operationType">The operation to do between the numbers</param>
 /// <param name="otherSelector">The other entity</param>
 /// <param name="otherObjective">The other entity's <see cref="Objective"/></param>
 public void Operation(BaseSelector mainSelector, Objective mainObjective, ID.Operation operationType, BaseSelector otherSelector, Objective otherObjective)
 {
     mainSelector.LimitSelector();
     otherSelector.LimitSelector();
     ForFunction.AddCommand(new ScoreboardOperationCommand(mainSelector, mainObjective, operationType, otherSelector, otherObjective));
 }
Exemplo n.º 29
0
 /// <summary>
 /// Teleports the selected entities to the specified location
 /// </summary>
 /// <param name="selector">The <see cref="BaseSelector"/> to use</param>
 /// <param name="tpTo">The location to teleport the entities to</param>
 /// <param name="rotation">The rotation to teleport the selected entities to</param>
 public void Teleport(BaseSelector selector, Vector?tpTo, Rotation?rotation)
 {
     ForFunction.AddCommand(new TeleportToRotationCommand(tpTo ?? new Coords(), selector, rotation ?? new Rotation(true, 0, 0)));
 }
Exemplo n.º 30
0
 /// <summary>
 /// Resets the selected entities scores
 /// </summary>
 /// <param name="selector">the <see cref="BaseSelector"/> to use</param>
 /// <param name="objective">if a <see cref="Objective"/> is specified only the score in the specified <see cref="Objective"/> will be reseted</param>
 public void Reset(BaseSelector selector, Objective?objective = null)
 {
     ForFunction.AddCommand(new ScoreboardResetCommand(selector, objective));
 }