Fix all warnings & Trim (#2226)

* Fix AutoFishing crash
* Fix all warnings
* Remove DotNetZip.
* Fix the usage of HttpClient.
This commit is contained in:
BruceChen 2022-10-02 18:31:08 +08:00 committed by GitHub
parent 4aa6c1c99f
commit 1d52d1eadd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
227 changed files with 2201 additions and 43564 deletions

View file

@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
{

View file

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Linq;
using System.Text;
namespace MinecraftClient.Mapping.BlockPalettes
@ -42,13 +42,13 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// <param name="outputEnum">output path for material.cs</param>
/// <remarks>java -cp minecraft_server.jar net.minecraft.data.Main --reports</remarks>
/// <returns>state => block name mappings</returns>
public static void JsonToClass(string blocksJsonFile, string outputClass, string outputEnum = null)
public static void JsonToClass(string blocksJsonFile, string outputClass, string? outputEnum = null)
{
string outputPalettePath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputClass + "XXX.cs");
string outputEnumPath = Path.Combine(Path.GetDirectoryName(blocksJsonFile), outputEnum + "XXX.cs");
string outputPalettePath = Path.Combine(Path.GetDirectoryName(blocksJsonFile)!, outputClass + "XXX.cs");
string outputEnumPath = Path.Combine(Path.GetDirectoryName(blocksJsonFile)!, outputEnum + "XXX.cs");
HashSet<int> knownStates = new HashSet<int>();
Dictionary<string, HashSet<int>> blocks = new Dictionary<string, HashSet<int>>();
HashSet<int> knownStates = new();
Dictionary<string, HashSet<int>> blocks = new();
Json.JSONData palette = Json.ParseJson(File.ReadAllText(blocksJsonFile, Encoding.UTF8));
foreach (KeyValuePair<string, Json.JSONData> item in palette.Properties)
@ -76,17 +76,16 @@ namespace MinecraftClient.Mapping.BlockPalettes
}
}
HashSet<string> materials = new HashSet<string>();
List<string> outFile = new List<string>();
HashSet<string> materials = new();
List<string> outFile = new();
outFile.AddRange(new[] {
"using System;",
"using System.Collections.Generic;",
"",
"namespace MinecraftClient.Mapping.BlockPalettes",
"{",
" public class PaletteXXX : BlockPalette",
" {",
" private static Dictionary<int, Material> materials = new Dictionary<int, Material>();",
" private static readonly Dictionary<int, Material> materials = new();",
"",
" static PaletteXXX()",
" {",
@ -103,7 +102,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
if (idList.Count > 1)
{
idList.Sort();
Queue<int> idQueue = new Queue<int>(idList);
Queue<int> idQueue = new(idList);
while (idQueue.Count > 0)
{

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
@ -11,7 +10,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// </summary>
public class Palette112 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>()
private static readonly Dictionary<int, Material> materials = new()
{
{ 0, Material.Air },
{ 1, Material.Stone },

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
@ -9,7 +8,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// </summary>
public class Palette113 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette113()
{

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
@ -9,7 +8,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// </summary>
public class Palette114 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette114()
{

View file

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
@ -9,7 +8,7 @@ namespace MinecraftClient.Mapping.BlockPalettes
/// </summary>
public class Palette115 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette115()
{

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
{
public class Palette116 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette116()
{

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
{
public class Palette117 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette117()
{

View file

@ -1,11 +1,10 @@
using System;
using System.Collections.Generic;
namespace MinecraftClient.Mapping.BlockPalettes
{
public class Palette119 : BlockPalette
{
private static Dictionary<int, Material> materials = new Dictionary<int, Material>();
private static readonly Dictionary<int, Material> materials = new();
static Palette119()
{