Skip to content

Commit

Permalink
Merge pull request #20 from takunology/2.0.0-dev
Browse files Browse the repository at this point in the history
release 2.0.0
  • Loading branch information
Takumi Okawa authored Aug 20, 2022
2 parents f54635f + 8f9d5ee commit 2ec54bd
Show file tree
Hide file tree
Showing 80 changed files with 860 additions and 52 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified MinecraftConnection/.vs/MinecraftConnection/v17/.suo
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected LivingEntityBase() { }

protected LivingEntityBase(string entityId)
{
EntityId = entityId;
this.EntityId = entityId;
}

public void GetPosition()
Expand Down
33 changes: 27 additions & 6 deletions MinecraftConnection/MinecraftConnection/Extends/ExtendsMethods.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,59 @@
using MinecraftConnection.Entity;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;

namespace MinecraftConnection.Extends
{
public static class ExtendsMethods
{
/// <summary>
/// Sort the item stack in ascending order by Item ID.
/// </summary>
/// <param name="items">Listed Item Stacks</param>
/// <returns>Sorted and listed item stacks</returns>
public static List<ItemStack> SortById(this List<ItemStack> items)
{
var sortedItems = items.OrderBy(x => x.Id).ToList();
return ItemStackNumbering(ref sortedItems);
}

/// <summary>
/// Sort the item stack in descending order by ID.
/// </summary>
/// <param name="items">Listed Item Stacks</param>
/// <returns>Sorted and listed item stacks</returns>
public static List<ItemStack> SortByIdDescending(this List<ItemStack> items)
{
var sortedItems = items.OrderByDescending(x => x.Id).ToList();
return ItemStackNumbering(ref sortedItems);
}

/// <summary>
/// Sort the item stack in ascending order by Item count.
/// </summary>
/// <param name="items">Listed Item Stacks</param>
/// <returns>Sorted and listed item stacks</returns>
public static List<ItemStack> SortByCount(this List<ItemStack> items)
{
var sortedItems = items.OrderBy(x => x.Count).ToList();
return ItemStackNumbering(ref sortedItems);
}

/// <summary>
/// Sort the item stack in descending order by Item count.
/// </summary>
/// <param name="items">Listed Item Stacks</param>
/// <returns>Sorted and listed item stacks</returns>
public static List<ItemStack> SortByCountDescending(this List<ItemStack> items)
{
var sortedItems = items.OrderBy(x => x.Count).ToList();
var sortedItems = items.OrderByDescending(x => x.Count).ToList();
return ItemStackNumbering(ref sortedItems);
}

/// <summary>
/// Sort items by ID, combining as many items as possible into one.
/// </summary>
/// <param name="items">Listed Item Stacks</param>
/// <returns>Sorted and listed item stacks</returns>
public static List<ItemStack> SortItems(this List<ItemStack> items)
{
var groupingItems = items.OrderBy(x => x.Id).GroupBy(x => x.Id);
Expand Down
14 changes: 0 additions & 14 deletions MinecraftConnection/MinecraftConnection/MinecraftBlocks.cs

This file was deleted.

113 changes: 105 additions & 8 deletions MinecraftConnection/MinecraftConnection/MinecraftCommands.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MinecraftConnection.RCON;
using MinecraftConnection.Block;
using MinecraftConnection.Entity;
using MinecraftConnection.Extends;
using MinecraftConnection.Block;
using MinecraftConnection.RCON;
using System.Collections.Generic;
using System.Threading;

namespace MinecraftConnection
{
/// <summary>
/// Create an instance to send commands to Minecraft.
/// </summary>
public partial class MinecraftCommands
{
public MinecraftCommands(string address, ushort port, string password)
Expand All @@ -23,47 +25,142 @@ public MinecraftCommands(string address, ushort port, string password)
/// </summary>
public partial class MinecraftCommands
{
/// <summary>
/// Execute any command.
/// </summary>
/// <param name="command">Minecraft command</param>
/// <returns>Result of command execution</returns>
/// <exception cref="System.Exception">The stop command cannot be executed from a remote console.</exception>
public string SendCommand(string command)
{
if (command.Equals("stop"))
throw new System.Exception("The stop command can only be sent from the server console.");
return PublicRcon.Rcon.SendCommand(command);
}

/// <summary>
/// Sets the time in Minecraft.
/// </summary>
/// <param name="time">Any time</param>
/// <returns>Result of command execution</returns>
public string TimeSet(ushort time) => PublicRcon.Rcon.SendCommand($"time set {time}");

/// <summary>
/// Wait for a specified period of time.
/// </summary>
/// <param name="time">Any time</param>
public void Wait(ushort time) => Thread.Sleep(time);

/// <summary>
/// Get entity data about the player.
/// </summary>
/// <param name="playerName">player ID</param>
/// <returns>Player class</returns>
public Player GetPlayerData(string playerName) => new Player(playerName);

/// <summary>
/// Display the title in the center of the game screen.
/// </summary>
/// <param name="title">Any string</param>
/// <returns>Result of command execution</returns>
public string DisplayTitle(string title)
{
return PublicRcon.Rcon.SendCommand($"title @a title \"{title}\"");
}

/// <summary>
/// Set subtitle. The subtitle will be displayed with the title when it is displayed.
/// </summary>
/// <param name="subTitle">Any string</param>
/// <returns>Result of command execution</returns>
public string SetSubTitle(string subTitle)
{
return PublicRcon.Rcon.SendCommand($"title @a subtitle \"{subTitle}\"");
}

/// <summary>
/// Fireworks are set off from the specified coordinates.
/// </summary>
/// <param name="position">Coordinates to be set off</param>
/// <param name="fireworks">Fireworks instance</param>
/// <returns></returns>
public string SetOffFireworks(Position position, Fireworks fireworks)
{
return PublicRcon.Rcon.SendCommand($"summon firework_rocket {position.X} {position.Y} {position.Z} {fireworks.GetNBT()}");
}

/// <summary>
/// Fireworks are set off from the specified coordinates.
/// </summary>
/// <param name="x">Coordinate x</param>
/// <param name="y">Coordinate y</param>
/// <param name="z">Coordinate z</param>
/// <param name="fireworks">Fireworks instance</param>
/// <returns></returns>
public string SetOffFireworks(double x, double y, double z, Fireworks fireworks)
{
return PublicRcon.Rcon.SendCommand($"summon firework_rocket {(int)x} {(int)y} {(int)z} {fireworks.GetNBT()}");
}

/// <summary>
/// Places the block at the specified coordinates.
/// </summary>
/// <param name="x">Coordinate x</param>
/// <param name="y">Coordinate y</param>
/// <param name="z">Coordinate z</param>
/// <param name="blockId">Block ID</param>
/// <returns></returns>
public string SetBlock(int x, int y, int z, string blockId)
{
return PublicRcon.Rcon.SendCommand($"setblock {x} {y} {z} {blockId}");
}

/*public string SetBlock(Position position, BlockItem block)
/// <summary>
/// Get the items in the chest placed at the specified coordinates.
/// </summary>
/// <param name="position">Chest Coordinates</param>
/// <returns>Receives item stacks in list form.</returns>
public List<ItemStack> GetChestItems(Position position)
{
var chestItems = new ChestBlock(position);
return chestItems.GetItems();
}

/// <summary>
/// Get the items in the chest placed at the specified coordinates.
/// </summary>
/// <param name="x">Coordinate x</param>
/// <param name="y">Coordinate y</param>
/// <param name="z">Coordinate z</param>
/// <returns>Receives item stacks in list form.</returns>
public List<ItemStack> GetChestItems(int x, int y, int z)
{
var chestItems = new ChestBlock(x, y, z);
return chestItems.GetItems();
}

/// <summary>
/// Sets the items in the chest at the specified coordinates.
/// </summary>
/// <param name="position">Chest Coordinates</param>
/// <param name="items">List of items to be set</param>
public void SetChestItems(Position position, List<ItemStack> items)
{
return PublicRcon.Rcon.SendCommand($"setblock {position.X} {position.Y} {position.Z} {block.BlockId}");
}*/
var chestItems = new ChestBlock(position);
chestItems.SetItems(items);
}

/// <summary>
/// Sets the items in the chest at the specified coordinates.
/// </summary>
/// <param name="x">Coordinate x</param>
/// <param name="y">Coordinate y</param>
/// <param name="z">Coordinate z</param>
/// <param name="items">List of items to be set</param>
public void SetChestItems(int x, int y, int z, List<ItemStack> items)
{
var chestItems = new ChestBlock(x, y, z);
chestItems.SetItems(items);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion>
<Authors>Takumi Okawa (Takunology)</Authors>
<Company>Minecraft_with_Code_Project</Company>
<Version>2.0.0-preview1</Version>
<Version>2.0.0</Version>
<PackageId>MinecraftConnection</PackageId>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand All @@ -18,10 +18,11 @@
<Copyright>Copyright (c) 2021 Takumi Okawa (Takunology)</Copyright>
<PackageIconUrl />
<PackageTags>Minecraft</PackageTags>
<PackageReleaseNotes>Version 2.0.0 - preview 1
<PackageReleaseNotes>Version 2.0.0

MinecraftConnection destructive changes were made. It is written differently than version 1. Documentation is still under construction.
Starting with 2.0.0, Minecraft now supports all languages, including Japanese, Chinese, Hindi, etc., as well as English in the Minecraft title display.</PackageReleaseNotes>
- MinecraftConnection has undergone a disruptive change.
- Support for various languages has been added.
- We have tested up to Version 1.19.2</PackageReleaseNotes>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>True|2022-02-15T12:50:15.1469967Z;</History>
<History>True|2022-08-20T00:10:23.4166908Z;True|2022-02-15T21:50:15.1469967+09:00;</History>
</PropertyGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"targets": {
".NETStandard,Version=v2.1": {},
".NETStandard,Version=v2.1/": {
"MinecraftConnection/2.0.0-preview1": {
"MinecraftConnection/2.0.0": {
"dependencies": {
"System.Text.Json": "6.0.3"
},
Expand Down Expand Up @@ -104,7 +104,7 @@
}
},
"libraries": {
"MinecraftConnection/2.0.0-preview1": {
"MinecraftConnection/2.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright (c) 2021 Takumi Okawa (Takunology)")]
[assembly: System.Reflection.AssemblyDescriptionAttribute(@"MinecraftConnection is a library for sending commands via RCON using C# to support you learn and automate your programming. It can be run on a vanilla server as well as a Spigot server, including plugins. Before running the program, you need to start a Minecraft server that allows RCON connections.")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("2.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0-preview1")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("MinecraftConnection")]
[assembly: System.Reflection.AssemblyTitleAttribute("MinecraftConnection")]
[assembly: System.Reflection.AssemblyVersionAttribute("2.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5b03834ca75b385d6a1013378db74ebccf777659
dbb19257d3cb418b3e64d4e86faf89ddc3caf992
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3aadf2eb06b21530dcea9bf044b6cd7a2c386408
58ac09808e49a60d39082e10803bbe07bec02c70
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"projects": {
"D:\\GitHub\\MinecraftConnection\\MinecraftConnection\\MinecraftConnection\\MinecraftConnection.csproj": {
"version": "2.0.0-preview1",
"version": "2.0.0",
"restore": {
"projectUniqueName": "D:\\GitHub\\MinecraftConnection\\MinecraftConnection\\MinecraftConnection\\MinecraftConnection.csproj",
"projectName": "MinecraftConnection",
Expand Down Expand Up @@ -68,7 +68,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.300\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.302\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\takun\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages;C:\Program Files (x86)\Microsoft\Xamarin\NuGet\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.2.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.2.1</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\takun\.nuget\packages\" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>MinecraftConnection</id>
<version>2.0.0</version>
<authors>Takumi Okawa (Takunology)</authors>
<license type="expression">MIT</license>
<licenseUrl>https://licenses.nuget.org/MIT</licenseUrl>
<icon>MCLogo.png</icon>
<projectUrl>https://www.mcwithcode.com/</projectUrl>
<description>MinecraftConnection is a library for sending commands via RCON using C# to support you learn and automate your programming. It can be run on a vanilla server as well as a Spigot server, including plugins. Before running the program, you need to start a Minecraft server that allows RCON connections.</description>
<releaseNotes>Version 2.0.0

- MinecraftConnection has undergone a disruptive change.
- Support for various languages has been added.
- We have tested up to Version 1.19.2</releaseNotes>
<copyright>Copyright (c) 2021 Takumi Okawa (Takunology)</copyright>
<tags>Minecraft</tags>
<repository type="git" url="https://github.com/takunology/MinecraftConnection" />
<dependencies>
<group targetFramework=".NETStandard2.1">
<dependency id="System.Text.Json" version="6.0.3" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
<files>
<file src="D:\GitHub\MinecraftConnection\MinecraftConnection\MinecraftConnection\bin\Release\netstandard2.1\MinecraftConnection.dll" target="lib\netstandard2.1\MinecraftConnection.dll" />
<file src="D:\GitHub\MinecraftConnection\MinecraftConnection\MinecraftConnection\MCLogo.png" target="MCLogo.png" />
</files>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright (c) 2021 Takumi Okawa (Takunology)")]
[assembly: System.Reflection.AssemblyDescriptionAttribute(@"MinecraftConnection is a library for sending commands via RCON using C# to support you learn and automate your programming. It can be run on a vanilla server as well as a Spigot server, including plugins. Before running the program, you need to start a Minecraft server that allows RCON connections.")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("2.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0-preview1")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("2.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("MinecraftConnection")]
[assembly: System.Reflection.AssemblyTitleAttribute("MinecraftConnection")]
[assembly: System.Reflection.AssemblyVersionAttribute("2.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68c8386b9eeb8b7d4e62d64b8faefab6a433731e
1a69108a1ba5a96e1599f4a7f2e1f2e92c85fcc5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b1a4e61eba72492c6f82914f13d438dccc2d41fc
55ebbe7502f00ee1b87d8abba2101c645c018603
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 2ec54bd

Please sign in to comment.